diff options
Diffstat (limited to 'chapter01')
| -rw-r--r-- | chapter01/README.md | 2 | ||||
| -rw-r--r-- | chapter01/docs/01-grammar.md | 1 | ||||
| -rw-r--r-- | chapter01/docs/01-graph.gv (renamed from chapter01/docs/02-graph.gv) | 0 | ||||
| -rw-r--r-- | chapter01/docs/01-graph.svg (renamed from chapter01/docs/02-graph.svg) | 0 | ||||
| -rw-r--r-- | chapter01/src/main/java/com/seaofnodes/simple/Parser.java | 4 | ||||
| -rw-r--r-- | chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java (renamed from chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java) | 4 |
6 files changed, 6 insertions, 5 deletions
diff --git a/chapter01/README.md b/chapter01/README.md index f3231d8c..57caa801 100644 --- a/chapter01/README.md +++ b/chapter01/README.md @@ -113,7 +113,7 @@ Here is visualization of the program: return 1; ``` - + * Control nodes appear as square boxes * Control edges are in bold red diff --git a/chapter01/docs/01-grammar.md b/chapter01/docs/01-grammar.md index cf947dfc..5d9f3cf7 100644 --- a/chapter01/docs/01-grammar.md +++ b/chapter01/docs/01-grammar.md @@ -21,5 +21,6 @@ primaryExpression INTEGER_LITERAL : [1-9][0-9]* + | [0] ; ```
\ No newline at end of file diff --git a/chapter01/docs/02-graph.gv b/chapter01/docs/01-graph.gv index 40181544..40181544 100644 --- a/chapter01/docs/02-graph.gv +++ b/chapter01/docs/01-graph.gv diff --git a/chapter01/docs/02-graph.svg b/chapter01/docs/01-graph.svg index fbf92d7d..fbf92d7d 100644 --- a/chapter01/docs/02-graph.svg +++ b/chapter01/docs/01-graph.svg 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 |
