1 %code top { /* CODE-TOP */ }
2 %code top { /* CODE-TOP2 */ }
11 extern int yylex(void);
12 static void yyerror(const char *s);
24 %left UMINUS /* supplies precedence for unary minus */
26 %% /* beginning of rules section */
56 | '-' expr %prec UMINUS
64 { $$ = $1; base = ($1==0) ? 8 : 10; }
66 { $$ = base * $1 + $2; }
69 %% /* start of programs */
81 yyerror(const char *s)
83 fprintf(stderr, "%s\n", s);
89 /* lexical analysis routine */
90 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
91 /* return DIGIT for a digit, yylval = 0 through 9 */
92 /* all other characters are returned immediately */
96 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
98 /* c is now nonblank */