-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSyntaxToken.cs
executable file
·68 lines (56 loc) · 1.35 KB
/
SyntaxToken.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
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
using UnityEngine;
using System.Collections;
using System;
namespace CSharpCodeParser
{
using Debug = UnityEngine.Debug;
public class SyntaxToken //: IComparable<SyntaxToken>
{
public enum Kind
{
Missing,
Whitespace,
Comment,
Preprocessor,
PreprocessorArguments,
PreprocessorSymbol,
//PreprocessorDirectiveExpected,
//PreprocessorCommentExpected,
//PreprocessorUnexpectedDirective,
VerbatimStringLiteral,
LastWSToken, // Marker only
VerbatimStringBegin,
BuiltInLiteral,
CharLiteral,
StringLiteral,
IntegerLiteral,
RealLiteral,
Punctuator,
Keyword,
Identifier,
ContextualKeyword,
EOF,
}
public Kind tokenKind;
public ParseTree.Leaf parent;
public TextSpan textSpan;
public string text;
public int tokenId;
public CsTextBuffer.FormatedLine formatedLine;
public int Line { get {
if(formatedLine != null)
return formatedLine.index;
return -1;} }
public int TokenIndex { get { return formatedLine.tokens.IndexOf(this); } }
public SyntaxToken(Kind kind, string text)
{
parent = null;
tokenKind = kind;
this.text = string.Intern(text);
tokenId = -1;
//style = null;
}
public override string ToString() { return tokenKind +"(\"" + text + "\")"; }
public string Dump() { return "[Token: " + tokenKind + " \"" + text + "\"]"; }
}
}