From 0697119593c00af15aeb2072e8b42122dde31c66 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 3 Dec 2024 22:44:36 -0800 Subject: viewer improvements viewer highlights parsed text; larger input box removes some double-display handles mouse over-run --- chapter18/src/main/java/com/seaofnodes/simple/JSViewer.java | 3 +++ chapter18/src/main/java/com/seaofnodes/simple/Parser.java | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'chapter18/src/main/java/com') 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 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; -- cgit v1.2.3