$ template make_tokens() $ $ // Generate all fixed token files $ foreach {//token[@value]} $ output $basedir + '/node/' + @ename + '.java' /* This file was generated by SableCC (http://www.sablecc.org/). */ package $package.node; import $package.analysis.*; public final class @ename extends Token { public @ename() { super.setText("${sablecc:escape_string_literal(string(@value))}"); } public @ename(int line, int pos) { super.setText("${sablecc:escape_string_literal(string(@value))}"); setLine(line); setPos(pos); } public Object clone() { return new @ename(getLine(), getPos()); } public void apply(Switch sw) { ((Analysis) sw).case@ename(this); } public void setText(String text) { throw new RuntimeException("Cannot change @ename text."); } } $ end output $ end foreach $ // Generate all variable token files $ foreach {//token[not(@value)]} $ output $basedir + '/node/' + @ename + '.java' /* This file was generated by SableCC (http://www.sablecc.org/). */ package $package.node; import $package.analysis.*; public final class @ename extends Token { public @ename(String text) { setText(text); } public @ename(String text, int line, int pos) { setText(text); setLine(line); setPos(pos); } public Object clone() { return new @ename(getText(), getLine(), getPos()); } public void apply(Switch sw) { ((Analysis) sw).case@ename(this); } } $ end output $ end foreach $ // Generate the node/Token.java file $ output $basedir + '/node/Token.java' /* This file was generated by SableCC (http://www.sablecc.org/). */ package @package.node; public abstract class Token extends Node { private String text; private int line; private int pos; public String getText() { return text; } public void setText(String text) { this.text = text; } public int getLine() { return line; } public void setLine(int line) { this.line = line; } public int getPos() { return pos; } public void setPos(int pos) { this.pos = pos; } public String toString() { return text + " "; } void removeChild(Node child) { } void replaceChild(Node oldChild, Node newChild) { } } $ end output $ // Generate the node/EOF.java file $ output $basedir + '/node/EOF.java' /* This file was generated by SableCC (http://www.sablecc.org/). */ package @package.node; import @package.analysis.*; public final class EOF extends Token { public EOF() { setText(""); } public EOF(int line, int pos) { setText(""); setLine(line); setPos(pos); } public Object clone() { return new EOF(getLine(), getPos()); } public void apply(Switch sw) { ((Analysis) sw).caseEOF(this); } } $ end output $ end template