1 | using System; |
---|
2 | using AST = antlr.collections.AST; |
---|
3 | |
---|
4 | namespace antlr |
---|
5 | { |
---|
6 | /*ANTLR Translator Generator |
---|
7 | * Project led by Terence Parr at http://www.jGuru.com |
---|
8 | * Software rights: http://www.antlr.org/license.html |
---|
9 | * |
---|
10 | * $Id:$ |
---|
11 | */ |
---|
12 | |
---|
13 | // |
---|
14 | // ANTLR C# Code Generator by Micheal Jordan |
---|
15 | // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com |
---|
16 | // Anthony Oguntimehin |
---|
17 | // |
---|
18 | // With many thanks to Eric V. Smith from the ANTLR list. |
---|
19 | // |
---|
20 | |
---|
21 | /*Common AST node implementation */ |
---|
22 | public class CommonAST : BaseAST |
---|
23 | { |
---|
24 | public static readonly CommonAST.CommonASTCreator Creator = new CommonASTCreator(); |
---|
25 | |
---|
26 | internal int ttype = Token.INVALID_TYPE; |
---|
27 | internal string text; |
---|
28 | |
---|
29 | |
---|
30 | [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)] |
---|
31 | protected CommonAST(CommonAST another) |
---|
32 | { |
---|
33 | // don't include child/sibling pointers in Clone()/dup() |
---|
34 | //down = another.down; |
---|
35 | //right = another.right; |
---|
36 | ttype = another.ttype; |
---|
37 | text = (another.text==null) ? null : String.Copy(another.text); |
---|
38 | } |
---|
39 | |
---|
40 | /*Get the token text for this node */ |
---|
41 | override public string getText() |
---|
42 | { |
---|
43 | return text; |
---|
44 | } |
---|
45 | |
---|
46 | /*Get the token type for this node */ |
---|
47 | override public int Type |
---|
48 | { |
---|
49 | get { return ttype; } |
---|
50 | set { ttype = value; } |
---|
51 | } |
---|
52 | |
---|
53 | override public void initialize(int t, string txt) |
---|
54 | { |
---|
55 | Type = t; |
---|
56 | setText(txt); |
---|
57 | } |
---|
58 | |
---|
59 | override public void initialize(AST t) |
---|
60 | { |
---|
61 | setText(t.getText()); |
---|
62 | Type = t.Type; |
---|
63 | } |
---|
64 | |
---|
65 | public CommonAST() |
---|
66 | { |
---|
67 | } |
---|
68 | |
---|
69 | public CommonAST(IToken tok) |
---|
70 | { |
---|
71 | initialize(tok); |
---|
72 | } |
---|
73 | |
---|
74 | override public void initialize(IToken tok) |
---|
75 | { |
---|
76 | setText(tok.getText()); |
---|
77 | Type = tok.Type; |
---|
78 | } |
---|
79 | /*Set the token text for this node */ |
---|
80 | override public void setText(string text_) |
---|
81 | { |
---|
82 | text = text_; |
---|
83 | } |
---|
84 | /*Set the token type for this node */ |
---|
85 | override public void setType(int ttype_) |
---|
86 | { |
---|
87 | this.Type = ttype_; |
---|
88 | } |
---|
89 | |
---|
90 | #region Implementation of ICloneable |
---|
91 | [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)] |
---|
92 | override public object Clone() |
---|
93 | { |
---|
94 | return new CommonAST(this); |
---|
95 | } |
---|
96 | #endregion |
---|
97 | |
---|
98 | public class CommonASTCreator : ASTNodeCreator |
---|
99 | { |
---|
100 | public CommonASTCreator() {} |
---|
101 | |
---|
102 | /// <summary> |
---|
103 | /// Returns the fully qualified name of the AST type that this |
---|
104 | /// class creates. |
---|
105 | /// </summary> |
---|
106 | public override string ASTNodeTypeName |
---|
107 | { |
---|
108 | get |
---|
109 | { |
---|
110 | return typeof(antlr.CommonAST).FullName;; |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | /// <summary> |
---|
115 | /// Constructs a <see cref="AST"/> instance. |
---|
116 | /// </summary> |
---|
117 | public override AST Create() |
---|
118 | { |
---|
119 | return new CommonAST(); |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|