Update: translate ja into ch, en

This commit is contained in:
GreasySlug 2022-10-01 15:48:29 +09:00
parent 081c88c0df
commit 22b65c6d34
2 changed files with 146 additions and 140 deletions

View file

@ -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());

View file

@ -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>.erREPL
TODO TokenStream
parse parse
TODO lexTokenStream
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>.erREPL
TokenStream
parse
lexTokenStream
ast
lower
parse ast
ast
check
lower並get ast
compile
ast
ast <filename>.pyc
exec
ast
<filename>.pyc <filename>.pyc
read
<filename>.pyc ",
)
}