ScriptStack 1.0.4
Loading...
Searching...
No Matches
Token.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Text;
4
6{
7
85
86 public class SerializableToken
87 {
88 public TokenType Type { get; set; }
89 public string Lexeme { get; set; }
90 public int Line { get; set; }
91 public int Column { get; set; }
92 public string Text { get; set; }
93 }
94
98 [Serializable]
99 public class Token
100 {
101
102 #region Private Variables
103
104 private TokenType tokenType;
105 private object lexeme;
106 private int line;
107 private int column;
108 private String text;
109
110 #endregion
111
112 #region Public Methods
113
114 public Token(TokenType tokenType, object lexeme, int line, int column, String sourceLine)
115 {
116 this.tokenType = tokenType;
117 this.lexeme = lexeme;
118 this.line = line;
119 this.column = Math.Max(0, column - lexeme.ToString().Length - 1);
120 this.text = sourceLine;
121 }
122
123 public override string ToString()
124 {
125 return "Token(" + tokenType + ", \"" + lexeme.ToString() + "\")";
126 }
127
128 #endregion
129
130 #region Public Methods
131
133 {
134 get { return tokenType; }
135 }
136
137 public object Lexeme
138 {
139 get { return lexeme; }
140 }
141
142 public int Line
143 {
144 get { return line; }
145 }
146
147 public int Column
148 {
149 get { return column; }
150 }
151
152 public string Text
153 {
154 get { return text; }
155 }
156
157 #endregion
158
159 }
160
161}
162
Token(TokenType tokenType, object lexeme, int line, int column, String sourceLine)
Definition Token.cs:114
override string ToString()
Definition Token.cs:123
TokenType
Known types of Token.
Definition Token.cs:12