01: package antlr;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.cs.usfca.edu
05: * Software rights: http://www.antlr.org/license.html
06: */
07:
08: /**A GrammarElement is a generic node in our
09: * data structure that holds a grammar in memory.
10: * This data structure can be used for static
11: * analysis or for dynamic analysis (during parsing).
12: * Every node must know which grammar owns it, how
13: * to generate code, and how to do analysis.
14: */
15: abstract class GrammarElement {
16: public static final int AUTO_GEN_NONE = 1;
17: public static final int AUTO_GEN_CARET = 2;
18: public static final int AUTO_GEN_BANG = 3;
19:
20: /*
21: * Note that Java does static argument type matching to
22: * determine which function to execute on the receiver.
23: * Here, that implies that we cannot simply say
24: * grammar.generator.gen(this) in GrammarElement or
25: * only CodeGenerator.gen(GrammarElement ge) would
26: * ever be called.
27: */
28: protected Grammar grammar;
29: protected int line;
30: protected int column;
31:
32: public GrammarElement(Grammar g) {
33: grammar = g;
34: line = -1;
35: column = -1;
36: }
37:
38: public GrammarElement(Grammar g, Token start) {
39: grammar = g;
40: line = start.getLine();
41: column = start.getColumn();
42: }
43:
44: public void generate(Context context) {
45:
46: }
47:
48: public int getLine() {
49: return line;
50: }
51:
52: public int getColumn() {
53: return column;
54: }
55:
56: public Lookahead look(int k) {
57: return null;
58: }
59:
60: public abstract String toString();
61: }
|