Add missing @Override annotations

This commit is contained in:
Sam Harwell 2012-02-23 09:12:13 -06:00
parent 96c08bec52
commit 1492648d26
36 changed files with 161 additions and 0 deletions

View File

@ -225,5 +225,6 @@ public class ANTLRInputStream implements CharStream {
return name; return name;
} }
@Override
public String toString() { return new String(data); } public String toString() { return new String(data); }
} }

View File

@ -234,6 +234,7 @@ public class BufferedTokenStream<T extends Token> implements TokenStream {
public String getSourceName() { return tokenSource.getSourceName(); } public String getSourceName() { return tokenSource.getSourceName(); }
/** Grab *all* tokens from stream and return string */ /** Grab *all* tokens from stream and return string */
@Override
public String toString() { public String toString() {
if ( p == -1 ) setup(); if ( p == -1 ) setup();
fill(); fill();

View File

@ -195,6 +195,7 @@ public class CommonToken implements WritableToken, Serializable {
return source != null ? source.getInputStream() : null; return source != null ? source.getInputStream() : null;
} }
@Override
public String toString() { public String toString() {
String channelStr = ""; String channelStr = "";
if ( channel>0 ) { if ( channel>0 ) {

View File

@ -353,6 +353,7 @@ public class TokenRewriteStream extends CommonTokenStream {
return buf.toString(); return buf.toString();
} }
@Override
public String toString() { public String toString() {
fill(); fill();
return toString(MIN_TOKEN_INDEX, size()-1); return toString(MIN_TOKEN_INDEX, size()-1);

View File

@ -52,6 +52,7 @@ public class ActionTransition extends Transition {
return true; // we are to be ignored by analysis 'cept for predicates return true; // we are to be ignored by analysis 'cept for predicates
} }
@Override
public String toString() { public String toString() {
return "action_"+ruleIndex+":"+actionIndex; return "action_"+ruleIndex+":"+actionIndex;
} }

View File

@ -179,6 +179,7 @@ public class LexerATNSimulator extends ATNSimulator {
} }
} }
@Override
public void reset() { public void reset() {
dfaPrevAccept.reset(); dfaPrevAccept.reset();
atnPrevAccept.reset(); atnPrevAccept.reset();

View File

@ -87,6 +87,7 @@ public class FastQueue<T> {
} }
/** Return string of current buffer contents; non-destructive */ /** Return string of current buffer contents; non-destructive */
@Override
public String toString() { public String toString() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
int n = size(); int n = size();

View File

@ -62,6 +62,7 @@ public interface IntSet {
boolean isNil(); boolean isNil();
@Override
boolean equals(Object obj); boolean equals(Object obj);
int getSingleElement(); int getSingleElement();
@ -73,5 +74,6 @@ public interface IntSet {
List<Integer> toList(); List<Integer> toList();
@Override
String toString(); String toString();
} }

View File

@ -64,6 +64,7 @@ public class Interval {
return cache[a]; return cache[a];
} }
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
if ( o==null ) { if ( o==null ) {
return false; return false;
@ -139,6 +140,7 @@ public class Interval {
return diff; return diff;
} }
@Override
public String toString() { public String toString() {
return a+".."+b; return a+".."+b;
} }

View File

@ -124,6 +124,7 @@ public class OrderedHashSet<T> extends LinkedHashSet<T> {
return elements.toArray(); return elements.toArray();
} }
@Override
public String toString() { public String toString() {
return elements.toString(); return elements.toString();
} }

View File

@ -58,6 +58,7 @@ public class LexerATNFactory extends ParserATNFactory {
codegenTemplates = gen.templates; codegenTemplates = gen.templates;
} }
@Override
public ATN createATN() { public ATN createATN() {
// BUILD ALL START STATES (ONE PER MODE) // BUILD ALL START STATES (ONE PER MODE)
Set<String> modes = ((LexerGrammar) g).modes.keySet(); Set<String> modes = ((LexerGrammar) g).modes.keySet();

View File

@ -105,6 +105,7 @@ public class ParserATNFactory implements ATNFactory {
public ParserATNFactory(@NotNull Grammar g) { this.g = g; atn = new ATN(); } public ParserATNFactory(@NotNull Grammar g) { this.g = g; atn = new ATN(); }
@Override
public ATN createATN() { public ATN createATN() {
_createATN(g.rules.values()); _createATN(g.rules.values());
atn.maxTokenType = g.getMaxTokenType(); atn.maxTokenType = g.getMaxTokenType();
@ -133,6 +134,7 @@ public class ParserATNFactory implements ATNFactory {
} }
} }
@Override
public void setCurrentRuleName(String name) { public void setCurrentRuleName(String name) {
this.currentRule = g.getRule(name); this.currentRule = g.getRule(name);
} }
@ -143,6 +145,7 @@ public class ParserATNFactory implements ATNFactory {
} }
/* start->ruleblock->end */ /* start->ruleblock->end */
@Override
public Handle rule(GrammarAST ruleAST, String name, Handle blk) { public Handle rule(GrammarAST ruleAST, String name, Handle blk) {
Rule r = g.getRule(name); Rule r = g.getRule(name);
RuleStartState start = atn.ruleToStartState[r.index]; RuleStartState start = atn.ruleToStartState[r.index];
@ -157,6 +160,7 @@ public class ParserATNFactory implements ATNFactory {
} }
/** From label A build Graph o-A->o */ /** From label A build Graph o-A->o */
@Override
public Handle tokenRef(TerminalAST node) { public Handle tokenRef(TerminalAST node) {
ATNState left = newState(node); ATNState left = newState(node);
ATNState right = newState(node); ATNState right = newState(node);
@ -170,6 +174,7 @@ public class ParserATNFactory implements ATNFactory {
* what an alt block looks like, must have extra state on left. * what an alt block looks like, must have extra state on left.
* This handles ~A also, converted to ~{A} set. * This handles ~A also, converted to ~{A} set.
*/ */
@Override
public Handle set(GrammarAST associatedAST, List<GrammarAST> terminals, boolean invert) { public Handle set(GrammarAST associatedAST, List<GrammarAST> terminals, boolean invert) {
ATNState left = newState(associatedAST); ATNState left = newState(associatedAST);
ATNState right = newState(associatedAST); ATNState right = newState(associatedAST);
@ -188,11 +193,13 @@ public class ParserATNFactory implements ATNFactory {
return new Handle(left, right); return new Handle(left, right);
} }
@Override
public Handle tree(GrammarAST node, List<Handle> els) { public Handle tree(GrammarAST node, List<Handle> els) {
throw new UnsupportedOperationException("^(...) not allowed in non-tree grammar"); throw new UnsupportedOperationException("^(...) not allowed in non-tree grammar");
} }
/** Not valid for non-lexers */ /** Not valid for non-lexers */
@Override
public Handle range(GrammarAST a, GrammarAST b) { public Handle range(GrammarAST a, GrammarAST b) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -209,6 +216,7 @@ public class ParserATNFactory implements ATNFactory {
} }
/** For a non-lexer, just build a simple token reference atom. */ /** For a non-lexer, just build a simple token reference atom. */
@Override
public Handle stringLiteral(TerminalAST stringLiteralAST) { public Handle stringLiteral(TerminalAST stringLiteralAST) {
return tokenRef(stringLiteralAST); return tokenRef(stringLiteralAST);
} }
@ -226,6 +234,7 @@ public class ParserATNFactory implements ATNFactory {
* where (r) is the start of rule r and the trailing o is not linked * where (r) is the start of rule r and the trailing o is not linked
* to from rule ref state directly (uses followState). * to from rule ref state directly (uses followState).
*/ */
@Override
public Handle ruleRef(GrammarAST node) { public Handle ruleRef(GrammarAST node) {
Handle h = _ruleRef(node); Handle h = _ruleRef(node);
// Rule r = g.getRule(node.getText()); // Rule r = g.getRule(node.getText());
@ -257,6 +266,7 @@ public class ParserATNFactory implements ATNFactory {
} }
/** From an empty alternative build o-e->o */ /** From an empty alternative build o-e->o */
@Override
public Handle epsilon(GrammarAST node) { public Handle epsilon(GrammarAST node) {
ATNState left = newState(node); ATNState left = newState(node);
ATNState right = newState(node); ATNState right = newState(node);
@ -269,6 +279,7 @@ public class ParserATNFactory implements ATNFactory {
* predicate action. The pred is a pointer into the AST of * predicate action. The pred is a pointer into the AST of
* the SEMPRED token. * the SEMPRED token.
*/ */
@Override
public Handle sempred(PredAST pred) { public Handle sempred(PredAST pred) {
//System.out.println("sempred: "+ pred); //System.out.println("sempred: "+ pred);
ATNState left = newState(pred); ATNState left = newState(pred);
@ -284,6 +295,7 @@ public class ParserATNFactory implements ATNFactory {
* The action goes into ATN though it is ignored during prediction * The action goes into ATN though it is ignored during prediction
* if actionIndex < 0. Only forced are executed during prediction. * if actionIndex < 0. Only forced are executed during prediction.
*/ */
@Override
public Handle action(ActionAST action) { public Handle action(ActionAST action) {
//System.out.println("action: "+action); //System.out.println("action: "+action);
ATNState left = newState(action); ATNState left = newState(action);
@ -320,6 +332,7 @@ public class ParserATNFactory implements ATNFactory {
* *
* TODO: Set alt number (1..n) in the states? * TODO: Set alt number (1..n) in the states?
*/ */
@Override
public Handle block(BlockAST blkAST, GrammarAST ebnfRoot, List<Handle> alts) { public Handle block(BlockAST blkAST, GrammarAST ebnfRoot, List<Handle> alts) {
if ( ebnfRoot==null ) { if ( ebnfRoot==null ) {
if ( alts.size()==1 ) { if ( alts.size()==1 ) {
@ -371,6 +384,7 @@ public class ParserATNFactory implements ATNFactory {
} }
@NotNull @NotNull
@Override
public Handle alt(@NotNull List<Handle> els) { public Handle alt(@NotNull List<Handle> els) {
return elemList(els); return elemList(els);
} }
@ -415,6 +429,7 @@ public class ParserATNFactory implements ATNFactory {
* or, if A is a block, just add an empty alt to the end of the block * or, if A is a block, just add an empty alt to the end of the block
*/ */
@NotNull @NotNull
@Override
public Handle optional(@NotNull GrammarAST optAST, @NotNull Handle blk) { public Handle optional(@NotNull GrammarAST optAST, @NotNull Handle blk) {
// TODO: no such thing as nongreedy ()? so give error // TODO: no such thing as nongreedy ()? so give error
BlockStartState blkStart = (BlockStartState)blk.left; BlockStartState blkStart = (BlockStartState)blk.left;
@ -433,6 +448,7 @@ public class ParserATNFactory implements ATNFactory {
* blk start. * blk start.
*/ */
@NotNull @NotNull
@Override
public Handle plus(@NotNull GrammarAST plusAST, @NotNull Handle blk) { public Handle plus(@NotNull GrammarAST plusAST, @NotNull Handle blk) {
PlusBlockStartState blkStart = (PlusBlockStartState)blk.left; PlusBlockStartState blkStart = (PlusBlockStartState)blk.left;
BlockEndState blkEnd = (BlockEndState)blk.right; BlockEndState blkEnd = (BlockEndState)blk.right;
@ -474,6 +490,7 @@ public class ParserATNFactory implements ATNFactory {
* not the same thing as (A|B|)+. * not the same thing as (A|B|)+.
*/ */
@NotNull @NotNull
@Override
public Handle star(@NotNull GrammarAST starAST, @NotNull Handle elem) { public Handle star(@NotNull GrammarAST starAST, @NotNull Handle elem) {
StarBlockStartState blkStart = (StarBlockStartState)elem.left; StarBlockStartState blkStart = (StarBlockStartState)elem.left;
BlockEndState blkEnd = (BlockEndState)elem.right; BlockEndState blkEnd = (BlockEndState)elem.right;
@ -505,6 +522,7 @@ public class ParserATNFactory implements ATNFactory {
/** Build an atom with all possible values in its label */ /** Build an atom with all possible values in its label */
@NotNull @NotNull
@Override
public Handle wildcard(GrammarAST node) { public Handle wildcard(GrammarAST node) {
ATNState left = newState(node); ATNState left = newState(node);
ATNState right = newState(node); ATNState right = newState(node);
@ -516,6 +534,7 @@ public class ParserATNFactory implements ATNFactory {
/** Build a subrule matching ^(. .*) (any tree or node). Let's use /** Build a subrule matching ^(. .*) (any tree or node). Let's use
* (^(. .+) | .) to be safe. * (^(. .+) | .) to be safe.
*/ */
@Override
public Handle wildcardTree(GrammarAST associatedAST) { throw new UnsupportedOperationException(); } public Handle wildcardTree(GrammarAST associatedAST) { throw new UnsupportedOperationException(); }
void epsilon(ATNState a, @NotNull ATNState b) { void epsilon(ATNState a, @NotNull ATNState b) {
@ -572,10 +591,12 @@ public class ParserATNFactory implements ATNFactory {
return n; return n;
} }
@Override
public Handle label(Handle t) { public Handle label(Handle t) {
return t; return t;
} }
@Override
public Handle listLabel(Handle t) { public Handle listLabel(Handle t) {
return t; return t;
} }
@ -606,6 +627,7 @@ public class ParserATNFactory implements ATNFactory {
} }
@NotNull @NotNull
@Override
public ATNState newState() { return newState(null); } public ATNState newState() { return newState(null); }
public boolean isGreedy(@NotNull BlockAST blkAST) { public boolean isGreedy(@NotNull BlockAST blkAST) {

View File

@ -130,6 +130,7 @@ public class ActionTranslator implements ActionSplitterListener {
return translator.chunks; return translator.chunks;
} }
@Override
public void attr(String expr, Token x) { public void attr(String expr, Token x) {
gen.g.tool.log("action-translator", "attr "+x); gen.g.tool.log("action-translator", "attr "+x);
Attribute a = node.resolver.resolveToAttribute(x.getText(), node); Attribute a = node.resolver.resolveToAttribute(x.getText(), node);
@ -160,6 +161,7 @@ public class ActionTranslator implements ActionSplitterListener {
} }
/** $x.y = expr; */ /** $x.y = expr; */
@Override
public void setQualifiedAttr(String expr, Token x, Token y, Token rhs) { public void setQualifiedAttr(String expr, Token x, Token y, Token rhs) {
gen.g.tool.log("action-translator", "setQAttr "+x+"."+y+"="+rhs); gen.g.tool.log("action-translator", "setQAttr "+x+"."+y+"="+rhs);
// x has to be current rule; just set y attr // x has to be current rule; just set y attr
@ -167,6 +169,7 @@ public class ActionTranslator implements ActionSplitterListener {
chunks.add(new SetAttr(nodeContext,y.getText(), rhsChunks)); chunks.add(new SetAttr(nodeContext,y.getText(), rhsChunks));
} }
@Override
public void qualifiedAttr(String expr, Token x, Token y) { public void qualifiedAttr(String expr, Token x, Token y) {
gen.g.tool.log("action-translator", "qattr "+x+"."+y); gen.g.tool.log("action-translator", "qattr "+x+"."+y);
Attribute a = node.resolver.resolveToAttribute(x.getText(), y.getText(), node); Attribute a = node.resolver.resolveToAttribute(x.getText(), y.getText(), node);
@ -197,6 +200,7 @@ public class ActionTranslator implements ActionSplitterListener {
} }
} }
@Override
public void setAttr(String expr, Token x, Token rhs) { public void setAttr(String expr, Token x, Token rhs) {
gen.g.tool.log("action-translator", "setAttr "+x+" "+rhs); gen.g.tool.log("action-translator", "setAttr "+x+" "+rhs);
List<ActionChunk> rhsChunks = translateActionChunk(factory,rf,rhs.getText(),node); List<ActionChunk> rhsChunks = translateActionChunk(factory,rf,rhs.getText(),node);
@ -205,12 +209,14 @@ public class ActionTranslator implements ActionSplitterListener {
chunks.add(s); chunks.add(s);
} }
@Override
public void nonLocalAttr(String expr, Token x, Token y) { public void nonLocalAttr(String expr, Token x, Token y) {
gen.g.tool.log("action-translator", "nonLocalAttr "+x+"::"+y); gen.g.tool.log("action-translator", "nonLocalAttr "+x+"::"+y);
Rule r = factory.getGrammar().getRule(x.getText()); Rule r = factory.getGrammar().getRule(x.getText());
chunks.add(new NonLocalAttrRef(nodeContext, x.getText(), y.getText(), r.index)); chunks.add(new NonLocalAttrRef(nodeContext, x.getText(), y.getText(), r.index));
} }
@Override
public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) { public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) {
gen.g.tool.log("action-translator", "setNonLocalAttr "+x+"::"+y+"="+rhs); gen.g.tool.log("action-translator", "setNonLocalAttr "+x+"::"+y+"="+rhs);
Rule r = factory.getGrammar().getRule(x.getText()); Rule r = factory.getGrammar().getRule(x.getText());
@ -219,9 +225,11 @@ public class ActionTranslator implements ActionSplitterListener {
chunks.add(s); chunks.add(s);
} }
@Override
public void unknownSyntax(Token t) { public void unknownSyntax(Token t) {
} }
@Override
public void text(String text) { public void text(String text) {
chunks.add(new ActionText(nodeContext,text)); chunks.add(new ActionText(nodeContext,text));
} }

View File

@ -37,60 +37,85 @@ import org.antlr.v4.tool.ast.*;
import java.util.List; import java.util.List;
public abstract class BlankOutputModelFactory implements OutputModelFactory { public abstract class BlankOutputModelFactory implements OutputModelFactory {
@Override
public ParserFile parserFile(String fileName) { return null; } public ParserFile parserFile(String fileName) { return null; }
@Override
public Parser parser(ParserFile file) { return null; } public Parser parser(ParserFile file) { return null; }
@Override
public RuleFunction rule(Rule r) { return null; } public RuleFunction rule(Rule r) { return null; }
@Override
public List<SrcOp> rulePostamble(RuleFunction function, Rule r) { return null; } public List<SrcOp> rulePostamble(RuleFunction function, Rule r) { return null; }
@Override
public LexerFile lexerFile(String fileName) { return null; } public LexerFile lexerFile(String fileName) { return null; }
@Override
public Lexer lexer(LexerFile file) { return null; } public Lexer lexer(LexerFile file) { return null; }
// ALTERNATIVES / ELEMENTS // ALTERNATIVES / ELEMENTS
@Override
public CodeBlockForAlt alternative(Alternative alt, boolean outerMost) { return null; } public CodeBlockForAlt alternative(Alternative alt, boolean outerMost) { return null; }
@Override
public CodeBlockForAlt finishAlternative(CodeBlockForAlt blk, List<SrcOp> ops) { return blk; } public CodeBlockForAlt finishAlternative(CodeBlockForAlt blk, List<SrcOp> ops) { return blk; }
@Override
public CodeBlockForAlt epsilon(Alternative alt, boolean outerMost) { return null; } public CodeBlockForAlt epsilon(Alternative alt, boolean outerMost) { return null; }
@Override
public List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { return null; } public List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { return null; }
@Override
public List<SrcOp> tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args) { return null; } public List<SrcOp> tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args) { return null; }
@Override
public List<SrcOp> stringRef(GrammarAST ID, GrammarAST label) { return tokenRef(ID, label, null); } public List<SrcOp> stringRef(GrammarAST ID, GrammarAST label) { return tokenRef(ID, label, null); }
@Override
public List<SrcOp> set(GrammarAST setAST, GrammarAST label, boolean invert) { return null; } public List<SrcOp> set(GrammarAST setAST, GrammarAST label, boolean invert) { return null; }
@Override
public List<SrcOp> wildcard(GrammarAST ast, GrammarAST labelAST) { return null; } public List<SrcOp> wildcard(GrammarAST ast, GrammarAST labelAST) { return null; }
// ACTIONS // ACTIONS
@Override
public List<SrcOp> action(GrammarAST ast) { return null; } public List<SrcOp> action(GrammarAST ast) { return null; }
@Override
public List<SrcOp> forcedAction(GrammarAST ast) { return null; } public List<SrcOp> forcedAction(GrammarAST ast) { return null; }
@Override
public List<SrcOp> sempred(GrammarAST ast) { return null; } public List<SrcOp> sempred(GrammarAST ast) { return null; }
// BLOCKS // BLOCKS
@Override
public Choice getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST label) { return null; } public Choice getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST label) { return null; }
@Override
public Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { return null; } public Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { return null; }
@Override
public Choice getLL1ChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) { return null; } public Choice getLL1ChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) { return null; }
@Override
public Choice getComplexChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) { return null; } public Choice getComplexChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) { return null; }
@Override
public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { return null; } public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { return null; }
@Override
public Choice getComplexEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { return null; } public Choice getComplexEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { return null; }
@Override
public List<SrcOp> getLL1Test(IntervalSet look, GrammarAST blkAST) { return null; } public List<SrcOp> getLL1Test(IntervalSet look, GrammarAST blkAST) { return null; }
@Override
public boolean needsImplicitLabel(GrammarAST ID, LabeledOp op) { return false; } public boolean needsImplicitLabel(GrammarAST ID, LabeledOp op) { return false; }
} }

View File

@ -68,6 +68,7 @@ public abstract class DefaultOutputModelFactory extends BlankOutputModelFactory
// Convenience methods // Convenience methods
@NotNull @NotNull
@Override
public Grammar getGrammar() { return g; } public Grammar getGrammar() { return g; }
@Override @Override

View File

@ -44,14 +44,17 @@ import java.util.List;
public class ParserFactory extends DefaultOutputModelFactory { public class ParserFactory extends DefaultOutputModelFactory {
public ParserFactory(CodeGenerator gen) { super(gen); } public ParserFactory(CodeGenerator gen) { super(gen); }
@Override
public ParserFile parserFile(String fileName) { public ParserFile parserFile(String fileName) {
return new ParserFile(this, fileName); return new ParserFile(this, fileName);
} }
@Override
public Parser parser(ParserFile file) { public Parser parser(ParserFile file) {
return new Parser(this, file); return new Parser(this, file);
} }
@Override
public RuleFunction rule(Rule r) { public RuleFunction rule(Rule r) {
if ( r instanceof LeftRecursiveRule ) { if ( r instanceof LeftRecursiveRule ) {
return new LeftRecursiveRuleFunction(this, (LeftRecursiveRule)r); return new LeftRecursiveRuleFunction(this, (LeftRecursiveRule)r);
@ -62,10 +65,12 @@ public class ParserFactory extends DefaultOutputModelFactory {
} }
} }
@Override
public CodeBlockForAlt epsilon(Alternative alt, boolean outerMost) { public CodeBlockForAlt epsilon(Alternative alt, boolean outerMost) {
return alternative(alt, outerMost); return alternative(alt, outerMost);
} }
@Override
public CodeBlockForAlt alternative(Alternative alt, boolean outerMost) { public CodeBlockForAlt alternative(Alternative alt, boolean outerMost) {
if ( outerMost ) return new CodeBlockForOuterMostAlt(this, alt); if ( outerMost ) return new CodeBlockForOuterMostAlt(this, alt);
return new CodeBlockForAlt(this); return new CodeBlockForAlt(this);
@ -77,10 +82,13 @@ public class ParserFactory extends DefaultOutputModelFactory {
return blk; return blk;
} }
@Override
public List<SrcOp> action(GrammarAST ast) { return list(new Action(this, ast)); } public List<SrcOp> action(GrammarAST ast) { return list(new Action(this, ast)); }
@Override
public List<SrcOp> sempred(GrammarAST ast) { return list(new SemPred(this, ast)); } public List<SrcOp> sempred(GrammarAST ast) { return list(new SemPred(this, ast)); }
@Override
public List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { public List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) {
InvokeRule invokeOp = new InvokeRule(this, ID, label); InvokeRule invokeOp = new InvokeRule(this, ID, label);
// If no manual label and action refs as token/rule not label, we need to define implicit label // If no manual label and action refs as token/rule not label, we need to define implicit label
@ -89,6 +97,7 @@ public class ParserFactory extends DefaultOutputModelFactory {
return list(invokeOp, listLabelOp); return list(invokeOp, listLabelOp);
} }
@Override
public List<SrcOp> tokenRef(GrammarAST ID, GrammarAST labelAST, GrammarAST args) { public List<SrcOp> tokenRef(GrammarAST ID, GrammarAST labelAST, GrammarAST args) {
LabeledOp matchOp = new MatchToken(this, (TerminalAST) ID); LabeledOp matchOp = new MatchToken(this, (TerminalAST) ID);
if ( labelAST!=null ) { if ( labelAST!=null ) {
@ -166,6 +175,7 @@ public class ParserFactory extends DefaultOutputModelFactory {
return list(wild, listLabelOp); return list(wild, listLabelOp);
} }
@Override
public Choice getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST labelAST) { public Choice getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST labelAST) {
int decision = ((DecisionState)blkAST.atnState).decision; int decision = ((DecisionState)blkAST.atnState).decision;
Choice c; Choice c;
@ -191,6 +201,7 @@ public class ParserFactory extends DefaultOutputModelFactory {
return c; return c;
} }
@Override
public Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { public Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) {
if (!g.tool.force_atn) { if (!g.tool.force_atn) {
int decision; int decision;
@ -212,14 +223,17 @@ public class ParserFactory extends DefaultOutputModelFactory {
return getComplexEBNFBlock(ebnfRoot, alts); return getComplexEBNFBlock(ebnfRoot, alts);
} }
@Override
public Choice getLL1ChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) { public Choice getLL1ChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) {
return new LL1AltBlock(this, blkAST, alts); return new LL1AltBlock(this, blkAST, alts);
} }
@Override
public Choice getComplexChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) { public Choice getComplexChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts) {
return new AltBlock(this, blkAST, alts); return new AltBlock(this, blkAST, alts);
} }
@Override
public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) {
int ebnf = 0; int ebnf = 0;
if ( ebnfRoot!=null ) ebnf = ebnfRoot.getType(); if ( ebnfRoot!=null ) ebnf = ebnfRoot.getType();
@ -241,6 +255,7 @@ public class ParserFactory extends DefaultOutputModelFactory {
return c; return c;
} }
@Override
public Choice getComplexEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) { public Choice getComplexEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) {
int ebnf = 0; int ebnf = 0;
if ( ebnfRoot!=null ) ebnf = ebnfRoot.getType(); if ( ebnfRoot!=null ) ebnf = ebnfRoot.getType();
@ -259,10 +274,12 @@ public class ParserFactory extends DefaultOutputModelFactory {
return c; return c;
} }
@Override
public List<SrcOp> getLL1Test(IntervalSet look, GrammarAST blkAST) { public List<SrcOp> getLL1Test(IntervalSet look, GrammarAST blkAST) {
return list(new TestSetInline(this, blkAST, look)); return list(new TestSetInline(this, blkAST, look));
} }
@Override
public boolean needsImplicitLabel(GrammarAST ID, LabeledOp op) { public boolean needsImplicitLabel(GrammarAST ID, LabeledOp op) {
Alternative currentOuterMostAlt = getCurrentOuterMostAlt(); Alternative currentOuterMostAlt = getCurrentOuterMostAlt();
boolean actionRefsAsToken = currentOuterMostAlt.tokenRefsInActions.containsKey(ID.getText()); boolean actionRefsAsToken = currentOuterMostAlt.tokenRefsInActions.containsKey(ID.getText());

View File

@ -91,6 +91,7 @@ public class InvokeRule extends RuleElement implements LabeledOp {
} }
} }
@Override
public List<Decl> getLabels() { public List<Decl> getLabels() {
return labels.elements(); return labels.elements();
} }

View File

@ -57,5 +57,6 @@ public class MatchToken extends RuleElement implements LabeledOp {
super(factory, ast); super(factory, ast);
} }
@Override
public List<Decl> getLabels() { return labels; } public List<Decl> getLabels() { return labels; }
} }

View File

@ -48,6 +48,7 @@ public class Graph {
if ( !edges.contains(n) ) edges.add(n); if ( !edges.contains(n) ) edges.add(n);
} }
@Override
public String toString() { return payload.toString(); } public String toString() { return payload.toString(); }
} }

View File

@ -42,6 +42,7 @@ public class GrammarASTAdaptor extends CommonTreeAdaptor {
public GrammarASTAdaptor() { ; } public GrammarASTAdaptor() { ; }
public GrammarASTAdaptor(org.antlr.runtime.CharStream input) { this.input = input; } public GrammarASTAdaptor(org.antlr.runtime.CharStream input) { this.input = input; }
@Override
public Object create(Token token) { public Object create(Token token) {
return new GrammarAST(token); return new GrammarAST(token);
} }
@ -66,11 +67,13 @@ public class GrammarASTAdaptor extends CommonTreeAdaptor {
return t; return t;
} }
@Override
public Object dupNode(Object t) { public Object dupNode(Object t) {
if ( t==null ) return null; if ( t==null ) return null;
return ((GrammarAST)t).dupNode(); //create(((GrammarAST)t).token); return ((GrammarAST)t).dupNode(); //create(((GrammarAST)t).token);
} }
@Override
public Object errorNode(org.antlr.runtime.TokenStream input, org.antlr.runtime.Token start, org.antlr.runtime.Token stop, public Object errorNode(org.antlr.runtime.TokenStream input, org.antlr.runtime.Token start, org.antlr.runtime.Token stop,
org.antlr.runtime.RecognitionException e) org.antlr.runtime.RecognitionException e)
{ {

View File

@ -44,6 +44,7 @@ public class ToolANTLRParser extends ANTLRParser {
this.tool = tool; this.tool = tool;
} }
@Override
public void displayRecognitionError(String[] tokenNames, public void displayRecognitionError(String[] tokenNames,
RecognitionException e) RecognitionException e)
{ {

View File

@ -101,12 +101,14 @@ public class AttributeChecks implements ActionSplitterListener {
// LISTENER METHODS // LISTENER METHODS
@Override
public void setQualifiedAttr(String expr, Token x, Token y, Token rhs) { public void setQualifiedAttr(String expr, Token x, Token y, Token rhs) {
qualifiedAttr(expr, x, y); qualifiedAttr(expr, x, y);
new AttributeChecks(g, r, alt, node, rhs).examineAction(); new AttributeChecks(g, r, alt, node, rhs).examineAction();
} }
// $x.y // $x.y
@Override
public void qualifiedAttr(String expr, Token x, Token y) { public void qualifiedAttr(String expr, Token x, Token y) {
if ( node.resolver.resolveToAttribute(x.getText(), y.getText(), node)==null ) { if ( node.resolver.resolveToAttribute(x.getText(), y.getText(), node)==null ) {
Rule rref = isolatedRuleRef(x.getText()); Rule rref = isolatedRuleRef(x.getText());
@ -131,6 +133,7 @@ public class AttributeChecks implements ActionSplitterListener {
} }
} }
@Override
public void setAttr(String expr, Token x, Token rhs) { public void setAttr(String expr, Token x, Token rhs) {
if ( node.resolver.resolveToAttribute(x.getText(), node)==null ) { if ( node.resolver.resolveToAttribute(x.getText(), node)==null ) {
errMgr.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE, errMgr.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE,
@ -139,6 +142,7 @@ public class AttributeChecks implements ActionSplitterListener {
new AttributeChecks(g, r, alt, node, rhs).examineAction(); new AttributeChecks(g, r, alt, node, rhs).examineAction();
} }
@Override
public void attr(String expr, Token x) { public void attr(String expr, Token x) {
if ( node.resolver.resolveToAttribute(x.getText(), node)==null ) { if ( node.resolver.resolveToAttribute(x.getText(), node)==null ) {
if ( node.resolver.resolvesToToken(x.getText(), node) ) { if ( node.resolver.resolvesToToken(x.getText(), node) ) {
@ -157,6 +161,7 @@ public class AttributeChecks implements ActionSplitterListener {
} }
} }
@Override
public void nonLocalAttr(String expr, Token x, Token y) { public void nonLocalAttr(String expr, Token x, Token y) {
Rule r = g.getRule(x.getText()); Rule r = g.getRule(x.getText());
if ( r==null ) { if ( r==null ) {
@ -170,6 +175,7 @@ public class AttributeChecks implements ActionSplitterListener {
} }
} }
@Override
public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) { public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) {
Rule r = g.getRule(x.getText()); Rule r = g.getRule(x.getText());
if ( r==null ) { if ( r==null ) {
@ -183,11 +189,13 @@ public class AttributeChecks implements ActionSplitterListener {
} }
} }
@Override
public void unknownSyntax(Token t) { public void unknownSyntax(Token t) {
errMgr.grammarError(ErrorType.INVALID_TEMPLATE_ACTION, errMgr.grammarError(ErrorType.INVALID_TEMPLATE_ACTION,
g.fileName, t, t.getText()); g.fileName, t, t.getText());
} }
@Override
public void text(String text) { } public void text(String text) { }
// don't care // don't care

View File

@ -33,24 +33,30 @@ import org.antlr.runtime.Token;
import org.antlr.v4.parse.ActionSplitterListener; import org.antlr.v4.parse.ActionSplitterListener;
public class BlankActionSplitterListener implements ActionSplitterListener { public class BlankActionSplitterListener implements ActionSplitterListener {
@Override
public void setQualifiedAttr(String expr, Token x, Token y, Token rhs) { public void setQualifiedAttr(String expr, Token x, Token y, Token rhs) {
} }
@Override
public void qualifiedAttr(String expr, Token x, Token y) { public void qualifiedAttr(String expr, Token x, Token y) {
} }
@Override
public void setAttr(String expr, Token x, Token rhs) { public void setAttr(String expr, Token x, Token rhs) {
} }
@Override
public void attr(String expr, Token x) { public void attr(String expr, Token x) {
} }
public void templateInstance(String expr) { public void templateInstance(String expr) {
} }
@Override
public void nonLocalAttr(String expr, Token x, Token y) { public void nonLocalAttr(String expr, Token x, Token y) {
} }
@Override
public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) { public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) {
} }
@ -66,9 +72,11 @@ public class BlankActionSplitterListener implements ActionSplitterListener {
public void templateExpr(String expr) { public void templateExpr(String expr) {
} }
@Override
public void unknownSyntax(Token t) { public void unknownSyntax(Token t) {
} }
@Override
public void text(String text) { public void text(String text) {
} }
} }

View File

@ -77,6 +77,7 @@ public class Alternative implements AttributeResolver {
public Alternative(Rule r, int altNum) { this.rule = r; this.altNum = altNum; } public Alternative(Rule r, int altNum) { this.rule = r; this.altNum = altNum; }
@Override
public boolean resolvesToToken(String x, ActionAST node) { public boolean resolvesToToken(String x, ActionAST node) {
if ( tokenRefs.get(x)!=null ) return true; if ( tokenRefs.get(x)!=null ) return true;
LabelElementPair anyLabelDef = getAnyLabelDef(x); LabelElementPair anyLabelDef = getAnyLabelDef(x);
@ -84,6 +85,7 @@ public class Alternative implements AttributeResolver {
return false; return false;
} }
@Override
public boolean resolvesToAttributeDict(String x, ActionAST node) { public boolean resolvesToAttributeDict(String x, ActionAST node) {
if ( resolvesToToken(x, node) ) return true; if ( resolvesToToken(x, node) ) return true;
if ( ruleRefs.get(x)!=null ) return true; // rule ref in this alt? if ( ruleRefs.get(x)!=null ) return true; // rule ref in this alt?
@ -95,6 +97,7 @@ public class Alternative implements AttributeResolver {
/** $x Attribute: rule arguments, return values, predefined rule prop. /** $x Attribute: rule arguments, return values, predefined rule prop.
*/ */
@Override
public Attribute resolveToAttribute(String x, ActionAST node) { public Attribute resolveToAttribute(String x, ActionAST node) {
return rule.resolveToAttribute(x, node); // reuse that code return rule.resolveToAttribute(x, node); // reuse that code
} }
@ -102,6 +105,7 @@ public class Alternative implements AttributeResolver {
/** $x.y, x can be surrounding rule, token/rule/label ref. y is visible /** $x.y, x can be surrounding rule, token/rule/label ref. y is visible
* attr in that dictionary. Can't see args on rule refs. * attr in that dictionary. Can't see args on rule refs.
*/ */
@Override
public Attribute resolveToAttribute(String x, String y, ActionAST node) { public Attribute resolveToAttribute(String x, String y, ActionAST node) {
if ( rule.name.equals(x) ) { // x is this rule? if ( rule.name.equals(x) ) { // x is this rule?
return rule.resolveToAttribute(x, y, node); return rule.resolveToAttribute(x, y, node);
@ -123,6 +127,7 @@ public class Alternative implements AttributeResolver {
return null; return null;
} }
@Override
public boolean resolvesToLabel(String x, ActionAST node) { public boolean resolvesToLabel(String x, ActionAST node) {
LabelElementPair anyLabelDef = getAnyLabelDef(x); LabelElementPair anyLabelDef = getAnyLabelDef(x);
return anyLabelDef!=null && return anyLabelDef!=null &&
@ -130,6 +135,7 @@ public class Alternative implements AttributeResolver {
anyLabelDef.type==LabelType.RULE_LABEL); anyLabelDef.type==LabelType.RULE_LABEL);
} }
@Override
public boolean resolvesToListLabel(String x, ActionAST node) { public boolean resolvesToListLabel(String x, ActionAST node) {
LabelElementPair anyLabelDef = getAnyLabelDef(x); LabelElementPair anyLabelDef = getAnyLabelDef(x);
return anyLabelDef!=null && return anyLabelDef!=null &&

View File

@ -57,6 +57,7 @@ public class Attribute {
this.decl = decl; this.decl = decl;
} }
@Override
public String toString() { public String toString() {
if ( initValue!=null ) { if ( initValue!=null ) {
return type+" "+name+"="+initValue; return type+" "+name+"="+initValue;

View File

@ -106,6 +106,7 @@ public class AttributeDict {
return inter; return inter;
} }
@Override
public String toString() { public String toString() {
return getName()+":"+attributes; return getName()+":"+attributes;
} }

View File

@ -38,6 +38,7 @@ public class DefaultToolListener implements ANTLRToolListener {
public DefaultToolListener(Tool tool) { this.tool = tool; } public DefaultToolListener(Tool tool) { this.tool = tool; }
@Override
public void info(String msg) { public void info(String msg) {
if (tool.errMgr.formatWantsSingleLineMessage()) { if (tool.errMgr.formatWantsSingleLineMessage()) {
msg = msg.replaceAll("\n", " "); msg = msg.replaceAll("\n", " ");
@ -45,6 +46,7 @@ public class DefaultToolListener implements ANTLRToolListener {
System.out.println(msg); System.out.println(msg);
} }
@Override
public void error(ANTLRMessage msg) { public void error(ANTLRMessage msg) {
ST msgST = tool.errMgr.getMessageTemplate(msg); ST msgST = tool.errMgr.getMessageTemplate(msg);
String outputMsg = msgST.render(); String outputMsg = msgST.render();
@ -54,6 +56,7 @@ public class DefaultToolListener implements ANTLRToolListener {
System.err.println(outputMsg); System.err.println(outputMsg);
} }
@Override
public void warning(ANTLRMessage msg) { public void warning(ANTLRMessage msg) {
ST msgST = tool.errMgr.getMessageTemplate(msg); ST msgST = tool.errMgr.getMessageTemplate(msg);
String outputMsg = msgST.render(); String outputMsg = msgST.render();

View File

@ -59,18 +59,22 @@ public class ErrorManager {
STErrorListener theDefaultSTListener = STErrorListener theDefaultSTListener =
new STErrorListener() { new STErrorListener() {
@Override
public void compileTimeError(STMessage msg) { public void compileTimeError(STMessage msg) {
ErrorManager.internalError(msg.toString()); ErrorManager.internalError(msg.toString());
} }
@Override
public void runTimeError(STMessage msg) { public void runTimeError(STMessage msg) {
ErrorManager.internalError(msg.toString()); ErrorManager.internalError(msg.toString());
} }
@Override
public void IOError(STMessage msg) { public void IOError(STMessage msg) {
ErrorManager.internalError(msg.toString()); ErrorManager.internalError(msg.toString());
} }
@Override
public void internalError(STMessage msg) { public void internalError(STMessage msg) {
ErrorManager.internalError(msg.toString()); ErrorManager.internalError(msg.toString());
} }

View File

@ -202,7 +202,9 @@ public class Grammar implements AttributeResolver {
final Grammar thiz = this; final Grammar thiz = this;
TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor()); TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor());
v.visit(ast, new TreeVisitorAction() { v.visit(ast, new TreeVisitorAction() {
@Override
public Object pre(Object t) { ((GrammarAST)t).g = thiz; return t; } public Object pre(Object t) { ((GrammarAST)t).g = thiz; return t; }
@Override
public Object post(Object t) { return t; } public Object post(Object t) { return t; }
}); });
initTokenSymbolTables(); initTokenSymbolTables();
@ -603,21 +605,27 @@ public class Grammar implements AttributeResolver {
} }
// no isolated attr at grammar action level // no isolated attr at grammar action level
@Override
public Attribute resolveToAttribute(String x, ActionAST node) { public Attribute resolveToAttribute(String x, ActionAST node) {
return null; return null;
} }
// no $x.y makes sense here // no $x.y makes sense here
@Override
public Attribute resolveToAttribute(String x, String y, ActionAST node) { public Attribute resolveToAttribute(String x, String y, ActionAST node) {
return null; return null;
} }
@Override
public boolean resolvesToLabel(String x, ActionAST node) { return false; } public boolean resolvesToLabel(String x, ActionAST node) { return false; }
@Override
public boolean resolvesToListLabel(String x, ActionAST node) { return false; } public boolean resolvesToListLabel(String x, ActionAST node) { return false; }
@Override
public boolean resolvesToToken(String x, ActionAST node) { return false; } public boolean resolvesToToken(String x, ActionAST node) { return false; }
@Override
public boolean resolvesToAttributeDict(String x, ActionAST node) { public boolean resolvesToAttributeDict(String x, ActionAST node) {
return false; return false;
} }

View File

@ -84,12 +84,14 @@ public class GrammarTransformPipeline {
public void expandParameterizedLoops(GrammarAST root) { public void expandParameterizedLoops(GrammarAST root) {
TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor()); TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor());
v.visit(root, new TreeVisitorAction() { v.visit(root, new TreeVisitorAction() {
@Override
public Object pre(Object t) { public Object pre(Object t) {
if ( ((GrammarAST)t).getType() == 3 ) { if ( ((GrammarAST)t).getType() == 3 ) {
return expandParameterizedLoop((GrammarAST)t); return expandParameterizedLoop((GrammarAST)t);
} }
return t; return t;
} }
@Override
public Object post(Object t) { return t; } public Object post(Object t) { return t; }
}); });
} }
@ -104,7 +106,9 @@ public class GrammarTransformPipeline {
// ensure each node has pointer to surrounding grammar // ensure each node has pointer to surrounding grammar
TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor()); TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor());
v.visit(tree, new TreeVisitorAction() { v.visit(tree, new TreeVisitorAction() {
@Override
public Object pre(Object t) { ((GrammarAST)t).g = g; return t; } public Object pre(Object t) { ((GrammarAST)t).g = g; return t; }
@Override
public Object post(Object t) { return t; } public Object post(Object t) { return t; }
}); });
} }

View File

@ -66,6 +66,7 @@ public class LabelElementPair {
} }
} }
@Override
public String toString() { public String toString() {
return label.getText()+" "+type+" "+element.toString(); return label.getText()+" "+type+" "+element.toString();
} }

View File

@ -233,6 +233,7 @@ public class Rule implements AttributeResolver {
/** $x Attribute: rule arguments, return values, predefined rule prop. /** $x Attribute: rule arguments, return values, predefined rule prop.
*/ */
@Override
public Attribute resolveToAttribute(String x, ActionAST node) { public Attribute resolveToAttribute(String x, ActionAST node) {
if ( args!=null ) { if ( args!=null ) {
Attribute a = args.get(x); if ( a!=null ) return a; Attribute a = args.get(x); if ( a!=null ) return a;
@ -248,6 +249,7 @@ public class Rule implements AttributeResolver {
} }
/** $x.y Attribute: x is surrounding rule, label ref (in any alts) */ /** $x.y Attribute: x is surrounding rule, label ref (in any alts) */
@Override
public Attribute resolveToAttribute(String x, String y, ActionAST node) { public Attribute resolveToAttribute(String x, String y, ActionAST node) {
if ( this.name.equals(x) ) { // x is this rule? if ( this.name.equals(x) ) { // x is this rule?
return resolveToAttribute(y, node); return resolveToAttribute(y, node);
@ -265,6 +267,7 @@ public class Rule implements AttributeResolver {
} }
@Override
public boolean resolvesToLabel(String x, ActionAST node) { public boolean resolvesToLabel(String x, ActionAST node) {
LabelElementPair anyLabelDef = getAnyLabelDef(x); LabelElementPair anyLabelDef = getAnyLabelDef(x);
return anyLabelDef!=null && return anyLabelDef!=null &&
@ -272,6 +275,7 @@ public class Rule implements AttributeResolver {
anyLabelDef.type==LabelType.TOKEN_LABEL); anyLabelDef.type==LabelType.TOKEN_LABEL);
} }
@Override
public boolean resolvesToListLabel(String x, ActionAST node) { public boolean resolvesToListLabel(String x, ActionAST node) {
LabelElementPair anyLabelDef = getAnyLabelDef(x); LabelElementPair anyLabelDef = getAnyLabelDef(x);
return anyLabelDef!=null && return anyLabelDef!=null &&
@ -279,12 +283,14 @@ public class Rule implements AttributeResolver {
anyLabelDef.type==LabelType.TOKEN_LIST_LABEL); anyLabelDef.type==LabelType.TOKEN_LIST_LABEL);
} }
@Override
public boolean resolvesToToken(String x, ActionAST node) { public boolean resolvesToToken(String x, ActionAST node) {
LabelElementPair anyLabelDef = getAnyLabelDef(x); LabelElementPair anyLabelDef = getAnyLabelDef(x);
if ( anyLabelDef!=null && anyLabelDef.type==LabelType.TOKEN_LABEL ) return true; if ( anyLabelDef!=null && anyLabelDef.type==LabelType.TOKEN_LABEL ) return true;
return false; return false;
} }
@Override
public boolean resolvesToAttributeDict(String x, ActionAST node) { public boolean resolvesToAttributeDict(String x, ActionAST node) {
if ( resolvesToToken(x, node) ) return true; if ( resolvesToToken(x, node) ) return true;
if ( x.equals(name) ) return true; // $r for action in rule r, $r is a dict if ( x.equals(name) ) return true; // $r for action in rule r, $r is a dict

View File

@ -42,10 +42,14 @@ public class GrammarASTErrorNode extends GrammarAST {
delegate = new CommonErrorNode(input,start,stop,e); delegate = new CommonErrorNode(input,start,stop,e);
} }
@Override
public boolean isNil() { return delegate.isNil(); } public boolean isNil() { return delegate.isNil(); }
@Override
public int getType() { return delegate.getType(); } public int getType() { return delegate.getType(); }
@Override
public String getText() { return delegate.getText(); } public String getText() { return delegate.getText(); }
@Override
public String toString() { return delegate.toString(); } public String toString() { return delegate.toString(); }
} }

View File

@ -58,6 +58,7 @@ public class LexerInterpreter implements TokenSource {
this.input = input; this.input = input;
} }
@Override
public String getSourceName() { return g.name; } public String getSourceName() { return g.name; }
@Override @Override
@ -65,18 +66,22 @@ public class LexerInterpreter implements TokenSource {
// TODO: use TokenFactory // TODO: use TokenFactory
} }
@Override
public int getCharPositionInLine() { public int getCharPositionInLine() {
return 0; return 0;
} }
@Override
public int getLine() { public int getLine() {
return 0; return 0;
} }
@Override
public CharStream getInputStream() { public CharStream getInputStream() {
return input; return input;
} }
@Override
public Token nextToken() { public Token nextToken() {
// TODO: Deal with off channel tokens // TODO: Deal with off channel tokens
int start = input.index(); int start = input.index();

View File

@ -43,15 +43,18 @@ public class ErrorQueue implements ANTLRToolListener {
public List<ANTLRMessage> warnings = new ArrayList<ANTLRMessage>(); public List<ANTLRMessage> warnings = new ArrayList<ANTLRMessage>();
public List<ANTLRMessage> all = new ArrayList<ANTLRMessage>(); public List<ANTLRMessage> all = new ArrayList<ANTLRMessage>();
@Override
public void info(String msg) { public void info(String msg) {
infos.add(msg); infos.add(msg);
} }
@Override
public void error(ANTLRMessage msg) { public void error(ANTLRMessage msg) {
errors.add(msg); errors.add(msg);
all.add(msg); all.add(msg);
} }
@Override
public void warning(ANTLRMessage msg) { public void warning(ANTLRMessage msg) {
warnings.add(msg); warnings.add(msg);
all.add(msg); all.add(msg);
@ -66,6 +69,7 @@ public class ErrorQueue implements ANTLRToolListener {
return all.size() + infos.size(); return all.size() + infos.size();
} }
@Override
public String toString() { return Utils.join(all.iterator(), "\n"); } public String toString() { return Utils.join(all.iterator(), "\n"); }
public String toString(Tool tool) { public String toString(Tool tool) {

View File

@ -189,16 +189,21 @@ public class TestCommonTokenStream extends BaseTest {
new CommonToken(1,"\n") {{channel = Lexer.HIDDEN;}}, new CommonToken(1,"\n") {{channel = Lexer.HIDDEN;}},
new CommonToken(Token.EOF,"") new CommonToken(Token.EOF,"")
}; };
@Override
public Token nextToken() { public Token nextToken() {
return tokens[i++]; return tokens[i++];
} }
@Override
public String getSourceName() { return "test"; } public String getSourceName() { return "test"; }
@Override
public int getCharPositionInLine() { public int getCharPositionInLine() {
return 0; return 0;
} }
@Override
public int getLine() { public int getLine() {
return 0; return 0;
} }
@Override
public CharStream getInputStream() { public CharStream getInputStream() {
return null; return null;
} }