Reputation: 73
I am using byacc to construct a grammar, but when i want to use yyerrok it says to me byacc: e - line 44 of "bee.y", $$ is untyped
definition:
| error ';' {$$ = 0; yyerrok; }
| definition ID defFirst ';'
| definition ID '(' defSecond ')' stmt
;
how do i solve the problem?
Upvotes: 2
Views: 2236
Reputation: 5893
(Comments converted to an answer)
@Grzes wrote:
You get this message not because of yyerrok usage. The reason is
$$ = 0;
, i.e. you do not assign a type to the non-terminaldefinition
(as @templatetypedef has said). With each production you can associate an action. Each action may return some semantic value which can be used in "higher" production. Moreover you can (or should) specify type of semantic value for each non-terminal and terminal. Take a look at bison doc: www.gnu.org/software/bison/manual/bison.html , especially pay attention to semantic value and semantic action.
Upvotes: 2