-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.cs
39 lines (35 loc) · 1.08 KB
/
Token.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace LoxInterpreter
// group members: Peter Zhang, Madeline Moore, Cara Cannarozzi
// Crafting Interpreters book by Robert Nystrom used as a reference
// https://craftinginterpreters.com/contents.html
{
/// <summary>
/// class that tracks location of tokens
/// </summary>
public class Token
{
public TokenType type;
public string lexeme;
public object literal;
public int Line; // [location]
/// <summary>
/// constructs token from provided arguments
/// </summary>
/// <param name="type"></param>
/// <param name="lexeme"></param>
/// <param name="literal"></param>
/// <param name="line"></param>
public Token(TokenType type, string lexeme, object literal, int line)
{
this.type = type;
this.lexeme = lexeme;
this.literal = literal;
this.Line = line;
}
// converts token to string
public override string ToString()
{
return type + " " + lexeme + " " + literal;
}
}
}