Skip to content

Instantly share code, notes, and snippets.

@hakobe
Last active Aug 29, 2015
Embed
What would you like to do?
%lex
%%
\s+ /* skip whitespace */
"fun" return 'FUN'
[0-9]+ return 'INT'
"=>" return '=>'
<<EOF>> return 'EOF'
. return 'INVALID'
/lex
%nonassoc FUNEXP
%left APPLY
%start expressions
%%
expressions
: e EOF
{ return $1; }
;
e
: e e %prec APPLY
{$$ = ['APPLY', $1, $2];}
| FUN var '=>' e %prec FUNEXP
{$$ = ['FUN', $2, $4];}
;
Conflict in grammar: multiple actions possible when lookahead token is FUN in state 5
- reduce by rule: e -> e e
- shift token (then go to state 3)
Conflict in grammar: multiple actions possible when lookahead token is FUN in state 8
- reduce by rule: e -> FUN var => e
- shift token (then go to state 3)
States with conflicts:
State 5
e -> e e . #lookaheads= EOF FUN
e -> e .e
e -> .e e
e -> .FUN var => e
State 8
e -> FUN var => e . #lookaheads= EOF FUN
e -> e .e
e -> .e e
e -> .FUN var => e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment