1 /* $NetBSD: quote_calc3.y,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
11 static void yyerror(const char *s
);
17 %token OP_ADD
"ADD-operator"
18 %token OP_SUB
"SUB-operator"
19 %token OP_MUL
"MUL-operator"
20 %token OP_DIV
"DIV-operator"
21 %token OP_MOD
"MOD-operator"
22 %token OP_AND
"AND-operator"
30 %left UMINUS
/* supplies precedence for unary minus */
32 %%
/* beginning of rules section */
62 | OP_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 */