summaryrefslogtreecommitdiff
path: root/chapter17
diff options
context:
space:
mode:
Diffstat (limited to 'chapter17')
-rw-r--r--chapter17/src/main/java/com/seaofnodes/simple/Parser.java4
-rw-r--r--chapter17/src/test/java/com/seaofnodes/simple/Chapter01Test.java2
-rw-r--r--chapter17/src/test/java/com/seaofnodes/simple/Chapter11Test.java8
3 files changed, 6 insertions, 8 deletions
diff --git a/chapter17/src/main/java/com/seaofnodes/simple/Parser.java b/chapter17/src/main/java/com/seaofnodes/simple/Parser.java
index dae3cd54..c144b1d7 100644
--- a/chapter17/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter17/src/main/java/com/seaofnodes/simple/Parser.java
@@ -1379,9 +1379,7 @@ public class Parser {
char ch0 = (char)_input[_position];
if( "+-/*&|^".indexOf(ch0) == -1 ) return 0;
char ch1 = (char)_input[_position+1];
- if( ch1=='=' )
- { _position += 2; return ch0; }
- if( isIdLetter((char)_input[_position+2]) ) return 0; // Stop --x
+ if( ch1 == '=' ) { _position += 2; return ch0; }
if( ch0 == '+' && ch1 == '+' ) { _position += 2; return (char) 1; }
if( ch0 == '-' && ch1 == '-' ) { _position += 2; return (char)-1; }
return 0;
diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter01Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter01Test.java
index c10dc510..f7524c17 100644
--- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter01Test.java
+++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter01Test.java
@@ -58,7 +58,7 @@ public class Chapter01Test {
@Test
public void testNotBad3() {
// this test used to fail in chapter 1
- assertEquals("return 12;", new Parser("return --12;").parse().print());
+ assertEquals("return 12;", new Parser("return - -12;").parse().print());
}
@Test
diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter11Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter11Test.java
index 5127b250..0151a694 100644
--- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter11Test.java
+++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter11Test.java
@@ -14,7 +14,7 @@ public class Chapter11Test {
public void testFuzzer() {
Parser parser = new Parser(
"""
-while(-----arg) {
+while(---- -arg) {
while(-arg) {
while(-----arg*---0) {
int N=--false==false<--arg;
@@ -103,7 +103,7 @@ while(-----arg) {
int UX=arg;
while(UX<-3*arg) {
UX=UX+arg/-1;
- arg=-3--(-UX--47<arg==--arg==arg)/arg--UX>=-arg;
+ arg=-3--(-UX- -47<arg==--arg==arg)/arg- -UX>=-arg;
if(---12) while(-UX) break;
break;
}
@@ -224,9 +224,9 @@ if(arg!=62==arg) {
}
}
arg=-arg+arg;
- arg=--47+-arg<1>arg*(-arg==-arg--0>3);
+ arg=--47+-arg<1>arg*(-arg==-arg- -0>3);
arg=(----arg)!=arg+--59;
- arg=--4+arg==-(arg)-arg;
+ arg=- -4+arg==-(arg)-arg;
}
else {
while(--true-----true*-25+-18>arg>=-----(-arg)---13) {