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