1 package antlr;
2
3 * <b>SOFTWARE RIGHTS</b>
5 * <p>
6 * ANTLR 2.5.0 MageLang Institute, 1998
7 * <p>
8 * We reserve no legal rights to the ANTLR--it is fully in the
9 * public domain. An individual or company may do whatever
10 * they wish with source code distributed with ANTLR or the
11 * code generated by ANTLR, including the incorporation of
12 * ANTLR, or its output, into commerical software.
13 * <p>
14 * We encourage users to develop software with ANTLR. However,
15 * we do ask that credit is given to us for developing
16 * ANTLR. By "credit", we mean that if you use ANTLR or
17 * incorporate any source code into one of your programs
18 * (commercial product, research project, or otherwise) that
19 * you acknowledge this fact somewhere in the documentation,
20 * research report, etc... If you like ANTLR and have
21 * developed a nice tool with the output, please mention that
22 * you developed it using ANTLR. In addition, we ask that the
23 * headers remain intact in our source code. As long as these
24 * guidelines are kept, we expect to continue enhancing this
25 * system and expect to make other tools available as they are
26 * completed.
27 * <p>
28 * The ANTLR gang:
29 * @version ANTLR 2.5.0 MageLang Institute, 1998
30 * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
31 * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
32 */
33 import java.util.Hashtable;
34 import java.util.Enumeration;
35 import java.io.IOException;
36 import antlr.collections.impl.BitSet;
37 import antlr.collections.impl.Vector;
38
39
40
41 class TreeWalkerGrammar extends Grammar {
42 protected boolean transform = false;
44
45
46 TreeWalkerGrammar(String className_, Tool tool_, String superClass) {
47 super(className_, tool_, superClass);
48 }
49
50 public void generate() throws IOException {
51 generator.gen(this);
52 }
53 protected String getSuperClass() { return "TreeParser"; }
55 * -trace have all rules call traceIn/traceOut
57 * -traceParser have parser rules call traceIn/traceOut
58 * -debug generate debugging output for parser debugger
59 */
60 public void processArguments(String[] args) {
61 for (int i=0; i<args.length; i++) {
62 if ( args[i].equals("-trace") ) {
63 traceRules = true;
64 Tool.setArgOK(i);
65 }
66 else if ( args[i].equals("-traceTreeParser") ) {
67 traceRules = true;
68 Tool.setArgOK(i);
69 }
70 }
76 }
77 * "k" -- set lookahead depth
79 * "lexer" -- set associated lexer class
80 * "tokdef" -- open a token definitions file
81 */
82 public boolean setOption(String key, Token value) {
83 if (key.equals("buildAST")) {
84 if (value.getText().equals("true")) {
85 buildAST = true;
86 } else if (value.getText().equals("false")) {
87 buildAST = false;
88 } else {
89 tool.error("buildAST option must be true or false", value.getLine());
90 }
91 return true;
92 }
93 if (key.equals("transform")) {
95 if (value.getText().equals("true")) {
96 transform = true;
97 return true;
98 }
99 else if (value.getText().equals("false")) {
100 transform = false;
101 return true;
102 }
103 else {
104 tool.error("Value for transform option must be true or false", value.getLine());
105 return false;
106 }
107 }
108 */
109 if (key.equals("ASTLabelType")) {
110 super.setOption(key, value);
111 return true;
112 }
113 if (super.setOption(key, value)) {
114 return true;
115 }
116 tool.error("Invalid option: " + key, value.getLine());
117 return false;
118 }
119 }
120