Refactor to keep lexerState and lexerStateEOL static

Also run `clang-format` on everything
This commit is contained in:
Rangi42
2024-03-23 16:42:28 -04:00
parent c075ffb570
commit e9e8915725
9 changed files with 179 additions and 198 deletions

View File

@@ -24,8 +24,9 @@ struct FileStackNode {
data;
std::shared_ptr<FileStackNode> parent; // Pointer to parent node, for error reporting
// Line at which the parent context was exited; meaningless for the root level
uint32_t lineNo;
// Line at which the parent context was exited
// Meaningless at the root level, but gets written to the object file anyway, so init it
uint32_t lineNo = 0;
// Set only if referenced: ID within the object file, -1 if not output yet
uint32_t ID = -1;
@@ -61,7 +62,7 @@ void fstk_SetPreIncludeFile(std::string const &path);
std::optional<std::string> fstk_FindFile(std::string const &path);
bool yywrap();
void fstk_RunInclude(std::string const &path);
void fstk_RunInclude(std::string const &path, bool updateStateNow);
void fstk_RunMacro(std::string const &macroName, std::shared_ptr<MacroArgs> macroArgs);
void fstk_RunRept(uint32_t count, int32_t reptLineNo, char const *body, size_t size);
void fstk_RunFor(

View File

@@ -94,19 +94,14 @@ struct LexerState {
LexerState &operator=(LexerState &&) = default;
LexerState &operator=(LexerState const &) = delete;
void setAsCurrentState();
bool setFileAsNextState(std::string const &filePath, bool updateStateNow);
void setViewAsNextState(char const *filePath, char const *buf, size_t size, uint32_t lineNo_);
void clear(uint32_t lineNo_);
};
extern LexerState *lexerState;
extern LexerState *lexerStateEOL;
static inline void lexer_SetState(LexerState *state) {
lexerState = state;
}
static inline void lexer_SetStateAtEOL(LexerState *state) {
lexerStateEOL = state;
}
extern char binDigits[2];
extern char gfxDigits[4];
@@ -122,11 +117,6 @@ static inline void lexer_SetGfxDigits(char const digits[4]) {
gfxDigits[3] = digits[3];
}
// `path` is referenced, but not held onto..!
bool lexer_OpenFile(LexerState &state, std::string const &path);
void lexer_OpenFileView(
LexerState &state, char const *path, char const *buf, size_t size, uint32_t lineNo
);
void lexer_RestartRept(uint32_t lineNo);
void lexer_Init();
void lexer_SetMode(LexerMode mode);

View File

@@ -20,5 +20,4 @@ struct MacroArgs {
void shiftArgs(int32_t count);
};
#endif // RGBDS_MACRO_H