Merge pull request #816 from tsion/incomplete-parse

Throw a specific error for incomplete parse errors.
This commit is contained in:
Eelco Dolstra 2016-02-24 13:34:56 +01:00
commit b584a0e7de
3 changed files with 11 additions and 1 deletions

View file

@ -195,5 +195,7 @@ or { return OR_KW; }
}
<<EOF>> { data->atEnd = true; return 0; }
%%

View file

@ -11,6 +11,7 @@ namespace nix {
MakeError(EvalError, Error)
MakeError(ParseError, Error)
MakeError(IncompleteParseError, ParseError)
MakeError(AssertionError, EvalError)
MakeError(ThrownError, AssertionError)
MakeError(Abort, EvalError)

View file

@ -31,10 +31,12 @@ 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>"))
{ };
};
@ -539,7 +541,12 @@ Expr * EvalState::parse(const char * text,
int res = yyparse(scanner, &data);
yylex_destroy(scanner);
if (res) throw ParseError(data.error);
if (res) {
if (data.atEnd)
throw IncompleteParseError(data.error);
else
throw ParseError(data.error);
}
data.result->bindVars(staticEnv);