source: trunk/yao/share/antlr-2.7.7/lib/csharp/antlr.runtime/antlr/Token.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.8 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        /*A token is minimally a token type.  Subclasses can add the text matched
21        *  for the token and line info.
22        */
23
24        public class Token : IToken //, ICloneable
25        {
26                // constants
27                public const int MIN_USER_TYPE = 4;
28                public const int NULL_TREE_LOOKAHEAD = 3;
29                public const int INVALID_TYPE = 0;
30                public const int EOF_TYPE = 1;
31                public static readonly int SKIP = - 1;
32               
33                // each Token has at least a token type
34                protected int type_;
35               
36                // the illegal token object
37                public static Token badToken = new Token(INVALID_TYPE, "<no text>");
38               
39                public Token()
40                {
41                        type_ = INVALID_TYPE;
42                }
43                public Token(int t)
44                {
45                        type_ = t;
46                }
47                public Token(int t, string txt)
48                {
49                        type_ = t;
50                        setText(txt);
51                }
52                public virtual int getColumn()
53                {
54                        return 0;
55                }
56                public virtual int getLine()
57                {
58                        return 0;
59                }
60                public virtual string getFilename() 
61                {
62                        return null;
63                }
64
65                public virtual void setFilename(string name) 
66                {
67                }
68
69                public virtual string getText()
70                {
71                        return "<no text>";
72                }
73
74                public int Type
75                {
76                        get { return type_;  }
77                        set { type_ = value; }
78                }
79
80                public virtual void setType(int newType)        { this.Type = newType; }
81
82                public virtual void  setColumn(int c)
83                {
84                        ;
85                }
86                public virtual void  setLine(int l)
87                {
88                        ;
89                }
90                public virtual void  setText(string t)
91                {
92                        ;
93                }
94                override public string ToString()
95                {
96                        return "[\"" + getText() + "\",<" + type_ + ">]";
97                }
98        }
99}
Note: See TracBrowser for help on using the repository browser.