%{ %} /* Tokens and types */ %token INT %token IDENT %token EOF ADD SUB MUL NOT EQUAL LPAREN RPAREN BANG /* add precedence directives */ %left ADD SUB /* lowest precedence */ %left MUL %nonassoc NOT /* higher precedence */ %start start %type expr %type start %% /* add unary BANG to the grammar */ start: | expr EOF { $1 } expr: | IDENT { () } | INT { () } | NOT expr { () } | BANG expr { () } | expr ADD expr { () } | expr SUB expr { () } | expr MUL expr { () } | LPAREN expr RPAREN { () } | simple_expr simple_expr { () } simple_expr: | IDENT { () } | INT { () } | LPAREN expr RPAREN { () }