Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: bison/src/bison/2.4.1/bison-2.4.1-src/examples/calc++/calc++-parser.yy

Issue 10807020: Add native Windows binary for bison. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #line 8420 "../../doc/bison.texinfo"
2 %skeleton "lalr1.cc" /* -*- C++ -*- */
3 %require "2.4.1"
4 %defines
5 %define parser_class_name "calcxx_parser"
6 #line 8438 "../../doc/bison.texinfo"
7 %code requires {
8 # include <string>
9 class calcxx_driver;
10 }
11 #line 8451 "../../doc/bison.texinfo"
12 // The parsing context.
13 %parse-param { calcxx_driver& driver }
14 %lex-param { calcxx_driver& driver }
15 #line 8464 "../../doc/bison.texinfo"
16 %locations
17 %initial-action
18 {
19 // Initialize the initial location.
20 @$.begin.filename = @$.end.filename = &driver.file;
21 };
22 #line 8478 "../../doc/bison.texinfo"
23 %debug
24 %error-verbose
25 #line 8488 "../../doc/bison.texinfo"
26 // Symbols.
27 %union
28 {
29 int ival;
30 std::string *sval;
31 };
32 #line 8503 "../../doc/bison.texinfo"
33 %code {
34 # include "calc++-driver.hh"
35 }
36 #line 8518 "../../doc/bison.texinfo"
37 %token END 0 "end of file"
38 %token ASSIGN ":="
39 %token <sval> IDENTIFIER "identifier"
40 %token <ival> NUMBER "number"
41 %type <ival> exp
42 #line 8532 "../../doc/bison.texinfo"
43 %printer { debug_stream () << *$$; } "identifier"
44 %destructor { delete $$; } "identifier"
45
46 %printer { debug_stream () << $$; } <ival>
47 #line 8543 "../../doc/bison.texinfo"
48 %%
49 %start unit;
50 unit: assignments exp { driver.result = $2; };
51
52 assignments: assignments assignment {}
53 | /* Nothing. */ {};
54
55 assignment:
56 "identifier" ":=" exp
57 { driver.variables[*$1] = $3; delete $1; };
58
59 %left '+' '-';
60 %left '*' '/';
61 exp: exp '+' exp { $$ = $1 + $3; }
62 | exp '-' exp { $$ = $1 - $3; }
63 | exp '*' exp { $$ = $1 * $3; }
64 | exp '/' exp { $$ = $1 / $3; }
65 | "identifier" { $$ = driver.variables[*$1]; delete $1; }
66 | "number" { $$ = $1; };
67 %%
68 #line 8571 "../../doc/bison.texinfo"
69 void
70 yy::calcxx_parser::error (const yy::calcxx_parser::location_type& l,
71 const std::string& m)
72 {
73 driver.error (l, m);
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698