67 |
|
|
68 |
%} |
%} |
69 |
|
|
70 |
/* Exercise M4 quoting: '@:>@@:>@', 0. */ |
/* Exercise %union. */ |
|
|
|
|
/* Also exercise %union. */ |
|
71 |
%union |
%union |
72 |
{ |
{ |
73 |
value_t ival; /* A comment to exercise an old bug. */ |
value_t ival; |
74 |
}; |
}; |
75 |
|
|
|
/* Exercise post-prologue dependency to %union. */ |
|
|
%{ |
|
|
static void id (YYSTYPE *lval); |
|
|
|
|
|
/* Exercise quotes in declarations. */ |
|
|
char quote[] = "@:>@@:>@,"; |
|
|
%} |
|
|
|
|
76 |
/* Bison Declarations */ |
/* Bison Declarations */ |
77 |
%token CALC_EOF 0 "end of file" |
%token CALC_EOF 0 "end of file" |
78 |
%token <ival> NUM "number" |
%token <ival> NUM "number" |
79 |
%type <ival> exp |
%type <ival> exp |
80 |
|
|
|
/* Exercise quotes in strings. */ |
|
|
%token FAKE "fake @>:@@>:@," |
|
|
|
|
81 |
%nonassoc '=' /* comparison */ |
%nonassoc '=' /* comparison */ |
82 |
%left '-' '+' |
%left '-' '+' |
83 |
%left '*' '/' |
%left '*' '/' |
94 |
; |
; |
95 |
|
|
96 |
line: |
line: |
97 |
'\n' |
'\n' {} |
98 |
| exp '\n' |
| exp '\n' {} |
|
{ |
|
|
/* Exercise quotes in braces. */ |
|
|
char tmp[] = "@>:@@:>@,"; |
|
|
} |
|
99 |
; |
; |
100 |
|
|
|
/* Exercise M4 quoting: '@:>@@:>@', 1. */ |
|
101 |
exp: |
exp: |
102 |
NUM { $$ = $1; } |
NUM { $$ = $1; } |
103 |
| exp '=' exp |
| exp '=' exp |
119 |
/* The input. */ |
/* The input. */ |
120 |
FILE *yyin; |
FILE *yyin; |
121 |
|
|
|
/* Exercise M4 quoting: '@:>@@:>@', 2. */ |
|
122 |
static void |
static void |
123 |
yyerror (const char *s) |
yyerror (const char *s) |
124 |
{ |
{ |
240 |
return res; |
return res; |
241 |
} |
} |
242 |
|
|
|
void |
|
|
id (YYSTYPE* lval) |
|
|
{ |
|
|
} |
|
|
|
|
243 |
int |
int |
244 |
main (int argc, const char **argv) |
main (int argc, const char **argv) |
245 |
{ |
{ |