1 package persistence.antlr; 2 3 8 9 import java.util.Hashtable ; 10 import java.util.Enumeration ; 11 import java.io.IOException ; 12 13 import persistence.antlr.collections.impl.BitSet; 14 import persistence.antlr.collections.impl.Vector; 15 16 17 18 class TreeWalkerGrammar extends Grammar { 19 protected boolean transform = false; 21 22 23 TreeWalkerGrammar(String className_, Tool tool_, String superClass) { 24 super(className_, tool_, superClass); 25 } 26 27 28 public void generate() throws IOException { 29 generator.gen(this); 30 } 31 32 protected String getSuperClass() { 34 return "TreeParser"; 35 } 36 37 42 public void processArguments(String [] args) { 43 for (int i = 0; i < args.length; i++) { 44 if (args[i].equals("-trace")) { 45 traceRules = true; 46 antlrTool.setArgOK(i); 47 } 48 else if (args[i].equals("-traceTreeParser")) { 49 traceRules = true; 50 antlrTool.setArgOK(i); 51 } 52 } 58 } 59 60 61 public boolean setOption(String key, Token value) { 62 if (key.equals("buildAST")) { 63 if (value.getText().equals("true")) { 64 buildAST = true; 65 } 66 else if (value.getText().equals("false")) { 67 buildAST = false; 68 } 69 else { 70 antlrTool.error("buildAST option must be true or false", getFilename(), value.getLine(), value.getColumn()); 71 } 72 return true; 73 } 74 if (key.equals("ASTLabelType")) { 75 super.setOption(key, value); 76 return true; 77 } 78 if (super.setOption(key, value)) { 79 return true; 80 } 81 antlrTool.error("Invalid option: " + key, getFilename(), value.getLine(), value.getColumn()); 82 return false; 83 } 84 } 85 | Popular Tags |