source: trunk/yao/share/antlr-2.7.7/lib/csharp/antlr.runtime/antlr/CommonToken.cs @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 1.9 KB
Line 
1using System;
2       
3namespace antlr
4{
5        /*ANTLR Translator Generator
6        * Project led by Terence Parr at http://www.jGuru.com
7        * Software rights: http://www.antlr.org/license.html
8        *
9        * $Id:$
10        */
11
12        //
13        // ANTLR C# Code Generator by Micheal Jordan
14        //                            Kunle Odutola       : kunle UNDERSCORE odutola AT hotmail DOT com
15        //                            Anthony Oguntimehin
16        //
17        // With many thanks to Eric V. Smith from the ANTLR list.
18        //
19
20        public class CommonToken : Token
21        {
22                public static readonly CommonToken.CommonTokenCreator Creator = new CommonTokenCreator();
23
24                // most tokens will want line and text information
25                protected internal int line;
26                protected internal string text = null;
27                protected internal int col;
28               
29                public CommonToken()
30                {
31                }
32               
33                public CommonToken(int t, string txt)
34                {
35                        type_ = t;
36                        setText(txt);
37                }
38               
39                public CommonToken(string s)
40                {
41                        text = s;
42                }
43               
44                override public int getLine()
45                {
46                        return line;
47                }
48               
49                override public string getText()
50                {
51                        return text;
52                }
53               
54                override public void  setLine(int l)
55                {
56                        line = l;
57                }
58               
59                override public void  setText(string s)
60                {
61                        text = s;
62                }
63               
64                override public string ToString()
65                {
66                        return "[\"" + getText() + "\",<" + type_ + ">,line=" + line + ",col=" + col + "]";
67                }
68               
69                /*Return token's start column */
70                override public int getColumn()
71                {
72                        return col;
73                }
74               
75                override public void  setColumn(int c)
76                {
77                        col = c;
78                }
79
80                public class CommonTokenCreator : TokenCreator
81                {
82                        public CommonTokenCreator() {}
83
84                        /// <summary>
85                        /// Returns the fully qualified name of the Token type that this
86                        /// class creates.
87                        /// </summary>
88                        public override string TokenTypeName
89                        {
90                                get 
91                                { 
92                                        return typeof(antlr.CommonToken).FullName;; 
93                                }
94                        }
95
96                        /// <summary>
97                        /// Constructs a <see cref="Token"/> instance.
98                        /// </summary>
99                        public override IToken Create()
100                        {
101                                return new CommonToken();
102                        }
103                }
104        }
105}
Note: See TracBrowser for help on using the repository browser.