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