LEX & YACC
LEX & YACC
LEX & YACC
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Constants, variables, and nodes can be represented by yylval in the parser’s value stack. Noticethe type definitions%token INTEGER%type exprThis binds expr to nPtr, and INTEGER to iValue in the YYSTYPE union. This is required so thatyacc can generate the correct code. For example, the ruleexpr: INTEGER { $$ = con($1); }should generate the following code. Note that yyvsp[0] addresses the top of the value stack, orthe value associated with INTEGER.yylval.nPtr = con(yyvsp[0].iValue);The unary minus operator is given higher priority than binary operators as follows:%left GE LE EQ NE '>' '