about summary refs log tree commit diff
path: root/src/libexpr/parser.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-04T21·06+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-04T21·06+0000
commit75068e7d753cf6cbe45a4bf294000dca9bd41d8b (patch)
treec6274cc10caab08349b5585206034f41ca4a575f /src/libexpr/parser.cc
parentaab88127321344d5818d823bff515d127108d058 (diff)
* Use a proper namespace.
* Optimise header file usage a bit.
* Compile the parser as C++.

Diffstat (limited to 'src/libexpr/parser.cc')
-rw-r--r--src/libexpr/parser.cc40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc
index fa6c4e2f3225..20a6c9be2efd 100644
--- a/src/libexpr/parser.cc
+++ b/src/libexpr/parser.cc
@@ -1,3 +1,8 @@
+#include "parser.hh"
+#include "aterm.hh"
+#include "util.hh"
+#include "nixexpr-ast.hh"
+    
 #include <sstream>
 
 #include <sys/types.h>
@@ -5,9 +10,15 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "aterm.hh"
-#include "parser.hh"
-#include "nixexpr-ast.hh"
+
+extern "C" {
+
+#include "parser-tab.hh"
+#include "lexer-tab.h"
+    
+}
+
+namespace nix {
 
 
 struct ParseData 
@@ -17,16 +28,15 @@ struct ParseData
     Path path;
     string error;
 };
+ 
+}
 
 
-extern "C" {
+int yyparse(yyscan_t scanner, nix::ParseData * data);
+
+
+namespace nix {
 
-#include "parser-tab.h"
-#include "lexer-tab.h"
-    
-/* Callbacks for getting from C to C++.  Due to a (small) bug in the
-   GLR code of Bison we cannot currently compile the parser as C++
-   code. */
 
 void setParseResult(ParseData * data, ATerm t)
 {
@@ -71,6 +81,7 @@ const char * getPath(ParseData * data)
     return data->path.c_str();
 }
 
+extern "C" {
 Expr unescapeStr(const char * s)
 {
     string t;
@@ -93,11 +104,7 @@ Expr unescapeStr(const char * s)
     }
     return makeStr(toATerm(t));
 }
-
-int yyparse(yyscan_t scanner, ParseData * data);
-
-
-} /* end of C functions */
+}
 
 
 static void checkAttrs(ATermMap & names, ATermList bnds)
@@ -232,3 +239,6 @@ Expr parseExprFromString(EvalState & state,
 {
     return parse(state, s.c_str(), "(string)", basePath);
 }
+
+ 
+}