mirror of
https://github.com/PashaBibko/LX.git
synced 2026-04-04 01:49:05 +00:00
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:
@@ -5,8 +5,17 @@
|
||||
|
||||
namespace LX
|
||||
{
|
||||
// Creates the memory for the pointer to the source //
|
||||
std::string* Token::source = nullptr;
|
||||
|
||||
// Passes the constructor args to the values //
|
||||
Token::Token(const TokenType _type, const LexerInfo& info, std::string _contents, std::streamsize _length)
|
||||
: type(_type), contents(_contents), index(info.index - _length + 1), line(info.line), column(info.column - _length), length(_length)
|
||||
Token::Token(const TokenType _type, const LexerInfo& info, std::streamsize _length)
|
||||
: type(_type), index(info.index - _length + 1), line(info.line), column(info.column - _length), length(_length)
|
||||
{}
|
||||
|
||||
//
|
||||
std::string Token::GetContents() const
|
||||
{
|
||||
return std::string(source->data() + index, length);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user