diff options
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index df4fdf032479..97e1a65849e2 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -1,7 +1,7 @@ %glr-parser %pure-parser %locations -%error-verbose +%define parse.error verbose %defines /* %no-lines */ %parse-param { void * scanner } @@ -31,12 +31,10 @@ namespace nix { Path basePath; Symbol path; string error; - bool atEnd; Symbol sLetBody; ParseData(EvalState & state) : state(state) , symbols(state.symbols) - , atEnd(false) , sLetBody(symbols.create("<let-body>")) { }; }; @@ -156,8 +154,8 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex whitespace-only final lines are not taken into account. (So the " " in "\n ''" is ignored, but the " " in "\n foo''" is.) */ bool atStartOfLine = true; /* = seen only whitespace in the current line */ - unsigned int minIndent = 1000000; - unsigned int curIndent = 0; + size_t minIndent = 1000000; + size_t curIndent = 0; for (auto & i : es) { ExprIndStr * e = dynamic_cast<ExprIndStr *>(i); if (!e) { @@ -168,7 +166,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex } continue; } - for (unsigned int j = 0; j < e->s.size(); ++j) { + for (size_t j = 0; j < e->s.size(); ++j) { if (atStartOfLine) { if (e->s[j] == ' ') curIndent++; @@ -190,8 +188,8 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex /* Strip spaces from each line. */ vector<Expr *> * es2 = new vector<Expr *>; atStartOfLine = true; - unsigned int curDropped = 0; - unsigned int n = es.size(); + size_t curDropped = 0; + size_t n = es.size(); for (vector<Expr *>::iterator i = es.begin(); i != es.end(); ++i, --n) { ExprIndStr * e = dynamic_cast<ExprIndStr *>(*i); if (!e) { @@ -202,7 +200,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex } string s2; - for (unsigned int j = 0; j < e->s.size(); ++j) { + for (size_t j = 0; j < e->s.size(); ++j) { if (atStartOfLine) { if (e->s[j] == ' ') { if (curDropped++ >= minIndent) @@ -295,11 +293,11 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err %token IND_STRING_OPEN IND_STRING_CLOSE %token ELLIPSIS -%nonassoc IMPL +%right IMPL %left OR %left AND %nonassoc EQ NEQ -%left '<' '>' LEQ GEQ +%nonassoc '<' '>' LEQ GEQ %right UPDATE %left NOT %left '+' '-' @@ -561,12 +559,7 @@ Expr * EvalState::parse(const char * text, int res = yyparse(scanner, &data); yylex_destroy(scanner); - if (res) { - if (data.atEnd) - throw IncompleteParseError(data.error); - else - throw ParseError(data.error); - } + if (res) throw ParseError(data.error); data.result->bindVars(staticEnv); |