From 43f2a09f106072727eaceb6134be02c03429b425 Mon Sep 17 00:00:00 2001 From: XmiliaH <45106915+XmiliaH@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:25:56 +0100 Subject: Report unclosed block in parsing (#28) --- chapter05/src/main/java/com/seaofnodes/simple/Parser.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'chapter05/src/main/java/com') diff --git a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java index 79b50672..a287f997 100644 --- a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java @@ -115,7 +115,9 @@ public class Parser { // Enter a new scope _scope.push(); Node n = null; - while (!match("}") && !_lexer.isEOF()) { + while (!match("}")) { + if (_lexer.isEOF()) throw errorSyntax("}"); + Node n0 = parseStatement(); if (n0 != null) n = n0; // Allow null returns from eg showGraph } -- cgit v1.2.3