Added symbols/operators to lexer

This commit is contained in:
Pasha Bibko
2025-07-21 17:34:47 +01:00
parent a6afeff493
commit 24fde1b770
6 changed files with 158 additions and 96 deletions

View File

@@ -27,12 +27,13 @@ namespace LXC::Lexer
enum Reason
{
InvalidCharacter,
UnterminatedStringLiteral
UnterminatedStringLiteral,
UnknownSymbolOrOperand
};
// Constructor to pass arguments through to the struct //
LexerError(Reason _reason, __int32 errorIndex)
: reason(_reason), index(errorIndex)
LexerError(Reason _reason, __int32 errorIndex, std::string _info = "")
: reason(_reason), index(errorIndex), info(_info)
{}
// Turns the error into a c-string //
@@ -41,7 +42,8 @@ namespace LXC::Lexer
static const char* reasons[] =
{
"Invalid character found in source",
"Unterminated string literal in source"
"Unterminated string literal in source",
"Unknown symbol or operand in source"
};
return reasons[reason];
@@ -50,6 +52,7 @@ namespace LXC::Lexer
// Error information //
const Reason reason;
const __int32 index;
const std::string info;
};
// Turns a file into a vector of tokens //