diff options
| author | Cliff Click <cliffc@acm.org> | 2024-12-03 22:44:36 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-01-15 15:07:30 -0800 |
| commit | 0697119593c00af15aeb2072e8b42122dde31c66 (patch) | |
| tree | 1f1001ac8f7e2527de72cf98d0360a90757f5308 /chapter18/src/main/java/com | |
| parent | 2136abe8071833fd072c4be13c885525b46f5320 (diff) | |
| download | Simple-0697119593c00af15aeb2072e8b42122dde31c66.tar.gz Simple-0697119593c00af15aeb2072e8b42122dde31c66.zip | |
viewer improvements
viewer highlights parsed text;
larger input box
removes some double-display
handles mouse over-run
Diffstat (limited to 'chapter18/src/main/java/com')
| -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; |
