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