goccmack / gocc

Parser / Scanner Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EOF $ representation introducing LR-1 conflicts

skius opened this issue · comments

There are LR-1 grammars for which gocc introduces unnecessary LR-1 conflicts, because it treats the symbol '$' and actual EOFs as the same token.

No conflicts:

S
  : empty << nil, nil >>
  | "%" "x" << nil, nil >>
  ;

Shift/Reduce conflict; it's unable to decide between reducing due to EOF or shifting due to $

S
  : empty << nil, nil >>
  | "$" "x" << nil, nil >>
  ;

I wasn't quite able to figure out where in gocc's source this is defined, but I suggest replacing this by either an actual EOF byte (if that's possible), or a custom abstract token that's defined to be different to all other tokens.