While the lemon documentation [1] claims that, in the absence of explicit error handling, all errors are fatal, this isn't true. Instead, if the parser could enter a valid state by just ignoring tokens, it would do so. This made things like a = b + + c "valid" expressions.
[1] At the end of http://www.hwaci.com/sw/lemon/lemon.html --- src/compiler/parser.y | 1 + src/compiler/test/error | 9 +++++++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/compiler/parser.y b/src/compiler/parser.y index b08667b..e06c6f7 100644 --- a/src/compiler/parser.y +++ b/src/compiler/parser.y @@ -85,6 +85,7 @@ %type node {struct ast_node *} %destructor node { free($$); } +%syntax_error { yy_parse_failed(yypParser); } start ::= TOK_START_EXPR node(N). { state->comm->parseout = N; diff --git a/src/compiler/test/error b/src/compiler/test/error index 4aed73f..c8d8749 100755 --- a/src/compiler/test/error +++ b/src/compiler/test/error @@ -20,4 +20,13 @@ x = a FPVM: parse error EOF +#------------------------------------------------------------------------------ + +ptest_fail "syntax error: x = a + + b" <<EOF +x = a + + b +EOF +expect <<EOF +FPVM: parse error +EOF + ############################################################################### -- 1.7.1 _______________________________________________ http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org IRC: #milkymist@Freenode
