Browse Source

[4088] Moved yy to isc::eval namespace

Tomek Mrugalski 9 years ago
parent
commit
496e02872e
4 changed files with 19 additions and 18 deletions
  1. 2 2
      src/lib/eval/eval_context.cc
  2. 2 2
      src/lib/eval/eval_context.h
  3. 11 11
      src/lib/eval/lexer.ll
  4. 4 3
      src/lib/eval/parser.yy

+ 2 - 2
src/lib/eval/eval_context.cc

@@ -19,7 +19,7 @@ EvalContext::parseFile(const std::string &filename)
 {
     file = filename;
     scan_begin();
-    yy::EvalParser parser (*this);
+    isc::eval::EvalParser parser (*this);
     parser.set_debug_level(trace_parsing);
     int res = parser.parse();
     scan_end();
@@ -42,7 +42,7 @@ EvalContext::parseString(const std::string& str)
 }
 
 void
-EvalContext::error (const yy::location& l, const std::string& m)
+EvalContext::error (const isc::eval::location& l, const std::string& m)
 {
   std::cerr << l << ": " << m << std::endl;
 }

+ 2 - 2
src/lib/eval/eval_context.h

@@ -6,7 +6,7 @@
 
 // Tell Flex the lexer's prototype ...
 # define YY_DECL \
-  yy::EvalParser::symbol_type yylex (EvalContext& driver)
+    isc::eval::EvalParser::symbol_type yylex (EvalContext& driver)
 
 // ... and declare it for the parser's sake.
 YY_DECL;
@@ -41,7 +41,7 @@ public:
   bool trace_parsing;
 
   // Error handling.
-  void error (const yy::location& l, const std::string& m);
+  void error (const isc::eval::location& l, const std::string& m);
   void error (const std::string& m);
 };
 #endif // ! EVALCONTEXT_HH

+ 11 - 11
src/lib/eval/lexer.ll

@@ -14,7 +14,7 @@
 # define yywrap() 1
 
 // The location of the current token.
-static yy::location loc;
+static isc::eval::location loc;
 %}
 %option noyywrap nounput batch debug noinput
 id    [a-zA-Z][a-zA-Z_0-9]*
@@ -35,13 +35,13 @@ blank [ \t]
 
 {blank}+   loc.step ();
 [\n]+      loc.lines (yyleng); loc.step ();
-"-"      return yy::EvalParser::make_MINUS(loc);
-"+"      return yy::EvalParser::make_PLUS(loc);
-"*"      return yy::EvalParser::make_STAR(loc);
-"/"      return yy::EvalParser::make_SLASH(loc);
-"("      return yy::EvalParser::make_LPAREN(loc);
-")"      return yy::EvalParser::make_RPAREN(loc);
-":="     return yy::EvalParser::make_ASSIGN(loc);
+"-"      return isc::eval::EvalParser::make_MINUS(loc);
+"+"      return isc::eval::EvalParser::make_PLUS(loc);
+"*"      return isc::eval::EvalParser::make_STAR(loc);
+"/"      return isc::eval::EvalParser::make_SLASH(loc);
+"("      return isc::eval::EvalParser::make_LPAREN(loc);
+")"      return isc::eval::EvalParser::make_RPAREN(loc);
+":="     return isc::eval::EvalParser::make_ASSIGN(loc);
 
 
 {int}      {
@@ -49,12 +49,12 @@ blank [ \t]
   long n = strtol (yytext, NULL, 10);
   if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
     driver.error (loc, "integer is out of range");
-  return yy::EvalParser::make_NUMBER(n, loc);
+  return isc::eval::EvalParser::make_NUMBER(n, loc);
 }
 
-{id}       return yy::EvalParser::make_IDENTIFIER(yytext, loc);
+{id}       return isc::eval::EvalParser::make_IDENTIFIER(yytext, loc);
 .          driver.error (loc, "invalid character");
-<<EOF>>    return yy::EvalParser::make_END(loc);
+<<EOF>>    return isc::eval::EvalParser::make_END(loc);
 %%
 
 void

+ 4 - 3
src/lib/eval/parser.yy

@@ -4,6 +4,7 @@
 %define parser_class_name {EvalParser}
 %define api.token.constructor
 %define api.value.type variant
+%define api.namespace {isc::eval}
 %define parse.assert
 %code requires
 {
@@ -24,7 +25,7 @@ class EvalContext;
 {
 # include "eval_context.h"
 }
-%define api.token.prefix {TOK_}
+%define api.token.prefix {TOKEN_}
 %token
   END  0  "end of file"
   ASSIGN  ":="
@@ -62,8 +63,8 @@ exp:
 | "number"      { std::swap ($$, $1); };
 %%
 void
-yy::EvalParser::error(const location_type& l,
-                      const std::string& m)
+isc::eval::EvalParser::error(const location_type& l,
+                             const std::string& m)
 {
   driver.error (l, m);
 }