refactor(parser): modify messages

This commit is contained in:
GreasrySlug 2023-02-10 09:50:24 +09:00 committed by GreasySlug
parent ebd528ec47
commit e5e9da5a7d
2 changed files with 25 additions and 21 deletions

View file

@ -280,7 +280,7 @@ impl LexError {
pub fn invalid_seq_elems_error(errno: usize, loc: Location, hint: Option<&str>) -> LexError {
let hint = hint.map(|hint| hint.to_string());
let msg = switch_lang!(
"japanese" => "連続する要素の宣言が異なりま",
"japanese" => "要素の列挙の仕方が不正で",
"simplified_chinese" => "无效的Sequential元素声明",
"traditional_chinese" => "無效的Sequential元素聲明",
"english" => "invalid sequential elements declaration",
@ -290,7 +290,7 @@ impl LexError {
pub fn invalid_record_element_err(errno: usize, loc: Location) -> LexError {
let msg = switch_lang!(
"japanese" => "レコード型の要素が宣言が異なりま",
"japanese" => "レコード型要素の列挙の仕方が不正で",
"simplified_chinese" => "无效的Record类型元素声明",
"traditional_chinese" => "無效的Record類型元素聲明",
"english" => "invalid record type element declarations",
@ -301,25 +301,29 @@ impl LexError {
let record = StyledStr::new("レコード型", Some(HINT), Some(ATTR));
let var = StyledStr::new("属性", Some(HINT), Some(ATTR));
let def = StyledStr::new("属性=リテラル", Some(HINT), Some(ATTR));
format!("{record}では{var}{def}のみ使うことができます")
let obj = StyledStr::new("属性=オブジェクト", Some(HINT), Some(ATTR));
format!("{record}では{var}{def}{obj}のみ宣言することができます")
},
"simplified_chinese" => {
let record = StyledStr::new("Record类型", Some(HINT), Some(ATTR));
let var = StyledStr::new("attr", Some(HINT), Some(ATTR));
let def = StyledStr::new("attr=lit", Some(HINT), Some(ATTR));
format!("只有{var}{def}可以在{record}中使用")
let obj = StyledStr::new("attr=object", Some(HINT), Some(ATTR));
format!("{record}中只能声明 {var}{def}{obj}")
},
"traditional_chinese" => {
let record = StyledStr::new("Record類型", Some(HINT), Some(ATTR));
let var = StyledStr::new("attr", Some(HINT), Some(ATTR));
let def = StyledStr::new("attr=lit", Some(HINT), Some(ATTR));
format!("只有{var}{def}可以在{record}中使用")
let obj = StyledStr::new("attr=object", Some(HINT), Some(ATTR));
format!("{record}中只能声明 {var}{def}{obj}")
},
"english" => {
let record = StyledStr::new("Record", Some(HINT), Some(ATTR));
let var = StyledStr::new("attr", Some(HINT), Some(ATTR));
let def = StyledStr::new("attr=lit", Some(HINT), Some(ATTR));
format!("only {var} or {def} can be used in {record}")
let obj = StyledStr::new("attr=object", Some(HINT), Some(ATTR));
format!("only {var}, {def} or {obj} can be declared in {record}")
},
);
Self::syntax_error(errno, loc, msg, Some(hint))