Compiles on UNIX based systems

This commit is contained in:
2025-07-21 19:57:05 +01:00
parent d6568a8d2f
commit cde435ba55
9 changed files with 65 additions and 28 deletions

View File

@@ -15,7 +15,7 @@ namespace LXC::Internal
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
static constexpr bool IsWhitespace(const char c)
bool IsWhitespace(const char c)
{
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
@@ -69,7 +69,7 @@ namespace LXC::Internal
namespace LXC::Lexer
{
LexerContext::LexerContext(const std::string& _source) :
source(_source), index(0), out{}, len((__int32)_source.length()), column(0), line(0)
source(_source), index(0), out{}, len((uint32_t)_source.length()), column(0), line(0)
{}
Util::ReturnVal<LexerOutput, LexerError> TokenizeFile(const std::string& fileContents)
@@ -86,7 +86,7 @@ namespace LXC::Lexer
bool inComment = false;
unsigned __int32 sectionStart = 0;
uint32_t sectionStart = 0;
} trackers;
@@ -111,7 +111,7 @@ namespace LXC::Lexer
// Creates the token (if at the end of the string literal) //
if (!trackers.inStrLiteral)
ctx.out.emplace_back(ctx, trackers.sectionStart + 1, (USHORT)(ctx.index - trackers.sectionStart - 1), Token::StringLiteral);
ctx.out.emplace_back(ctx, trackers.sectionStart + 1, (unsigned short)(ctx.index - trackers.sectionStart - 1), Token::StringLiteral);
} else if (trackers.inStrLiteral) {}
@@ -125,9 +125,7 @@ namespace LXC::Lexer
// Checks for the end of the number literal to create the token //
if (!Internal::IsNumeric(next)) _UNLIKELY
{
ctx.out.emplace_back(ctx, trackers.sectionStart, (USHORT)(ctx.index - trackers.sectionStart + 1), Token::NumLiteral);
ctx.out.emplace_back(ctx, trackers.sectionStart, (unsigned short)(ctx.index - trackers.sectionStart + 1), Token::NumLiteral);
trackers.inNumLiteral = false;
}
}
@@ -147,7 +145,7 @@ namespace LXC::Lexer
auto it = Internal::keywords.find(fullWord);
Token::TokenType tType = (it != Internal::keywords.end()) ? it->second : Token::Identifier;
ctx.out.emplace_back(ctx, trackers.sectionStart, (USHORT)(ctx.index - trackers.sectionStart + 1), tType);
ctx.out.emplace_back(ctx, trackers.sectionStart, (unsigned short)(ctx.index - trackers.sectionStart + 1), tType);
trackers.inIdentifier = false;
}
}
@@ -168,7 +166,7 @@ namespace LXC::Lexer
std::string_view fullSymbol(ctx.source.data() + trackers.sectionStart, ctx.index - trackers.sectionStart + 1);
auto it = Internal::symbolAndOpMap.find(fullSymbol);
if (it != Internal::symbolAndOpMap.end())
ctx.out.emplace_back(ctx, trackers.sectionStart, (USHORT)(ctx.index - trackers.sectionStart + 1), it->second);
ctx.out.emplace_back(ctx, trackers.sectionStart, (unsigned short)(ctx.index - trackers.sectionStart + 1), it->second);
else
return Util::FunctionFail<LexerError>(LexerError::UnknownSymbolOrOperand, trackers.sectionStart, std::string(fullSymbol));

View File

@@ -8,7 +8,7 @@
namespace LXC::Lexer
{
// Constructor to assign the members of the token class //
Token::Token(const LexerContext& ctx, unsigned __int32 start, unsigned short len, TokenType _type) :
Token::Token(const LexerContext& ctx, const uint32_t start, unsigned short len, TokenType _type) :
type(_type), length(len), index(start), contents(nullptr)
{
// Only user defined class tokens need to store c-string //