This commit is contained in:
nub31
2025-09-11 21:22:30 +02:00
parent 5fecfeba43
commit fd27d2709d
46 changed files with 5339 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
using NubLang.Code;
namespace NubLang.Tokenization;
public abstract class Token(SourceFileSpan fileSpan)
{
public SourceFileSpan FileSpan { get; } = fileSpan;
}
public class IdentifierToken(SourceFileSpan fileSpan, string value) : Token(fileSpan)
{
public string Value { get; } = value;
}
public class LiteralToken(SourceFileSpan fileSpan, LiteralKind kind, string value) : Token(fileSpan)
{
public LiteralKind Kind { get; } = kind;
public string Value { get; } = value;
}
public enum LiteralKind
{
Integer,
Float,
String,
Bool
}
public class SymbolToken(SourceFileSpan fileSpan, Symbol symbol) : Token(fileSpan)
{
public Symbol Symbol { get; } = symbol;
}
public enum Symbol
{
Func,
Return,
If,
Else,
While,
Break,
Continue,
Colon,
OpenParen,
CloseParen,
OpenBrace,
CloseBrace,
OpenBracket,
CloseBracket,
Comma,
Period,
Assign,
Bang,
Equal,
NotEqual,
LessThan,
LessThanOrEqual,
GreaterThan,
GreaterThanOrEqual,
Plus,
Minus,
Star,
ForwardSlash,
Struct,
Caret,
Ampersand,
Let,
Calls,
Interface,
For,
Extern,
Semi,
Percent,
LeftShift,
RightShift,
Pipe,
And,
Or,
Module,
Import,
Export,
}