1 %code { /* CODE-DEFAULT2 */ }
2 %code { /* CODE-DEFAULT */ }
3 %code requires { /* CODE-REQUIRES */ }
4 %code provides { /* CODE-PROVIDES */ }
5 %code top { /* CODE-TOP */ }
6 %code provides { /* CODE-PROVIDES2 */ }
15 extern int yylex(void);
16 static void yyerror(const char *s);
28 %left UMINUS /* supplies precedence for unary minus */
30 %% /* beginning of rules section */
60 | '-' 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);
93 /* lexical analysis routine */
94 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
95 /* return DIGIT for a digit, yylval = 0 through 9 */
96 /* all other characters are returned immediately */
100 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
102 /* c is now nonblank */