From 835e614e1e2531db3dc7dbe027de122a9fa0b78f Mon Sep 17 00:00:00 2001 From: bd-912 Date: Wed, 27 Mar 2024 23:20:35 -0600 Subject: Reorder generated files --- syntaxtree/NodeToken.java | 87 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 syntaxtree/NodeToken.java (limited to 'syntaxtree/NodeToken.java') diff --git a/syntaxtree/NodeToken.java b/syntaxtree/NodeToken.java new file mode 100644 index 0000000..100169d --- /dev/null +++ b/syntaxtree/NodeToken.java @@ -0,0 +1,87 @@ +// +// Generated by JTB 1.3.2 +// + +package syntaxtree; + +import java.util.*; +/** + * Represents a single token in the grammar. If the "-tk" option + * is used, also contains a Vector of preceding special tokens. + */ +public class NodeToken implements Node { + public NodeToken(String s) { + this(s, -1, -1, -1, -1, -1); } + + public NodeToken(String s, int kind, int beginLine, int beginColumn, int endLine, int endColumn) { + tokenImage = s; + specialTokens = null; + this.kind = kind; + this.beginLine = beginLine; + this.beginColumn = beginColumn; + this.endLine = endLine; + this.endColumn = endColumn; + } + + public NodeToken getSpecialAt(int i) { + if ( specialTokens == null ) + throw new java.util.NoSuchElementException("No specials in token"); + return specialTokens.elementAt(i); + } + + public int numSpecials() { + if ( specialTokens == null ) return 0; + return specialTokens.size(); + } + + public void addSpecial(NodeToken s) { + if ( specialTokens == null ) specialTokens = new Vector(); + specialTokens.addElement(s); + } + + public void trimSpecials() { + if ( specialTokens == null ) return; + specialTokens.trimToSize(); + } + + public String toString() { return tokenImage; } + + public String withSpecials() { + if ( specialTokens == null ) + return tokenImage; + + StringBuffer buf = new StringBuffer(); + + for ( Enumeration e = specialTokens.elements(); e.hasMoreElements(); ) + buf.append(e.nextElement().toString()); + + buf.append(tokenImage); + return buf.toString(); + } + + public void accept(visitor.Visitor v) { + v.visit(this); + } + public R accept(visitor.GJVisitor v, A argu) { + return v.visit(this,argu); + } + public R accept(visitor.GJNoArguVisitor v) { + return v.visit(this); + } + public void accept(visitor.GJVoidVisitor v, A argu) { + v.visit(this,argu); + } + + public String tokenImage; + + // Stores a list of NodeTokens + public Vector specialTokens; + + // -1 for these ints means no position info is available. + public int beginLine, beginColumn, endLine, endColumn; + + // Equal to the JavaCC token "kind" integer. + // -1 if not available. + public int kind; +} + -- cgit v1.2.3