1 /* $NetBSD: pure_calc.y,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
12 #define YYLEX_PARAM &yylval
13 #define YYLEX_DECL() yylex(YYSTYPE *yylval)
14 #define YYERROR_DECL() yyerror(const char *s)
16 static void YYERROR_DECL
();
29 %left UMINUS
/* supplies precedence for unary minus */
31 %%
/* beginning of rules section */
61 |
'-' expr %prec UMINUS
69 { $$
= $1; base
= ($1==0) ?
8 : 10; }
71 { $$
= base
* $1 + $2; }
74 %%
/* start of programs */
77 static int YYLEX_DECL
();
92 fprintf
(stderr
, "%s\n", s
);
98 /* lexical analysis routine */
99 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
100 /* return DIGIT for a digit, yylval = 0 through 9 */
101 /* all other characters are returned immediately */
105 while
( (c
=getchar
()) == ' ' ) { /* skip blanks */ }
107 /* c is now nonblank */