diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-06-12 00:40:28 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-06-12 09:44:00 +0900 |
commit | 2dd098d1e16bd0b8786ca97ccc7d3b06fa6bc3d1 (patch) | |
tree | 2e5a9ffa712ffe553d5ecafb35e27a7a3cd1fa11 /driver/parser_test.go | |
parent | Support the underscore symbol matching any symbols in vartan-test command (diff) | |
download | urubu-2dd098d1e16bd0b8786ca97ccc7d3b06fa6bc3d1.tar.gz urubu-2dd098d1e16bd0b8786ca97ccc7d3b06fa6bc3d1.tar.xz |
Prohibit using a pattern in an alternative
When a syntax error occurs, the parser must provide a user with the names of expected tokens.
However, if a pattern appears directly in an alternative, Vartan cannot assign an appropriate name to the pattern.
Therefore, this commit prohibits alternatives from containing patterns.
Diffstat (limited to 'driver/parser_test.go')
-rw-r--r-- | driver/parser_test.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/driver/parser_test.go b/driver/parser_test.go index 9e232f7..215988d 100644 --- a/driver/parser_test.go +++ b/driver/parser_test.go @@ -50,18 +50,20 @@ func TestParser_Parse(t *testing.T) { #name test; expr - : expr "\+" term + : expr '+' term | term ; term - : term "\*" factor + : term '*' factor | factor ; factor - : "\(" expr "\)" + : '(' expr ')' | id ; -id: "[A-Za-z_][0-9A-Za-z_]*"; + +id + : "[A-Za-z_][0-9A-Za-z_]*"; `, src: `(a+(b+c))*d+e`, cst: nonTermNode("expr", @@ -404,10 +406,10 @@ fragment words: "[A-Za-z\u{0020}]+"; #name test; list - : "\[" elems "]" #ast elems... + : '[' elems ']' #ast elems... ; elems - : elems "," id #ast elems... id + : elems ',' id #ast elems... id | id ; |