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::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::{power_assert, read_file};
@ -211,7 +211,7 @@ impl ErgConfig {
}
"-?" | "-h" | "--help" => {
// TODO:
println!("{}", CMD_HELP);
println!("{}", command_message());
process::exit(0);
}
"-m" if next_arg.is_some() => {
@ -220,7 +220,7 @@ impl ErgConfig {
"--mode" if next_arg.is_some() => {
let mode = next_arg.unwrap();
if let "-?" | "-h" | "--help" = &mode[..] {
println!("{}", MODE_HELP);
println!("{}", mode_message());
process::exit(0);
}
cfg.mode = Box::leak(mode.into_boxed_str());

View file

@ -1,29 +1,10 @@
use crate::switch_lang;
/// erg -h/--help/-?
#[cfg(not(feature = "japanese"))]
pub const CMD_HELP: &str = "\
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
SUBCOMMAND
-c cmd : program passed in as string
-m mod : module to be executed";
#[cfg(feature = "japanese")]
pub const CMD_HELP: &str = "\
pub fn command_message<'a>() -> &'a str {
switch_lang!(
"japanese" =>
"\
USAGE:
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
@ -34,19 +15,65 @@ ARGS:
OPTIONS
--help/-?/-h helpを表示
--version/-V
--verbose 0|1|2
--opt-level/-o 0|1|2|3
--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サーバーのタイムアト時間を指定
--py-server-timeout (uint 64 number) PythonのREPLサーバーのタイムアト時間を指定
--dump-as-pyc .pycファイルにダンプ
--mode lex|parse|compile|exec
--mode lex|parse|compile|exec
SUBCOMMAND
-c cmd :
-m mod : ";
-c cmd :
-m mod : ",
#[cfg(feature = "simplified_chinese")]
pub const CMD_HELP: &str = "\
"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
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:
erg [OPTIONS] [SUBCOMMAND] [ARGS]...
@ -66,159 +93,138 @@ OPTIONS
SUBCOMMAND
-c cmd : program passed in as string
-m mod : module to be executed";
-m mod : module to be executed",
)
}
#[cfg(feature = "traditional_chinese")]
pub const CMD_HELP: &str = "\
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
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 = "\
pub fn mode_message<'a>() -> &'a str {
switch_lang!(
"japanese" =>
"\
USAGE:
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
lex
Takes input from a .er file or REPL strings, and lexes them into erg tokens
The lexed string becomes an iterator as TokenStream
<filename>.erやREPLなどから入力を受け取り
TokenStreamとして返す
parse
Exec lex and get TokenStream
Iterate TokenStream and confirm that it fits the erg grammar
TokenStream is reduced to Module
lexを実行しTokenStreamを獲得して構文を解析
matchで変換しast()
lower
Exec parse and get module
Module is converted ast(abstract syntax tree)
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()
parseを実行しastを獲得
astを返す
check
lowerを実行しastを獲得
astの借用チェック
astを返す
compile
checkを実行し借用チェックされたastを獲得
astをo.pycにコンパイル
checkを実行しチェックされたastを獲得
astをコンパイルし<filename>.pycを返す
exec
compileを実行しo.pycを獲得
o.pycを実行
checkを実行しチェックされたastを獲得
<filename>.pycを実行後<filename>.pycを削除
read
o.pycを読み取りergのastに変換";
<filename>.pycをデシリアライズしダンプ",
#[cfg(feature = "simplified_chinese")]
pub const MODE_HELP: &str = "\
"simplified_chinese" =>
"\
USAGE:
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
lex
TODO
TODO
Receive input from <filename>.er, REPL, etc., and tokenize the text
Returns analysis results as TokenStream
parse
TODO
TODO
TODO
Execute lex, get TokenStream, and parse the syntax
Desugar multiple pattern definition sentences, convert by match and return ast (abstract syntax tree)
lower
TODO
TODO
Execute parse to get ast
Resolve name, check type and infer, and return ast
check
TODO
TODO
Execute lower and get ast
Check side-effects, ownership and return ast
compile
TODO
TODO
Run check to get checked ast
Compile ast and return <filename>.pyc
exec
TODO
TODO
Execute check to get checked ast
Delete <filename>.pyc after executing <filename>.pyc
read
TODO";
Deserialize <filename>.pyc and dump",
#[cfg(feature = "traditional_chinese")]
pub const MODE_HELP: &str = "\
"traditional_chinese" =>
"\
USAGE:
erg --mode [lex | parse | lower | check | compile | exec | read] [SUBCOMMAND] [ARGS]...
lex
TODO
TODO
<filename>.erREPL
TokenStream
parse
TODO
TODO
TODO
lexTokenStream
ast
lower
TODO
TODO
parse ast
ast
check
TODO
TODO
lower并get ast
compile
TODO
TODO
ast
ast <filename>.pyc
exec
TODO
TODO
ast
<filename>.pyc <filename>.pyc
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 ",
)
}