This commit is contained in:
Timerix22 2023-12-19 02:22:26 +06:00
parent 8e4be0b7e1
commit 84adeb3c97
2 changed files with 30 additions and 33 deletions

View File

@ -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 public class Lexer
{ {
string ExprStr; string ExprStr;

30
src/Token.fu Normal file
View 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;
}