mirror of
https://github.com/PashaBibko/LX.git
synced 2026-04-04 01:49:05 +00:00
General clean up
- Moved some classes from Lexer.h to seperate (non-Global files) - Deleted dllmain as it wasn't used for the most part
This commit is contained in:
@@ -150,6 +150,10 @@
|
||||
<ClCompile Include="src\Lexer.cpp" />
|
||||
<ClCompile Include="src\Token.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="inc\LexerErrors.h" />
|
||||
<ClInclude Include="inc\LexerInfo.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -21,4 +21,12 @@
|
||||
<Filter>Header Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="inc\LexerErrors.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="inc\LexerInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
25
Lexer/inc/LexerErrors.h
Normal file
25
Lexer/inc/LexerErrors.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <LX-Common.h>
|
||||
|
||||
#include <Lexer.h>
|
||||
|
||||
namespace LX
|
||||
{
|
||||
// Error type with index and character to alert the user that LX does not understand that symbol //
|
||||
struct InvalidCharInSource : public RuntimeError
|
||||
{
|
||||
GENERATE_LX_ERROR_REQUIRED_FUNCTION_DECLARATIONS;
|
||||
|
||||
InvalidCharInSource(std::streamsize _col, std::streamsize _line, std::streamsize _index, char _invalid);
|
||||
|
||||
static std::string* s_Source;
|
||||
static std::filesystem::path* s_SourceFile;
|
||||
|
||||
std::streamsize col;
|
||||
std::streamsize line;
|
||||
std::streamsize index;
|
||||
|
||||
char invalid;
|
||||
};
|
||||
}
|
||||
37
Lexer/inc/LexerInfo.h
Normal file
37
Lexer/inc/LexerInfo.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <LX-Common.h>
|
||||
|
||||
#include <Lexer.h>
|
||||
|
||||
namespace LX
|
||||
{
|
||||
// Struct to store the current information of the lexer //
|
||||
struct LexerInfo
|
||||
{
|
||||
// Current trackers of where in the source it is //
|
||||
|
||||
std::streamsize line = 1; // <- Lines start on 1 (probably because of non-programmer's)
|
||||
std::streamsize index = 0;
|
||||
std::streamsize column = 0; // <- Columns start on 1 (probably because of non-programmer's). THEN WHY IS THIS SET TO 0
|
||||
|
||||
// Trackers for when a multi-char token started //
|
||||
|
||||
std::streamsize startOfWord = 0;
|
||||
std::streamsize startOfNumberLiteral = 0;
|
||||
std::streamsize startOfStringLiteral = 0;
|
||||
|
||||
// Different flags of the lexer //
|
||||
// Stored as a bitset to minimse memory allocated //
|
||||
// - Basically no difference, because only one exists at any given time //
|
||||
// - But it is a cool C++ feature I like so I use it //
|
||||
|
||||
bool isAlpha : 1 = false;
|
||||
bool isNumeric : 1 = false;
|
||||
bool inComment : 1 = false;
|
||||
bool inStringLiteral : 1 = false;
|
||||
bool isNextCharAlpha : 1 = false;
|
||||
bool isNextCharNumeric : 1 = false;
|
||||
bool wasLastCharAlpha : 1 = false;
|
||||
bool wasLastCharNumeric : 1 = false;
|
||||
bool lexingNumber : 1 = false;
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <Lexer.h>
|
||||
|
||||
#include <LexerErrors.h>
|
||||
#include <LexerInfo.h>
|
||||
|
||||
namespace LX
|
||||
{
|
||||
std::string* InvalidCharInSource::s_Source = nullptr;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <Lexer.h>
|
||||
|
||||
#include <LexerInfo.h>
|
||||
|
||||
namespace LX
|
||||
{
|
||||
// Creates the memory for the pointer to the source //
|
||||
|
||||
Reference in New Issue
Block a user