mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 05:54:33 +00:00
Update: translate ja into ch, en
This commit is contained in:
parent
081c88c0df
commit
22b65c6d34
2 changed files with 146 additions and 140 deletions
|
@ -8,7 +8,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::help_messages::{CMD_HELP, MODE_HELP};
|
use crate::help_messages::{command_message, mode_message};
|
||||||
use crate::stdin::GLOBAL_STDIN;
|
use crate::stdin::GLOBAL_STDIN;
|
||||||
use crate::{power_assert, read_file};
|
use crate::{power_assert, read_file};
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ impl ErgConfig {
|
||||||
}
|
}
|
||||||
"-?" | "-h" | "--help" => {
|
"-?" | "-h" | "--help" => {
|
||||||
// TODO:
|
// TODO:
|
||||||
println!("{}", CMD_HELP);
|
println!("{}", command_message());
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
"-m" if next_arg.is_some() => {
|
"-m" if next_arg.is_some() => {
|
||||||
|
@ -220,7 +220,7 @@ impl ErgConfig {
|
||||||
"--mode" if next_arg.is_some() => {
|
"--mode" if next_arg.is_some() => {
|
||||||
let mode = next_arg.unwrap();
|
let mode = next_arg.unwrap();
|
||||||
if let "-?" | "-h" | "--help" = &mode[..] {
|
if let "-?" | "-h" | "--help" = &mode[..] {
|
||||||
println!("{}", MODE_HELP);
|
println!("{}", mode_message());
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
cfg.mode = Box::leak(mode.into_boxed_str());
|
cfg.mode = Box::leak(mode.into_boxed_str());
|
||||||
|
|
|
@ -1,29 +1,10 @@
|
||||||
|
use crate::switch_lang;
|
||||||
|
|
||||||
/// erg -h/--help/-?
|
/// erg -h/--help/-?
|
||||||
#[cfg(not(feature = "japanese"))]
|
pub fn command_message<'a>() -> &'a str {
|
||||||
pub const CMD_HELP: &str = "\
|
switch_lang!(
|
||||||
USAGE:
|
"japanese" =>
|
||||||
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
|
|
||||||
|
|
||||||
SUBCOMMAND
|
|
||||||
-c cmd : program passed in as string
|
|
||||||
-m mod : module to be executed";
|
|
||||||
|
|
||||||
#[cfg(feature = "japanese")]
|
|
||||||
pub const CMD_HELP: &str = "\
|
|
||||||
USAGE:
|
USAGE:
|
||||||
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
|
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
|
||||||
|
|
||||||
|
@ -34,19 +15,65 @@ ARGS:
|
||||||
OPTIONS
|
OPTIONS
|
||||||
--help/-?/-h このhelpを表示
|
--help/-?/-h このhelpを表示
|
||||||
--version/-V バージョンを表示
|
--version/-V バージョンを表示
|
||||||
--verbose 0|1|2 冗長化レベル
|
--verbose 0|1|2 冗長性レベルを指定
|
||||||
--opt-level/-o 0|1|2|3 最適化レベル
|
--opt-level/-o 0|1|2|3 最適化レベルを指定
|
||||||
--python-version/-p (uint 32 number) Pythonバージョンを指定
|
--python-version/-p (uint 32 number) Pythonバージョンを指定
|
||||||
--py-server-timeout (uint 64 number) PythonのREPLサーバーのタイムアプト時間を指定
|
--py-server-timeout (uint 64 number) PythonのREPLサーバーのタイムアウト時間を指定
|
||||||
--dump-as-pyc .pycファイルにダンプ
|
--dump-as-pyc .pycファイルにダンプ
|
||||||
--mode lex|parse|compile|exec モードで実行
|
--mode lex|parse|compile|exec 指定モードで実行
|
||||||
|
|
||||||
SUBCOMMAND
|
SUBCOMMAND
|
||||||
-c cmd : 文字列をプログラムに渡す
|
-c cmd : 文字列をプログラムに譲渡
|
||||||
-m mod : モジュールを実行させる";
|
-m mod : モジュールを実行",
|
||||||
|
|
||||||
#[cfg(feature = "simplified_chinese")]
|
"simplified_chinese" =>
|
||||||
pub const CMD_HELP: &str = "\
|
"\
|
||||||
|
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 执行模式
|
||||||
|
|
||||||
|
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 執行模式
|
||||||
|
|
||||||
|
SUBCOMMAND
|
||||||
|
-c cmd : 作為字符串傳入的程序
|
||||||
|
-m mod : 要執行的模塊",
|
||||||
|
|
||||||
|
"english" =>
|
||||||
|
"\
|
||||||
USAGE:
|
USAGE:
|
||||||
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
|
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
|
||||||
|
|
||||||
|
@ -66,159 +93,138 @@ OPTIONS
|
||||||
|
|
||||||
SUBCOMMAND
|
SUBCOMMAND
|
||||||
-c cmd : program passed in as string
|
-c cmd : program passed in as string
|
||||||
-m mod : module to be executed";
|
-m mod : module to be executed",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "traditional_chinese")]
|
pub fn mode_message<'a>() -> &'a str {
|
||||||
pub const CMD_HELP: &str = "\
|
switch_lang!(
|
||||||
USAGE:
|
"japanese" =>
|
||||||
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
|
|
||||||
|
|
||||||
SUBCOMMAND
|
|
||||||
-c cmd : program passed in as string
|
|
||||||
-m mod : module to be executed";
|
|
||||||
|
|
||||||
/// erg --mode -h/--help/-?
|
|
||||||
#[cfg(not(feature = "japanese"))]
|
|
||||||
pub const MODE_HELP: &str = "\
|
|
||||||
USAGE:
|
USAGE:
|
||||||
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
||||||
|
|
||||||
lex
|
lex
|
||||||
Takes input from a .er file or REPL strings, and lexes them into erg tokens
|
<filename>.erやREPLなどから入力を受け取り、字句を解析
|
||||||
The lexed string becomes an iterator as TokenStream
|
解析結果をTokenStreamとして返す
|
||||||
|
|
||||||
parse
|
parse
|
||||||
Exec lex and get TokenStream
|
lexを実行し、TokenStreamを獲得して構文を解析
|
||||||
Iterate TokenStream and confirm that it fits the erg grammar
|
脱糖衣し複数パターン定義文をmatchで変換しast(抽象構文木)を返す
|
||||||
TokenStream is reduced to Module
|
|
||||||
|
|
||||||
lower
|
lower
|
||||||
Exec parse and get module
|
parseを実行し、astを獲得
|
||||||
Module is converted ast(abstract syntax tree)
|
名前解決、型チェックと推論しastを返す
|
||||||
|
|
||||||
check
|
|
||||||
Exec lower and get module
|
|
||||||
Borrow checks at ast
|
|
||||||
|
|
||||||
compile
|
|
||||||
Exec check and get ast
|
|
||||||
Compile ast to o.pyc file
|
|
||||||
|
|
||||||
exec
|
|
||||||
exec the compiled o.pyc
|
|
||||||
|
|
||||||
read
|
|
||||||
read the .pyc, and out put to .er file";
|
|
||||||
|
|
||||||
#[cfg(feature = "japanese")]
|
|
||||||
pub const MODE_HELP: &str = "\
|
|
||||||
USAGE:
|
|
||||||
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
|
||||||
|
|
||||||
lex
|
|
||||||
.erファイルやREPLなどから入力を受け取り、それを字句解析
|
|
||||||
字句解析された文字列のtokenをTokenStreamとして収集
|
|
||||||
|
|
||||||
parse
|
|
||||||
lexを実行し、TokenStreamを獲得
|
|
||||||
TokenStreamをイテレートし、ergの構文解析
|
|
||||||
TokenStreamをmoduleに還元
|
|
||||||
|
|
||||||
lower
|
|
||||||
parseを実行し、moduleを獲得
|
|
||||||
moduleをast(抽象構文木)に変換
|
|
||||||
|
|
||||||
check
|
check
|
||||||
lowerを実行しastを獲得
|
lowerを実行しastを獲得
|
||||||
astの借用チェック
|
副作用、所有権を確認しastを返す
|
||||||
|
|
||||||
compile
|
compile
|
||||||
checkを実行し借用チェックされたastを獲得
|
checkを実行しチェックされたastを獲得
|
||||||
astをo.pycにコンパイル
|
astをコンパイルし、<filename>.pycを返す
|
||||||
|
|
||||||
exec
|
exec
|
||||||
compileを実行し、o.pycを獲得
|
checkを実行しチェックされたastを獲得
|
||||||
o.pycを実行
|
<filename>.pycを実行後、<filename>.pycを削除
|
||||||
|
|
||||||
read
|
read
|
||||||
o.pycを読み取り、ergのastに変換";
|
<filename>.pycをデシリアライズしダンプ",
|
||||||
|
|
||||||
#[cfg(feature = "simplified_chinese")]
|
"simplified_chinese" =>
|
||||||
pub const MODE_HELP: &str = "\
|
"\
|
||||||
USAGE:
|
USAGE:
|
||||||
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
||||||
|
|
||||||
lex
|
lex
|
||||||
TODO
|
Receive input from <filename>.er, REPL, etc., and tokenize the text
|
||||||
TODO
|
Returns analysis results as TokenStream
|
||||||
|
|
||||||
parse
|
parse
|
||||||
TODO
|
Execute lex, get TokenStream, and parse the syntax
|
||||||
TODO
|
Desugar multiple pattern definition sentences, convert by match and return ast (abstract syntax tree)
|
||||||
TODO
|
|
||||||
|
|
||||||
lower
|
lower
|
||||||
TODO
|
Execute parse to get ast
|
||||||
TODO
|
Resolve name, check type and infer, and return ast
|
||||||
|
|
||||||
check
|
check
|
||||||
TODO
|
Execute lower and get ast
|
||||||
TODO
|
Check side-effects, ownership and return ast
|
||||||
|
|
||||||
compile
|
compile
|
||||||
TODO
|
Run check to get checked ast
|
||||||
TODO
|
Compile ast and return <filename>.pyc
|
||||||
|
|
||||||
exec
|
exec
|
||||||
TODO
|
Execute check to get checked ast
|
||||||
TODO
|
Delete <filename>.pyc after executing <filename>.pyc
|
||||||
|
|
||||||
read
|
read
|
||||||
TODO";
|
Deserialize <filename>.pyc and dump",
|
||||||
|
|
||||||
#[cfg(feature = "traditional_chinese")]
|
"traditional_chinese" =>
|
||||||
pub const MODE_HELP: &str = "\
|
"\
|
||||||
USAGE:
|
USAGE:
|
||||||
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
||||||
|
|
||||||
lex
|
lex
|
||||||
TODO
|
从 <filename>.er、REPL 等接收输入,并标记文本
|
||||||
TODO
|
以 TokenStream 形式返回分析结果
|
||||||
|
|
||||||
parse
|
parse
|
||||||
TODO
|
执行lex,获取TokenStream,解析语法
|
||||||
TODO
|
对多个模式定义语句进行脱糖,通过匹配转换并返回 ast(抽象语法树)
|
||||||
TODO
|
|
||||||
|
|
||||||
lower
|
lower
|
||||||
TODO
|
执行 parse 得到 ast
|
||||||
TODO
|
解析名称,检查类型和推断,并返回 ast
|
||||||
|
|
||||||
check
|
check
|
||||||
TODO
|
执行lower并get ast
|
||||||
TODO
|
检查副作用、所有权和回报
|
||||||
|
|
||||||
compile
|
compile
|
||||||
TODO
|
運行檢查以檢查 ast
|
||||||
TODO
|
編譯 ast 並返回 <filename>.pyc
|
||||||
|
|
||||||
exec
|
exec
|
||||||
TODO
|
执行检查以检查 ast
|
||||||
TODO
|
执行 <filename>.pyc 后删除 <filename>.pyc
|
||||||
|
|
||||||
read
|
read
|
||||||
TODO";
|
反序列化 <filename>.pyc 并转储",
|
||||||
|
|
||||||
|
"english" =>
|
||||||
|
"\
|
||||||
|
USAGE:
|
||||||
|
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
|
||||||
|
|
||||||
|
lex
|
||||||
|
從 <filename>.er、REPL 等接收輸入,並標記文本
|
||||||
|
以 TokenStream 形式返回分析結果
|
||||||
|
|
||||||
|
parse
|
||||||
|
執行lex,獲取TokenStream,解析語法
|
||||||
|
對多個模式定義語句進行脫糖,通過匹配轉換並返回 ast(抽象語法樹)
|
||||||
|
|
||||||
|
lower
|
||||||
|
執行 parse 得到 ast
|
||||||
|
解析名稱,檢查類型和推斷,並返回 ast
|
||||||
|
|
||||||
|
check
|
||||||
|
執行lower並get ast
|
||||||
|
檢查副作用、所有權和回報
|
||||||
|
|
||||||
|
compile
|
||||||
|
运行检查以检查 ast
|
||||||
|
编译 ast 并返回 <filename>.pyc
|
||||||
|
|
||||||
|
exec
|
||||||
|
執行檢查以檢查 ast
|
||||||
|
執行 <filename>.pyc 後刪除 <filename>.pyc
|
||||||
|
|
||||||
|
read
|
||||||
|
反序列化 <filename>.pyc 並轉儲",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue