Changed how tokens are represented in memory

Also made string-literal tokens now include the quotes as part of their contents.
This commit is contained in:
Pasha Bibko
2025-04-22 10:55:35 +01:00
parent 4b47e803ce
commit c95d91b867
6 changed files with 40 additions and 28 deletions

View File

@@ -43,7 +43,7 @@ namespace LX
// Number literals just require them to be turned into an AST node //
// Note: Number literals are stored as strings because i'm a masochist //
case Token::NUMBER_LITERAL:
return std::make_unique<AST::NumberLiteral>(p.tokens[p.index++].contents);
return std::make_unique<AST::NumberLiteral>(p.tokens[p.index++].GetContents());
// Returns nullptr, the parsing function that recives that value will decide if that is valid //
default:
@@ -133,7 +133,7 @@ namespace LX
// Assigns the function name //
ExpectToken<Token::IDENTIFIER>(p.tokens[p.index]);
func.name = p.tokens[p.index++].contents;
func.name = p.tokens[p.index++].GetContents();
// Loops over the body until it reaches the end //
// TODO: Detect the end instead of looping over the entire token vector