-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
783 additions
and
182 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
msgid "test" | ||
msgstr "草" | ||
msgid "" | ||
msgstr "" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
|
||
msgid "Welcome to tshell.Type help() to get more infomation" | ||
msgstr "欢迎使用tshell。输入help()获取更多信息" | ||
|
||
msgid "SyntaxError" | ||
msgstr "语法错误" | ||
|
||
msgid "OperatorError" | ||
msgstr "操作符错误" | ||
|
||
msgid "this string should be ended with {}" | ||
msgstr "这个字符串应当以{}结束" | ||
|
||
msgid "operator {} is not supported for type {}" | ||
msgstr "操作符{}不支持类型{}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
enum ErrorType { | ||
SyntaxError, | ||
} | ||
use gettextrs::gettext; | ||
use std::process::exit; | ||
|
||
const EXIT_FAILURE: i32 = 1; | ||
|
||
pub const SYNTAX_ERROR: &str = "SyntaxError"; | ||
pub const OPERATOR_ERROR: &str = "OperatorError"; | ||
pub const STRING_WITHOUT_END: &str = "this string should be ended with {}"; | ||
pub const OPERATOR_IS_NOT_SUPPORT: &str = "operator {} is not supported for type {}"; | ||
|
||
pub struct ErrorInfo { | ||
pub message: String, | ||
errot_type: ErrorType, | ||
errot_type: &'static str, | ||
} | ||
|
||
impl ErrorInfo { | ||
pub fn new(message: String) -> ErrorInfo { | ||
pub fn new(message: String, error_type: &'static str) -> ErrorInfo { | ||
ErrorInfo { | ||
message, | ||
errot_type: ErrorType::SyntaxError, | ||
errot_type: error_type, | ||
} | ||
} | ||
} | ||
|
||
pub trait ErrorContent { | ||
fn get_module_name(&self) -> &str; | ||
|
||
fn get_line(&self) -> usize; | ||
} | ||
|
||
pub fn report_error(content: &impl ErrorContent, info: ErrorInfo) { | ||
eprintln!("Error in line {}", content.get_line()); | ||
eprintln!("In module {}", content.get_module_name()); | ||
eprintln!("{}:{}", gettext(info.errot_type), info.message); | ||
exit(EXIT_FAILURE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! some constant values and configurations in trc | ||
pub const MAIN_MODULE_NAME: &str = "main"; |
Oops, something went wrong.