Changed 'message' instruction to 'error_message'

This commit is contained in:
yhirose 2022-09-01 19:59:46 -04:00
parent 8c240f25cf
commit 8e845201a8
4 changed files with 21 additions and 21 deletions

View File

@ -32,7 +32,7 @@ The PEG syntax is well described on page 2 in the [document](http://www.brynosau
* `{ precedence L - + L / * }` (Parsing infix expression)
* `%recovery(` ... `)` (Error recovery operator)
* `exp⇑label` or `exp^label` (Syntax sugar for `(exp / %recover(label))`)
* `label { message "..." }` (Error message instruction)
* `label { error_message "..." }` (Error message instruction)
* `{ no_ast_opt }` (No AST node optimazation instruction)
'End of Input' check will be done as default. In order to disable the check, please call `disable_eoi_check`.
@ -566,8 +566,8 @@ NAME ← < [a-zA-Z_][a-zA-Z_0-9]* >
%word ← NAME
# Recovery operator labels
semia ← '' { message "missing semicolon in assignment." }
stmtb ← (!(Stmt / 'else' / '}') .)* { message "invalid statement" }
semia ← '' { error_message "missing semicolon in assignment." }
stmtb ← (!(Stmt / 'else' / '}') .)* { error_message "invalid statement" }
condw ← &'==' ('==' RelExp)* / &'<' ('<' AddExp)* / (!')' .)*
```

Binary file not shown.

View File

@ -3416,8 +3416,8 @@ private:
g["PrecedenceAssoc"] <= cls("LR");
// Error message instruction
g["ErrorMessage"] <=
seq(lit("message"), g["SpacesOom"], g["LiteralD"], g["SpacesZom"]);
g["ErrorMessage"] <= seq(lit("error_message"), g["SpacesOom"],
g["LiteralD"], g["SpacesZom"]);
// No Ast node optimazation instruction
g["NoAstOpt"] <= seq(lit("no_ast_opt"), g["SpacesZom"]);
@ -3811,7 +3811,7 @@ private:
g["ErrorMessage"] = [](const SemanticValues &vs) {
Instruction instruction;
instruction.type = "message";
instruction.type = "error_message";
instruction.data = std::any_cast<std::string>(vs[0]);
instruction.sv = vs.sv();
return instruction;
@ -4070,7 +4070,7 @@ private:
if (!apply_precedence_instruction(rule, info, s, log)) {
return nullptr;
}
} else if (instruction.type == "message") {
} else if (instruction.type == "error_message") {
rule.error_message = std::any_cast<std::string>(instruction.data);
} else if (instruction.type == "no_ast_opt") {
rule.no_ast_opt = true;

View File

@ -1505,7 +1505,7 @@ TEST(ErrorTest, Default_error_handling_fiblang) {
%whitespace [ \t\r\n]*
%word [a-zA-Z]
col '' { message "missing colon." }
col '' { error_message "missing colon." }
)");
EXPECT_TRUE(!!pg);
@ -1558,8 +1558,8 @@ WORD <- < (![ \t\r\n=|[\]#] .)+ >
comment <- ('#' (!nl .)*)
nl <- '\r'? '\n'
header <- (!__ .)* { message "invalid section header, missing ']'." }
entry <- (!(__ / HEADER) .)+ { message "invalid entry." }
header <- (!__ .)* { error_message "invalid section header, missing ']'." }
entry <- (!(__ / HEADER) .)+ { error_message "invalid entry." }
)");
EXPECT_TRUE(!!pg);
@ -1737,14 +1737,14 @@ comment <- ('#' (!nl .)*)
nl <- '\r'? '\n'
# Recovery
duplicate_or <- skip_puncs { message "Duplicate OR operator (|)" }
missing_or <- '' { message "Missing OR operator (|)" }
missing_bracket <- skip_puncs { message "Missing opening/closing square bracket" }
expect_phrase <- skip { message "Expect phrase" }
invalid_ope_comb <- skip_puncs { message "Use of invalid operator combination" }
invalid_ope <- skip { message "Use of invalid operator" }
wildcard <- '' { message "Wildcard characters (%c) should not be used" }
vernacular_char <- '' { message "Section name %c must be in English" }
duplicate_or <- skip_puncs { error_message "Duplicate OR operator (|)" }
missing_or <- '' { error_message "Missing OR operator (|)" }
missing_bracket <- skip_puncs { error_message "Missing opening/closing square bracket" }
expect_phrase <- skip { error_message "Expect phrase" }
invalid_ope_comb <- skip_puncs { error_message "Use of invalid operator combination" }
invalid_ope <- skip { error_message "Use of invalid operator" }
wildcard <- '' { error_message "Wildcard characters (%c) should not be used" }
vernacular_char <- '' { error_message "Section name %c must be in English" }
skip <- (!(__) .)*
skip_puncs <- [|=]* _
@ -1972,8 +1972,8 @@ PRINTLN ← 'System.out.println'
%word NAME
# Throw operator labels
rcblk SkipToRCUR { message "missing end of block." }
semia '' { message "missing simicolon in assignment." }
rcblk SkipToRCUR { error_message "missing end of block." }
semia '' { error_message "missing simicolon in assignment." }
# Recovery expressions
SkipToRCUR (!RCUR (LCUR SkipToRCUR / .))* RCUR
@ -2058,7 +2058,7 @@ START <- (LINE (ln LINE)*)? ln?
LINE <- STR '=' CODE
CODE <- HEX / DEC { message 'code format error...' }
CODE <- HEX / DEC { error_message 'code format error...' }
HEX <- < [a-f0-9]+ 'h' >
DEC <- < [0-9]+ >