ch3-03.y   ch3-03.y 
%{ %{
/* For printf() */
#include <stdio.h>
/* Proformas for functions we define below... */
void yyerror(char *s);
int yylex(void);
/* Specific for here... */
double vbltable[26]; double vbltable[26];
%} %}
%union { %union {
double dval; double dval;
int vblno; int vblno;
} }
%token <vblno> NAME %token <vblno> NAME
%token <dval> NUMBER %token <dval> NUMBER
skipping to change at line 41 skipping to change at line 49
yyerror("divide by zero"); yyerror("divide by zero");
else else
$$ = $1 / $3; $$ = $1 / $3;
} }
| '-' expression %prec UMINUS { $$ = -$2; } | '-' expression %prec UMINUS { $$ = -$2; }
| '(' expression ')' { $$ = $2; } | '(' expression ')' { $$ = $2; }
| NUMBER | NUMBER
| NAME { $$ = vbltable[$1]; } | NAME { $$ = vbltable[$1]; }
; ;
%% %%
/* An optional but friendlier yyerror function... */
void yyerror(char *s)
{
extern int yylineno; // defined and maintained in lex
extern char *yytext; // defined and maintained in lex
fprintf(stderr, "ERROR: %s at symbol '%s' on line %d\n", s, yytext, yylineno);
}
 End of changes. 2 change blocks. 
0 lines changed or deleted 8 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/