aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-24 13:34:56 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-24 13:34:56 +0100
commitb584a0e7dea6fd903f8a285ee3a997ba535b44a7 (patch)
tree8ec27a4865126929da9ea12bffc9f2cb9f114f9c
parentbf2adf72c4fb4e04afb95ad3b2ad84c19707f246 (diff)
parent6498adb002bcf7e715afe46c23b8635d4592c156 (diff)
Merge pull request #816 from tsion/incomplete-parse
Throw a specific error for incomplete parse errors.
-rw-r--r--src/libexpr/lexer.l2
-rw-r--r--src/libexpr/nixexpr.hh1
-rw-r--r--src/libexpr/parser.y9
3 files changed, 11 insertions, 1 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index 701c01aff..f3660ab43 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -195,5 +195,7 @@ or { return OR_KW; }
}
+<<EOF>> { data->atEnd = true; return 0; }
+
%%
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 5e7bc40c8..d2ca09b3a 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -11,6 +11,7 @@ namespace nix {
MakeError(EvalError, Error)
MakeError(ParseError, Error)
+MakeError(IncompleteParseError, ParseError)
MakeError(AssertionError, EvalError)
MakeError(ThrownError, AssertionError)
MakeError(Abort, EvalError)
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index f87aa2619..80ecd44c5 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -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);