1 #line 7195 "../../doc/bison.texinfo"
2 %skeleton "lalr1.cc" /* -*- C++ -*- */
3 %define "parser_class_name" "calcxx_parser"
7 # include "calc++-driver.hh"
9 #line 7211 "../../doc/bison.texinfo"
10 // The parsing context.
11 %parse-param { calcxx_driver& driver }
12 %lex-param { calcxx_driver& driver }
13 #line 7224 "../../doc/bison.texinfo"
17 // Initialize the initial location.
18 @$.begin.filename = @$.end.filename = &driver.file;
20 #line 7238 "../../doc/bison.texinfo"
23 #line 7248 "../../doc/bison.texinfo"
30 #line 7265 "../../doc/bison.texinfo"
31 %token YYEOF 0 "end of file"
32 %token TOKEN_ASSIGN ":="
33 %token <sval> TOKEN_IDENTIFIER "identifier"
34 %token <ival> TOKEN_NUMBER "number"
35 %type <ival> exp "expression"
36 #line 7278 "../../doc/bison.texinfo"
37 %printer { debug_stream () << *$$; } "identifier"
38 %destructor { delete $$; } "identifier"
40 %printer { debug_stream () << $$; } "number" "expression"
41 #line 7289 "../../doc/bison.texinfo"
44 unit: assignments exp { driver.result = $2; };
46 assignments: assignments assignment {}
49 assignment: TOKEN_IDENTIFIER ":=" exp { driver.variables[*$1] = $3; };
53 exp: exp '+' exp { $$ = $1 + $3; }
54 | exp '-' exp { $$ = $1 - $3; }
55 | exp '*' exp { $$ = $1 * $3; }
56 | exp '/' exp { $$ = $1 / $3; }
57 | TOKEN_IDENTIFIER { $$ = driver.variables[*$1]; }
58 | TOKEN_NUMBER { $$ = $1; };
60 #line 7315 "../../doc/bison.texinfo"
62 yy::calcxx_parser::error (const yy::calcxx_parser::location_type& l,