@@ -44,28 +44,53 @@ const compiled = Wenyan.compile('吾有一言。曰「「問天地好在。」
44
44
45
45
- core
46
46
- [ compile] ( #compile )
47
+ - [ execute] ( #execute )
48
+
49
+ ### Execute
50
+
51
+ [ Source] ( ../src/parser.js )
52
+
53
+ ``` ts
54
+ function execute(source : string , options ? : ExecuteOptions )
55
+ ```
56
+
57
+ ** Parameters **
58
+
59
+ | Name | Type | Note |
60
+ | -- - | -- - | -- - |
61
+ | source | string | The Wenyan source code |
62
+ | options | object | [Execute Options ](#Execute - Options ) |
47
63
48
64
### Compile
49
65
50
66
[Source ](../ src / parser .js )
51
67
52
68
` ` ` ts
53
- function compile(targetLang : string , source : string , options ? : CompilerOptions )
69
+ function compile(source: string, options?: CompilerOptions)
54
70
` ` `
55
71
56
72
** Parameters **
57
73
58
74
| Name | Type | Note |
59
75
| -- - | -- - | -- - |
60
- | targetLang | string | Can be ` js ` , ` py ` or ` rb ` |
61
76
| source | string | The Wenyan source code |
62
77
| options | object | [Compiler Options ](#Compiler - Options ) |
63
78
64
- ### Compiler Options
79
+ #### Compiler Options
65
80
66
81
| Fields | Default Value | Note |
67
82
| -- - | -- - | -- - |
83
+ | lang | ` js ` | Target language , can be ` js ` , ` py ` or ` rb ` |
68
84
| romanizeIdentifiers | none | Romanize variable identifiers (e .g . ` 甲 ` to ` JIA2 ` ) |
69
85
| resetVarCnt | false | Reset temporary variable counter |
70
86
| logCallback | console .log | Get verbose debug log |
71
87
| errorLog | process .exit | Error log |
88
+
89
+ #### Execute Options
90
+
91
+ Execute Options extends all field in [Compiler Options ](#Compiler - Options )
92
+
93
+ | Fields | Default Value | Note |
94
+ | -- - | -- - | -- - |
95
+ | outputHanzi | true | Convert numbers and bools to Hanzi |
96
+ | output | ` console.log ` | You can redirect the output if you don ' t want to use `console.log` |
0 commit comments