GrammarError: Collision when using `lalr`
See original GitHub issueI have a language using the following grammar:
action : STRING ACTION_OPERATOR (ESCAPED_STRING | STRING)
attr : (action | MACRO | conditional)
attrs : (attr ";")* attr ";"? // Colon is only used as separator, and thus optional for final attr
operator : OPERATOR
conditional : STRING "?" STRING ":"
expr : MACRO OPERATOR attrs
line : expr COMMENT?
file : line+
comment : COMMENT
MACRO : STRING
COMMENT : /#.*$/m
STRING : /[a-zA-Z0-9_.-]+/
OPERATOR : ":" | "+:"
ACTION_OPERATOR : "===" | "==" | "+=" | "-=" | "="
%import common.WS
%import common.NEWLINE
%import common.ESCAPED_STRING
%ignore WS
%ignore COMMENT
%ignore NEWLINE
Parsing my files works fine with earley
, however, it is quite slow: 18 seconds versus 1.5 seconds for my implementation in pyparsing
, although the latter may still be incomplete. Parsing with lalr
gives
GrammarError: Collision in MACRO: [('reduce', <attrs : attr __SEMICOLON>), ('reduce', <__anon_star_0 : attr __SEMICOLON>)]
Could you explain what the reason is for this?
Possibly related issue #10
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:22 (11 by maintainers)
Top Results From Across the Web
Unambiguous gramar for let e1 in e2
I think the problem is start : expr expr : ... | exprcont exprcont : ... | expr. This loop means that your...
Read more >lark-parser/Lobby - Gitter
I am using lalr @erezsh ... But I have a GrammarError: Collision in Terminal ... @PavelICS It's the right idea, but for LALR...
Read more >Grammar Reference - Lark documentation - Read the Docs
Grammars in Lark are based on EBNF syntax, with several enhancements. ... When using LALR, the highest priority rules are used to resolve...
Read more >Symbols instead of strings - gitmirror - Gitea: Git with a cup of tea
from .parser_frontends import LALR. from .parsers.lalr_parser import UnexpectedToken. from .common import is_terminal, GrammarError, LexerConf, ParserConf, ...
Read more >Deadly collision under investigation on Two Notch Rd, ...
8, a Nissan Armada collided with a pedestrian on Two Notch Rd at the intersection of ... Notice a spelling or grammar error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I indeed forgot to denote it as a raw string. The earley parser is slightly faster now. Hopefully I find more time to work on the lalr solution. Thanks for your help!
Oh nevermind, just as I posted it I saw the issue:
will solve it.