diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-04T21·06+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-04T21·06+0000 |
commit | 75068e7d753cf6cbe45a4bf294000dca9bd41d8b (patch) | |
tree | c6274cc10caab08349b5585206034f41ca4a575f /src/libexpr/parser.y | |
parent | aab88127321344d5818d823bff515d127108d058 (diff) |
* Use a proper namespace.
* Optimise header file usage a bit. * Compile the parser as C++.
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index c1e3b48a79a1..7714a5911165 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -3,7 +3,7 @@ %locations %error-verbose %parse-param { yyscan_t scanner } -%parse-param { void * data } +%parse-param { ParseData * data } %lex-param { yyscan_t scanner } %{ @@ -12,34 +12,47 @@ #include <string.h> #include <aterm2.h> -#include "parser-tab.h" +#include "parser-tab.hh" +extern "C" { #include "lexer-tab.h" +} -typedef ATerm Expr; -typedef ATerm ValidValues; -typedef ATerm DefaultValue; -typedef ATerm Pos; +#include "aterm.hh" +#include "nixexpr.hh" #include "nixexpr-ast.hh" -void setParseResult(void * data, ATerm t); -void parseError(void * data, char * error, int line, int column); -ATerm absParsedPath(void * data, ATerm t); -ATerm fixAttrs(int recursive, ATermList as); -const char * getPath(void * data); -void backToString(yyscan_t scanner); +using namespace nix; -void yyerror(YYLTYPE * loc, yyscan_t scanner, void * data, char * s) +namespace nix { + +struct ParseData { - parseError(data, s, loc->first_line, loc->first_column); + Expr result; + Path basePath; + Path path; + string error; +}; + +void setParseResult(ParseData * data, ATerm t); +void parseError(ParseData * data, char * error, int line, int column); +ATerm absParsedPath(ParseData * data, ATerm t); +ATerm fixAttrs(int recursive, ATermList as); +const char * getPath(ParseData * data); +Expr unescapeStr(const char * s); + +extern "C" { + void backToString(yyscan_t scanner); +} + } -ATerm toATerm(const char * s) +void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, char * s) { - return (ATerm) ATmakeAppl0(ATmakeAFun((char *) s, 0, ATtrue)); + parseError(data, s, loc->first_line, loc->first_column); } -static Pos makeCurPos(YYLTYPE * loc, void * data) +static Pos makeCurPos(YYLTYPE * loc, ParseData * data) { return makePos(toATerm(getPath(data)), loc->first_line, loc->first_column); |