lark
lark copied to clipboard
Ignored terminal used in the grammar is expected with Earley but not with LALR
trafficstars
Describe the bug
When a terminal is ignored but still used in the grammar, the behavior is different depending on the parser used. With LALR, the terminal is ignored, with Earley it is expected.
According to the doc, the behavior of LALR seems to be the expected one, but the Earley behavior still makes sense.
To Reproduce
grammar = """
start : "CREATE" WS "START"
%import common.WS
%ignore WS
"""
lalr_parser = Lark(grammar, parser="lalr")
lalr_parser.parse("CREATE START") # Fails
lalr_parser.parse("CREATESTART") # Fails
earley_parser = Lark(grammar, parser="earley")
earley_parser.parse("CREATE START") # Succeeds
earley_parser.parse("CREATESTART") # Fails
Environment
Version 1.2.2