-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToken.cs
More file actions
77 lines (69 loc) · 1.86 KB
/
Token.cs
File metadata and controls
77 lines (69 loc) · 1.86 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
namespace maple
{
public enum TokenType
{
// MISC
None,
// DOCUMENT SYNTAX
Misc,
Break,
Whitespace,
Alphabetical,
Keyword,
NumberLiteral,
StringLiteral,
CharLiteral,
BooleanLiteral,
HexLiteral,
Comment,
Grouping,
Operator,
Url,
Function,
SpecialChar,
MultilineCommentOpen,
MultilineCommentClose,
// CLI INPUT
CliCommandValid,
CliCommandInvalid,
CliSwitch,
CliString,
// SPECIAL
TrailingWhitespace,
}
public class Token
{
private TokenType _ttype;
public TokenType TType
{
get { return _ttype; }
set
{
_ttype = value;
if (Settings.Theme.TokenColorTable.ContainsKey(value))
Color = Settings.Theme.TokenColorTable[value];
else
{
// Log.Write("Theme missing TokenType: " + value, "token", important: true);
Color = ConsoleColor.Gray;
}
ColorAttribute = Printer.ConsoleColorToAttributeTable[Color];
// TODO: this is a mess
if (_ttype == TokenType.TrailingWhitespace)
{
ColorAttribute = (short)(ColorAttribute << 4);
}
}
}
public String Text { get; set; }
public ConsoleColor Color { get; private set; } = ConsoleColor.Gray;
public short ColorAttribute { get; private set; } = 0x0007;
public string Annotation { get; set; } = "";
public Token(String text, TokenType tokenType)
{
this.Text = text;
this.TType = tokenType;
}
}
}