1 /* $NetBSD: quote_calc2.y,v 1.1.1.1 2013/04/06 14:45:28 christos Exp $ */
11 static void yyerror(const char *s
);
30 %left UMINUS
/* supplies precedence for unary minus */
32 %%
/* beginning of rules section */
62 |
"SUB" expr %prec UMINUS
70 { $$
= $1; base
= ($1==0) ?
8 : 10; }
72 { $$
= base
* $1 + $2; }
75 %%
/* start of programs */
87 yyerror(const char *s
)
89 fprintf
(stderr
, "%s\n", s
);
94 /* lexical analysis routine */
95 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
96 /* return DIGIT for a digit, yylval = 0 through 9 */
97 /* all other characters are returned immediately */
101 while
( (c
=getchar
()) == ' ' ) { /* skip blanks */ }
103 /* c is now nonblank */