From d6442ce5d00b9bea52d366ff4d6ae8c03b84aabb Mon Sep 17 00:00:00 2001 From: Thalia Archibald Date: Mon, 1 Jul 2024 08:42:23 -0700 Subject: Fix grammar and forward-port minor changes (#91) * Backport test exception handling to chapter 1 * Add unary ! to chapter 10 and 11 grammars * Lex { } ! as punctuation * Forward-port format whitespace * Forward-port test organization * Forward-port replace build-graphs.sh with Makefile * Add chapter title to chapter 11 --- chapter10/docs/10-grammar.md | 1 + chapter10/src/main/java/com/seaofnodes/simple/Parser.java | 3 +-- chapter10/src/test/java/com/seaofnodes/simple/Chapter08Test.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) (limited to 'chapter10') diff --git a/chapter10/docs/10-grammar.md b/chapter10/docs/10-grammar.md index 01863e7f..29ca7762 100644 --- a/chapter10/docs/10-grammar.md +++ b/chapter10/docs/10-grammar.md @@ -92,6 +92,7 @@ multiplicativeExpression unaryExpression : ('-') unaryExpression + | '!' unaryExpression | primaryExpression ; diff --git a/chapter10/src/main/java/com/seaofnodes/simple/Parser.java b/chapter10/src/main/java/com/seaofnodes/simple/Parser.java index 9a1b4465..dbb2d172 100644 --- a/chapter10/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter10/src/main/java/com/seaofnodes/simple/Parser.java @@ -821,9 +821,8 @@ public class Parser { return new String(_input, start, --_position - start); } - // private boolean isPunctuation(char ch) { - return "=;[]<>()+-/*".indexOf(ch) != -1; + return "=;[]<>(){}+-/*!".indexOf(ch) != -1; } private String parsePunctuation() { diff --git a/chapter10/src/test/java/com/seaofnodes/simple/Chapter08Test.java b/chapter10/src/test/java/com/seaofnodes/simple/Chapter08Test.java index adcb6b59..6e8d218f 100644 --- a/chapter10/src/test/java/com/seaofnodes/simple/Chapter08Test.java +++ b/chapter10/src/test/java/com/seaofnodes/simple/Chapter08Test.java @@ -5,7 +5,6 @@ import com.seaofnodes.simple.node.*; import com.seaofnodes.simple.type.TypeInteger; import org.junit.Assert; import org.junit.Test; -import org.junit.Ignore; import static org.junit.Assert.*; -- cgit v1.2.3