-
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
33 changed files
with
1,047 additions
and
194 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
## Trc is a stack-based programming language | ||
|
||
Trc's syntax is easy,and have full toolchain.It is easy to learn modern c++ and compiler,too. | ||
Trc's syntax is easy,and have full toolchain. It is easy to learn modern c++ and compiler,too. | ||
|
||
## language | ||
|
||
|
@@ -81,6 +81,8 @@ Wechat:angelgel2020 | |
|
||
QQ:3570249647 | ||
|
||
email: ```[email protected]``` | ||
|
||
## Referenced Open-source software | ||
|
||
| Library |Usage | | ||
|
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,24 @@ | ||
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 "VmError" | ||
msgstr "虚拟机错误" | ||
|
||
msgid "this string should be ended with {}" | ||
msgstr "这个字符串应当以{}结束" | ||
|
||
msgid "operator {} is not supported for type {}" | ||
msgstr "操作符{}不支持类型{}" | ||
|
||
msgid "The number of data of vm stack is not correct, should have {} data" | ||
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,42 @@ | ||
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 VM_ERROR:&str = "VmError"; | ||
|
||
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 const VM_DATA_NUMBER:&str = "The number of data of vm stack is not correct, should have {} data"; | ||
|
||
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; | ||
} | ||
|
||
/// report error in vm or compiler | ||
/// we will translate the error type to gettextrs | ||
/// but you should translate the error messgae by caller | ||
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.