diff --git a/parse.js b/parse.js index 8b3875b..f72846d 100644 --- a/parse.js +++ b/parse.js @@ -99,6 +99,11 @@ let error, mostErrorMatched = 0; while (!error) { + if (!this.tokenStream.peek(lex.TokenType.Op, "}").error) + { + break; + } + let stmt, errorMatched; ({ ast:stmt, error, numMatched:errorMatched } = this.attemptSubtree(this.statement)); @@ -114,7 +119,7 @@ } } - if (error) return this.getError({ msg: "Expecting expression", ...this.tokenStream.currentLinePos() }); + if (error) return this.getError({ msg: "Expecting statement", ...this.tokenStream.currentLinePos() }); return { ast: { node: ASTNode.Statements, statements: statements }, error: null }; } @@ -151,7 +156,7 @@ [ { parse: this.expression, handle: ast => ({ node: ASTNode.ExprStatement, expr: ast }) } ], - "Expecting expression"); + "Expecting statement"); let error, bestError, numMatched, bestNumMatched = 0; }