11 extern
int yyerror(char *);
16 //#define YYERROR_VERBOSE 1
22 %token TOKEN_IDENTIFIER TOKEN_DOT TOKEN_STAR TOKEN_ARROW TOKEN_ADDR
23 %token TOKEN_SIZEOF TOKEN_NUMBER
24 %left TOKEN_DOT TOKEN_ARROW
'['
28 final: expression
{ result
= $1; }
32 simple_expression
{ $$
= $1; } |
33 '(' expression
')' { $$
= $2; } |
34 expression TOKEN_DOT ident
{ $$
= exprNodeDot
($1, $3); } |
35 expression TOKEN_ARROW ident
{ $$
= exprNodeArrow
($1, $3); } |
36 expression
'[' number
']' { $$
= exprNodeArray
($1, $3); }
40 TOKEN_STAR expression
{ $$
= exprNodeStar
($2); } |
41 TOKEN_ADDR expression
{ $$
= exprNodeAddr
($2); } |
42 TOKEN_SIZEOF
'(' expression
')' { $$
= exprNodeSizeof
($3); }
46 TOKEN_NUMBER
{ $$
= exprNodeNumber
(); }
50 TOKEN_IDENTIFIER
{$$
= exprNodeIdentifier
(); }
62 int main
(int argc
, char **argv
)
67 yyin
= fopen
(argv
[0], "r");
71 result
->print
(result
);