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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: bison/src/bison/2.4.1/bison-2.4.1-src/examples/calc++/calc++-parser.yy
===================================================================
--- bison/src/bison/2.4.1/bison-2.4.1-src/examples/calc++/calc++-parser.yy (revision 0)
+++ bison/src/bison/2.4.1/bison-2.4.1-src/examples/calc++/calc++-parser.yy (revision 0)
@@ -0,0 +1,74 @@
+#line 8420 "../../doc/bison.texinfo"
+%skeleton "lalr1.cc" /* -*- C++ -*- */
+%require "2.4.1"
+%defines
+%define parser_class_name "calcxx_parser"
+#line 8438 "../../doc/bison.texinfo"
+%code requires {
+# include <string>
+class calcxx_driver;
+}
+#line 8451 "../../doc/bison.texinfo"
+// The parsing context.
+%parse-param { calcxx_driver& driver }
+%lex-param { calcxx_driver& driver }
+#line 8464 "../../doc/bison.texinfo"
+%locations
+%initial-action
+{
+ // Initialize the initial location.
+ @$.begin.filename = @$.end.filename = &driver.file;
+};
+#line 8478 "../../doc/bison.texinfo"
+%debug
+%error-verbose
+#line 8488 "../../doc/bison.texinfo"
+// Symbols.
+%union
+{
+ int ival;
+ std::string *sval;
+};
+#line 8503 "../../doc/bison.texinfo"
+%code {
+# include "calc++-driver.hh"
+}
+#line 8518 "../../doc/bison.texinfo"
+%token END 0 "end of file"
+%token ASSIGN ":="
+%token <sval> IDENTIFIER "identifier"
+%token <ival> NUMBER "number"
+%type <ival> exp
+#line 8532 "../../doc/bison.texinfo"
+%printer { debug_stream () << *$$; } "identifier"
+%destructor { delete $$; } "identifier"
+
+%printer { debug_stream () << $$; } <ival>
+#line 8543 "../../doc/bison.texinfo"
+%%
+%start unit;
+unit: assignments exp { driver.result = $2; };
+
+assignments: assignments assignment {}
+ | /* Nothing. */ {};
+
+assignment:
+ "identifier" ":=" exp
+ { driver.variables[*$1] = $3; delete $1; };
+
+%left '+' '-';
+%left '*' '/';
+exp: exp '+' exp { $$ = $1 + $3; }
+ | exp '-' exp { $$ = $1 - $3; }
+ | exp '*' exp { $$ = $1 * $3; }
+ | exp '/' exp { $$ = $1 / $3; }
+ | "identifier" { $$ = driver.variables[*$1]; delete $1; }
+ | "number" { $$ = $1; };
+%%
+#line 8571 "../../doc/bison.texinfo"
+void
+yy::calcxx_parser::error (const yy::calcxx_parser::location_type& l,
+ const std::string& m)
+{
+ driver.error (l, m);
+}

Powered by Google App Engine
This is Rietveld 408576698