9 static void yyerror(const char *s);
15 %token OP_ADD "ADD-operator"
16 %token OP_SUB "SUB-operator"
17 %token OP_MUL "MUL-operator"
18 %token OP_DIV "DIV-operator"
19 %token OP_MOD "MOD-operator"
20 %token OP_AND "AND-operator"
28 %left UMINUS /* supplies precedence for unary minus */
30 %% /* beginning of rules section */
60 | OP_SUB expr %prec UMINUS
68 { $$ = $1; base = ($1==0) ? 8 : 10; }
70 { $$ = base * $1 + $2; }
73 %% /* start of programs */
85 yyerror(const char *s)
87 fprintf(stderr, "%s\n", s);
92 /* lexical analysis routine */
93 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
94 /* return DIGIT for a digit, yylval = 0 through 9 */
95 /* all other characters are returned immediately */
99 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
101 /* c is now nonblank */