Token.fu
This commit is contained in:
parent
8e4be0b7e1
commit
84adeb3c97
33
src/Lexer.fu
33
src/Lexer.fu
@ -1,36 +1,3 @@
|
||||
//namespace SharpCalculator.Parsing;
|
||||
|
||||
public enum TokenType
|
||||
{
|
||||
BracketOpen,
|
||||
BracketClose,
|
||||
OperatorPow,
|
||||
OperatorMul,
|
||||
OperatorMod,
|
||||
OperatorDiv,
|
||||
OperatorAdd,
|
||||
OperatorSub,
|
||||
Literal,
|
||||
Number
|
||||
}
|
||||
|
||||
public class Token
|
||||
{
|
||||
string Str;
|
||||
TokenType Type;
|
||||
|
||||
public static Token() Create(string str, TokenType type){
|
||||
Token() tok = {
|
||||
Str = str,
|
||||
Type = type
|
||||
};
|
||||
return tok;
|
||||
}
|
||||
|
||||
public string GetStr() => Str;
|
||||
public TokenType GetType() => Type;
|
||||
}
|
||||
|
||||
public class Lexer
|
||||
{
|
||||
string ExprStr;
|
||||
|
||||
30
src/Token.fu
Normal file
30
src/Token.fu
Normal file
@ -0,0 +1,30 @@
|
||||
public enum TokenType
|
||||
{
|
||||
BracketOpen=1,
|
||||
BracketClose=2,
|
||||
OperatorPow=3,
|
||||
OperatorMul=4,
|
||||
OperatorMod=5,
|
||||
OperatorDiv=6,
|
||||
OperatorAdd=7,
|
||||
OperatorSub=8,
|
||||
Literal=9,
|
||||
Number=10
|
||||
}
|
||||
|
||||
public class Token
|
||||
{
|
||||
string Str;
|
||||
TokenType Type;
|
||||
|
||||
public static Token() Create(string str, TokenType type){
|
||||
Token() tok = {
|
||||
Str = str,
|
||||
Type = type
|
||||
};
|
||||
return tok;
|
||||
}
|
||||
|
||||
public string GetStr() => Str;
|
||||
public TokenType GetType() => Type;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user