1 /* $NetBSD: calc.y,v 1.1.1.5 2013/04/06 14:45:27 christos Exp $ */
10 extern
int yylex(void);
11 static void yyerror(const char *s
);
23 %left UMINUS
/* supplies precedence for unary minus */
25 %%
/* beginning of rules section */
55 |
'-' expr %prec UMINUS
63 { $$
= $1; base
= ($1==0) ?
8 : 10; }
65 { $$
= base
* $1 + $2; }
68 %%
/* start of programs */
80 yyerror(const char *s
)
82 fprintf
(stderr
, "%s\n", s
);
88 /* lexical analysis routine */
89 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
90 /* return DIGIT for a digit, yylval = 0 through 9 */
91 /* all other characters are returned immediately */
95 while
( (c
=getchar
()) == ' ' ) { /* skip blanks */ }
97 /* c is now nonblank */