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