1 package org.antlr.works.syntax.element; 2 3 import org.antlr.works.ate.syntax.misc.ATEToken; 4 5 import java.util.ArrayList ; 6 import java.util.List ; 7 37 38 public class ElementGrammarName { 39 40 public static final List <String > types; 41 42 public static final int COMBINED = 0; 43 public static final int PARSER = 1; 44 public static final int LEXER = 2; 45 public static final int TREEPARSER = 3; 46 47 public ATEToken name; 48 public ATEToken start; 49 public ATEToken end; 50 public ATEToken type; 51 52 static { 53 types = new ArrayList <String >(); 54 types.add("combined"); 55 types.add("parser"); 56 types.add("lexer"); 57 types.add("tree"); 58 } 59 60 public ElementGrammarName(ATEToken name, ATEToken start, ATEToken end, ATEToken type) { 61 this.name = name; 62 this.start = type==null?start:type; 63 this.end = end; 64 this.type = type; 65 } 66 67 public int getType() { 68 int t = COMBINED; 69 if(type != null) { 70 t = types.indexOf(type.getAttribute()); 71 } 72 73 if(t == -1) { 74 return COMBINED; 75 } else { 76 return t; 77 } 78 } 79 80 public String getName() { 81 return name.getAttribute(); 82 } 83 84 public static boolean isKnownType(String type) { 85 return types.contains(type); 86 } 87 88 } 89 | Popular Tags |