make tokens into flags yo
This commit is contained in:
parent
2f10015229
commit
f9f2f5b81a
|
|
@ -336,7 +336,9 @@ public class Reader : IReader<Token>, IDisposable
|
||||||
Check('=') ?
|
Check('=') ?
|
||||||
MakeToken(GreaterEqual, buffer + Next()) :
|
MakeToken(GreaterEqual, buffer + Next()) :
|
||||||
MakeToken(Greater, buffer),
|
MakeToken(Greater, buffer),
|
||||||
'~' => MakeToken(BitwiseNot, buffer),
|
'~' => Check('(') ?
|
||||||
|
MakeToken(Lambda, buffer) :
|
||||||
|
MakeToken(BitwiseNot, buffer),
|
||||||
'?' => Check('?') ?
|
'?' => Check('?') ?
|
||||||
MakeToken(DoubleQuestion, buffer + Next()) :
|
MakeToken(DoubleQuestion, buffer + Next()) :
|
||||||
Check(':') ?
|
Check(':') ?
|
||||||
|
|
|
||||||
|
|
@ -2,109 +2,114 @@
|
||||||
|
|
||||||
using static TokenType;
|
using static TokenType;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
public enum TokenType
|
public enum TokenType
|
||||||
{
|
{
|
||||||
Error,
|
Error = -1,
|
||||||
Void,
|
Void = 0,
|
||||||
Null,
|
|
||||||
|
|
||||||
Eof,
|
Constant = 1 << 4,
|
||||||
NewLine,
|
Null = Constant | 1,
|
||||||
Whitespace,
|
True = Constant | 2,
|
||||||
Comment,
|
False = Constant | 3,
|
||||||
|
|
||||||
Bracket = 1 << 8,
|
Format = 1 << 5,
|
||||||
GroupOpen = Bracket | 1,
|
Eof = Format | 1,
|
||||||
GroupClose = Bracket | 2,
|
NewLine = Format | 2,
|
||||||
|
Whitespace = Format | 3,
|
||||||
|
Comment = Format | 4,
|
||||||
|
|
||||||
ContextOpen = Bracket | 3,
|
Bracket = 1 << 6,
|
||||||
ContextClose = Bracket | 4,
|
GroupOpen = Bracket | 1,
|
||||||
|
GroupClose = Bracket | 2,
|
||||||
|
ContextOpen = Bracket | 3,
|
||||||
|
ContextClose = Bracket | 4,
|
||||||
|
ArrayOpen = Bracket | 5,
|
||||||
|
ArrayClose = Bracket | 6,
|
||||||
|
ListOpen = Bracket | 7,
|
||||||
|
Lambda = Bracket | 8,
|
||||||
|
|
||||||
ArrayOpen = Bracket | 5,
|
Structure = 1 << 7,
|
||||||
ArrayClose = Bracket | 6,
|
Comma = Structure | 1,
|
||||||
ListOpen = Bracket | 7,
|
Dot = Structure | 2,
|
||||||
|
Colon = Structure | 3,
|
||||||
|
Semicolon = Structure | 4,
|
||||||
|
|
||||||
AddItem,
|
Operator = 1 << 8,
|
||||||
RemoveItem,
|
Minus = Operator | 1,
|
||||||
|
Plus = Operator | 2,
|
||||||
|
Decrement = Operator | 3,
|
||||||
|
Increment = Operator | 4,
|
||||||
|
Slash = Operator | 5,
|
||||||
|
Star = Operator | 6,
|
||||||
|
Modulo = Operator | 7,
|
||||||
|
BitwiseAnd = Operator | 8,
|
||||||
|
BitwiseOr = Operator | 9,
|
||||||
|
BitwiseXor = Operator | 10,
|
||||||
|
BitwiseNot = Operator | 11,
|
||||||
|
BitwiseLeft = Operator | 12,
|
||||||
|
BitwiseRight = Operator | 13,
|
||||||
|
|
||||||
Comma,
|
Assignment = 1 << 9,
|
||||||
Dot,
|
Equal = Assignment | 1,
|
||||||
Colon,
|
PlusEqual = Assignment | 2,
|
||||||
Semicolon,
|
MinusEqual = Assignment | 3,
|
||||||
|
SlashEqual = Assignment | 4,
|
||||||
|
StarEqual = Assignment | 5,
|
||||||
|
ModuloEqual = Assignment | 6,
|
||||||
|
AddItem = Assignment | 7,
|
||||||
|
RemoveItem = Assignment | 8,
|
||||||
|
|
||||||
Minus,
|
Condition = 1 << 10,
|
||||||
Plus,
|
Bang = Condition | 1,
|
||||||
MinusEqual,
|
BangEqual = Condition | 2,
|
||||||
PlusEqual,
|
EqualEqual = Condition | 4,
|
||||||
Decrement,
|
Greater = Condition | 5,
|
||||||
Increment,
|
GreaterEqual = Condition | 6,
|
||||||
|
Less = Condition | 7,
|
||||||
|
LessEqual = Condition | 8,
|
||||||
|
And = Condition | 9,
|
||||||
|
Or = Condition | 10,
|
||||||
|
|
||||||
Slash,
|
Literal = 1 << 11,
|
||||||
SlashEqual,
|
Identifier = Literal | 1,
|
||||||
Star,
|
String = Literal | 2,
|
||||||
StarEqual,
|
Integer = Literal | 3,
|
||||||
Modulo,
|
Decimal = Literal | 4,
|
||||||
ModuloEqual,
|
Hexadecimal = Literal | 5,
|
||||||
|
|
||||||
BitwiseAnd,
|
Control = 1 << 12,
|
||||||
BitwiseOr,
|
Else = Control | 1,
|
||||||
BitwiseXor,
|
For = Control | 2,
|
||||||
BitwiseNot,
|
If = Control | 3,
|
||||||
|
This = Control | 4,
|
||||||
|
Var = Control | 5,
|
||||||
|
While = Control | 6,
|
||||||
|
Do = Control | 7,
|
||||||
|
Return = Control | 8,
|
||||||
|
Question = Control | 9,
|
||||||
|
DoubleQuestion = Control | 10,
|
||||||
|
TernaryElse = Control | 11,
|
||||||
|
Ref = Control | 12,
|
||||||
|
Function = Control | 13,
|
||||||
|
Class = Control | 14,
|
||||||
|
Base = Control | 15,
|
||||||
|
|
||||||
BitwiseLeft,
|
Native = 1 << 14,
|
||||||
BitwiseRight,
|
Print = Native | 1,
|
||||||
|
PrintStack = Native | 2,
|
||||||
|
PrintGlobals = Native | 3,
|
||||||
|
PrintExpr = Native | 4,
|
||||||
|
TypeOf = Native | 5,
|
||||||
|
|
||||||
Bang,
|
Import = Native | 6,
|
||||||
BangEqual,
|
Export = Native | 7
|
||||||
Equal,
|
|
||||||
EqualEqual,
|
|
||||||
Greater,
|
|
||||||
GreaterEqual,
|
|
||||||
Less,
|
|
||||||
LessEqual,
|
|
||||||
|
|
||||||
Question,
|
|
||||||
DoubleQuestion,
|
|
||||||
|
|
||||||
Identifier,
|
|
||||||
String,
|
|
||||||
Integer,
|
|
||||||
Decimal,
|
|
||||||
Hexadecimal,
|
|
||||||
|
|
||||||
And,
|
|
||||||
Else,
|
|
||||||
False,
|
|
||||||
For,
|
|
||||||
If,
|
|
||||||
Or,
|
|
||||||
This,
|
|
||||||
True,
|
|
||||||
Var,
|
|
||||||
While,
|
|
||||||
Do,
|
|
||||||
Return,
|
|
||||||
TernaryElse,
|
|
||||||
|
|
||||||
Ref,
|
|
||||||
Function,
|
|
||||||
Class,
|
|
||||||
Base,
|
|
||||||
|
|
||||||
Print,
|
|
||||||
PrintStack,
|
|
||||||
PrintGlobals,
|
|
||||||
PrintExpr,
|
|
||||||
TypeOf,
|
|
||||||
|
|
||||||
Import,
|
|
||||||
Export
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TokenTypeExtensions
|
public static class TokenTypeExtensions // iknow, i know, gotta make this flagged rather than THIS
|
||||||
{
|
{
|
||||||
public static bool IsBracket(this TokenType type)
|
public static bool IsBracket(this TokenType type)
|
||||||
=> type is GroupClose or GroupOpen or ContextClose or ContextOpen or ArrayClose or ArrayOpen or ListOpen;
|
=> type is GroupClose or GroupOpen or ContextClose or ContextOpen or ArrayClose or ArrayOpen or ListOpen or Lambda;
|
||||||
|
|
||||||
public static bool IsString(this TokenType type)
|
public static bool IsString(this TokenType type)
|
||||||
=> type is TokenType.String;
|
=> type is TokenType.String;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue