summaryrefslogtreecommitdiff
path: root/chapter01/src
diff options
context:
space:
mode:
Diffstat (limited to 'chapter01/src')
-rw-r--r--chapter01/src/main/java/com/seaofnodes/simple/Parser.java4
-rw-r--r--chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java (renamed from chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java)4
2 files changed, 4 insertions, 4 deletions
diff --git a/chapter01/src/main/java/com/seaofnodes/simple/Parser.java b/chapter01/src/main/java/com/seaofnodes/simple/Parser.java
index 8fb1ebaf..cdfff842 100644
--- a/chapter01/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter01/src/main/java/com/seaofnodes/simple/Parser.java
@@ -80,7 +80,7 @@ public class Parser {
* Parse integer literal
*
* <pre>
- * integerLiteral: [1-9][0-9]*
+ * integerLiteral: [1-9][0-9]* | [0]
* </pre>
*/
private ConstantNode parseIntegerLiteral(Lexer lexer) {
@@ -245,7 +245,7 @@ public class Parser {
private Token parsePuncuation() {
int start = _position-1;
- while( isPunctuation(nextChar()) );
+ if( isPunctuation(nextChar()) );
return Token.newPunct(new String(_input,start,--_position-start));
}
diff --git a/chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java b/chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java
index 887f63b8..14c22437 100644
--- a/chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java
+++ b/chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java
@@ -4,7 +4,7 @@ import com.seaofnodes.simple.node.*;
import org.junit.Test;
import static org.junit.Assert.*;
-public class ParserTest {
+public class Chapter01Test {
@Test
public void testSimpleProgram() {
@@ -54,7 +54,7 @@ public class ParserTest {
@Test
public void testBad3() {
try { new Parser().parse("return --12;"); }
- catch( RuntimeException e ) { assertEquals("syntax error, expected integer literal: --",e.getMessage()); }
+ catch( RuntimeException e ) { assertEquals("syntax error, expected integer literal: -",e.getMessage()); }
}
@Test