1 package antlr; 2 3 9 10 13 abstract class GrammarAtom extends AlternativeElement { 14 protected String label; 15 protected String atomText; 16 protected int tokenType = Token.INVALID_TYPE; 17 protected boolean not = false; 21 protected String ASTNodeType = null; 22 23 public GrammarAtom(Grammar g, Token t, int autoGenType) { 24 super(g, t, autoGenType); 25 atomText = t.getText(); 26 } 27 28 public String getLabel() { 29 return label; 30 } 31 32 public String getText() { 33 return atomText; 34 } 35 36 public int getType() { 37 return tokenType; 38 } 39 40 public void setLabel(String label_) { 41 label = label_; 42 } 43 44 public String getASTNodeType() { 45 return ASTNodeType; 46 } 47 48 public void setASTNodeType(String type) { 49 ASTNodeType = type; 50 } 51 52 public void setOption(Token option, Token value) { 53 if (option.getText().equals("AST")) { 54 setASTNodeType(value.getText()); 55 } 56 else { 57 grammar.antlrTool.error("Invalid element option:" + option.getText(), 58 grammar.getFilename(), option.getLine(), option.getColumn()); 59 } 60 } 61 62 public String toString() { 63 String s = " "; 64 if (label != null) s += label + ":"; 65 if (not) s += "~"; 66 return s + atomText; 67 } 68 } 69 | Popular Tags |