1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
use crate::switch_lang;
pub fn command_message<'a>() -> &'a str {
switch_lang!(
"japanese" =>
"\
USAGE:
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
ARGS:
<script> スクリプトファイルからプログラムを読み込む
<script>に渡す引数を入力する
OPTIONS
--help/-?/-h このhelpを表示
--version/-V バージョンを表示
--verbose 0|1|2 冗長性レベルを指定
--opt-level/-o 0|1|2|3 最適化レベルを指定
--python-version/-p (uint 32 number) Pythonバージョンを指定
--py-server-timeout (uint 64 number) PythonのREPLサーバーのタイムアウト時間を指定
--dump-as-pyc .pycファイルにダンプ
--mode lex|parse|compile|exec 指定モードで実行(詳細は--mode --helpを参照)
SUBCOMMAND
-c cmd : 文字列をプログラムに譲渡
-m mod : モジュールを実行",
"simplified_chinese" =>
"\
USAGE:
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
ARGS:
<script> 从脚本文件读取程序
参数也可以指定要传递给 <script>
OPTIONS
--help/-?/-h 显示帮助
--version/-V 显示版本
--verbose 0|1|2 指定细致程度
--opt-level/-o 0|1|2|3 指定优化级别
--python-version/-p (uint 32 number) Python 版本
--py-server-timeout (uint 64 number) Python REPL 服务器超时
--dump-as-pyc 转储为 .pyc 文件
--mode lex|parse|compile|exec 执行模式 (更多信息见`--mode --help`)
SUBCOMMAND
-c cmd : 作为字符串传入程序
-m mod : 要执行的模块",
"traditional_chinese" =>
"\
USAGE:
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
ARGS:
<script> 從腳本檔案讀取程式
參數也可以指定要傳遞給 <script>
OPTIONS
--help/-?/-h 顯示幫助
--version/-V 顯示版本
--verbose 0|1|2 指定細緻程度
--opt-level/-o 0|1|2|3 指定優化級別
--python-version/-p (uint 32 number) Python 版本
--py-server-timeout (uint 64 number) Python REPL 服務器超時
--dump-as-pyc 轉儲為 .pyc 文件
--mode lex|parse|compile|exec 執行模式 (更多信息見`--mode --help`)
SUBCOMMAND
-c cmd : 作為字串傳入程式
-m mod : 要執行的模塊",
"english" =>
"\
USAGE:
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
ARGS:
<script> program read from script file
Arguments can also be specified to be passed to the <script>
OPTIONS
--help/-?/-h show this help
--version/-V show version
--verbose 0|1|2 verbosity level
--opt-level/-o 0|1|2|3 optimization level
--python-version/-p (uint 32 number) Python version
--py-server-timeout (uint 64 number) timeout for the Python REPL server
--dump-as-pyc dump as .pyc file
--mode lex|parse|compile|exec execution mode (See `--mode --help` for details)
SUBCOMMAND
-c cmd : program passed in as string
-m mod : module to be executed",
)
}
pub fn mode_message<'a>() -> &'a str {
switch_lang!(
"japanese" =>
"\
USAGE:
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
lex
<filename>.erやREPLなどから入力を受け取り、字句を解析
解析結果をTokenStreamとして返す
parse
lexを実行し、TokenStreamを獲得して構文を解析
脱糖しAST(抽象構文木)を返す
lower
parseを実行し、ASTを獲得
名前解決、型検査・型推論をしてHIR(高レベル中間表現)を返す
check
lowerを実行
副作用、所有権を確認しHIRを返す
compile
checkを実行
HIRをからバイトコードを生成し、<filename>.pycを出力する
exec
compileを実行し、更に<filename>.pycを実行
read
<filename>.pycをデシリアライズしコードオブジェクトの情報をダンプ",
"simplified_chinese" =>
"\
USAGE:
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
lex
从 <filename>.er, REPL 等接受输入, 并标记文本
以 TokenStream 形式返回分析结果
parse
执行 lex, 获取 TokenStream, 并解析语法
将多模式定义语句的语法糖按匹配转换并返回 AST(抽象语法树)
lower
执行 parse
解析名称、检查类型和推断, 并返回 HIR(高级中间表示)
check
执行 lower
检查副作用、所有权并返回 HIR
compile
运行 check 以获取检查完成的 AST
编译 AST 并返回 <文件名>.pyc
exec
运行 check 以获取检查完成的 AST
在执行 <文件名>.pyc 后删除 <文件名>.pyc
read
反序列化 <文件名>.pyc 和 dump",
"traditional_chinese" =>
"\
USAGE:
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
lex
從 <檔名>.er, REPL 等接受輸入, 並標記文字
以 TokenStream 形式返回分析結果
parse
執行 lex, 獲取 TokenStream, 並解析語法
將多模式定義語句的語法糖按匹配轉換並返回 AST(抽象語法樹)
lower
執行 parse
解析名稱、檢查類型和推斷, 並返回 HIR(高級中間表示)
check
執行 lower
檢查副作用、所有權並返回 HIR
compile
運行 check 以獲取檢查完成的 AST
編譯 AST 並返回 <檔名>.pyc
exec
運行check以獲取檢查完成的 AST
在執行 <檔名>.pyc 後删除 <檔名>.pyc
read
反序列化 <檔名>.pyc 和 dump",
"english" =>
"\
USAGE:
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
lex
Receive input from <filename>.er, REPL, etc. and lex the text
Returns the analysis results as a TokenStream
parse
Executes lex to get TokenStream, and parses it
Degenerate and return AST (Abstract Syntax Tree)
lower
Execute parse to obtain AST
Performs name resolution, type checking, and type inference, and returns HIR (High-level Intermediate Representation)
check
Execute lower
Checks for side-effects, ownership, and returns HIR
compile
Execute check
Generates bytecode from HIR and outputs <filename>.pyc
exec
Execute compile and then <filename>.pyc
read
Deserialize <filename>.pyc and dump code object information",
)
}