Browse Source

Fix for shift/reduce conflict on END

remotes/origin/gm/2021-09-23T00Z/github.com--lark-parser-lark/end_symbol_2021
Erez Sh 4 years ago
parent
commit
dbc5ad59cb
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      lark/parsers/lalr_analysis.py

+ 2
- 1
lark/parsers/lalr_analysis.py View File

@@ -261,11 +261,12 @@ class LALR_Analyzer(GrammarAnalyzer):
rules = [best[1]]
else:
reduce_reduce.append((state, la, rules))
if la in actions:
if la in actions and la.name != END:
if self.debug:
logger.warning('Shift/Reduce conflict for terminal %s: (resolving as shift)', la.name)
logger.warning(' * %s', list(rules)[0])
else:
# No shift found for la, or it's End Of Input, in which case Reduce should come before Shift.
actions[la] = (Reduce, list(rules)[0])
m[state] = { k.name: v for k, v in actions.items() }



Loading…
Cancel
Save