diff options
Diffstat (limited to 'chapter18/src/main/java')
| -rw-r--r-- | chapter18/src/main/java/com/seaofnodes/simple/JSViewer.java | 3 | ||||
| -rw-r--r-- | chapter18/src/main/java/com/seaofnodes/simple/Parser.java | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/chapter18/src/main/java/com/seaofnodes/simple/JSViewer.java b/chapter18/src/main/java/com/seaofnodes/simple/JSViewer.java index 79a84edf..c63b5118 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/JSViewer.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/JSViewer.java @@ -30,6 +30,7 @@ public class JSViewer implements AutoCloseable { } void run( ) throws Exception { + SERVER.put("!"); while( true ) { String src = SERVER.get(); switch( src ) { @@ -74,6 +75,8 @@ public class JSViewer implements AutoCloseable { Collection<Node> all = GraphVisualizer.findAll(P==null ? null : P._xScopes, STOP, P==null ? null : P._scope); SB sb = new SB(); sb.p("digraph view_").p(N++).p(" {\n").ii(); + if( P!=null ) + sb.i().p("// POS: ").p(P.pos()).nl(); // To keep the Scopes below the graph and pointing up into the graph we // need to group the Nodes in a subgraph cluster, and the scopes into a diff --git a/chapter18/src/main/java/com/seaofnodes/simple/Parser.java b/chapter18/src/main/java/com/seaofnodes/simple/Parser.java index 47bfe08e..04af20f7 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/Parser.java @@ -640,7 +640,6 @@ public class Parser { // A Block scope parse, and inspect the scope afterward for fields. _scope.push(true); - _xScopes.push(_scope); require("{"); while (!peek('}') && !_lexer.isEOF()) parseStatement(); @@ -661,7 +660,6 @@ public class Parser { // Done with struct/block scope require("}"); require(";"); - _xScopes.pop(); _scope.pop(); return null; } @@ -1183,7 +1181,7 @@ public class Parser { private boolean peek(char ch) { return _lexer.peek(ch); } private boolean peekIsId() { return _lexer.peekIsId(); } - private int pos() { return _lexer._position; } + public int pos() { return _lexer._position; } private int pos(int pos) { int old = _lexer._position; _lexer._position = pos; |
