mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Adapt the RGBASM parser to C++ (#1333)
This uses variants instead of a `%union`, and "complete symbols" that can call complex constructors.
This commit is contained in:
2
Makefile
2
Makefile
@@ -174,7 +174,7 @@ clean:
|
|||||||
$Qfind src/ -name "*.o" -exec rm {} \;
|
$Qfind src/ -name "*.o" -exec rm {} \;
|
||||||
$Qfind . -type f \( -name "*.gcno" -o -name "*.gcda" -o -name "*.gcov" \) -exec rm {} \;
|
$Qfind . -type f \( -name "*.gcno" -o -name "*.gcda" -o -name "*.gcov" \) -exec rm {} \;
|
||||||
$Q${RM} rgbshim.sh
|
$Q${RM} rgbshim.sh
|
||||||
$Q${RM} src/asm/parser.cpp src/asm/parser.hpp
|
$Q${RM} src/asm/parser.cpp src/asm/parser.hpp src/asm/stack.hh
|
||||||
$Q${RM} src/link/script.cpp src/link/script.hpp src/link/stack.hh
|
$Q${RM} src/link/script.cpp src/link/script.hpp src/link/stack.hh
|
||||||
$Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test
|
$Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "asm/symbol.hpp" // MAXSYMLEN
|
||||||
|
|
||||||
#include "platform.hpp" // SSIZE_MAX
|
#include "platform.hpp" // SSIZE_MAX
|
||||||
|
|
||||||
#define MAXSTRLEN 255
|
#define MAXSTRLEN 255
|
||||||
@@ -139,12 +141,19 @@ struct CaptureBody {
|
|||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct String {
|
||||||
|
char string[MAXSTRLEN + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SymName {
|
||||||
|
char symName[MAXSYMLEN + 1];
|
||||||
|
};
|
||||||
|
|
||||||
void lexer_CheckRecursionDepth();
|
void lexer_CheckRecursionDepth();
|
||||||
char const *lexer_GetFileName();
|
char const *lexer_GetFileName();
|
||||||
uint32_t lexer_GetLineNo();
|
uint32_t lexer_GetLineNo();
|
||||||
uint32_t lexer_GetColNo();
|
uint32_t lexer_GetColNo();
|
||||||
void lexer_DumpStringExpansions();
|
void lexer_DumpStringExpansions();
|
||||||
int yylex();
|
|
||||||
bool lexer_CaptureRept(CaptureBody &capture);
|
bool lexer_CaptureRept(CaptureBody &capture);
|
||||||
bool lexer_CaptureMacroBody(CaptureBody &capture);
|
bool lexer_CaptureMacroBody(CaptureBody &capture);
|
||||||
|
|
||||||
|
|||||||
1
src/asm/.gitignore
vendored
1
src/asm/.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/parser.cpp
|
/parser.cpp
|
||||||
/parser.hpp
|
/parser.hpp
|
||||||
|
/stack.hh
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -399,8 +399,9 @@ int main(int argc, char *argv[]) {
|
|||||||
// Init lexer and file stack, providing file info
|
// Init lexer and file stack, providing file info
|
||||||
fstk_Init(mainFileName, maxDepth);
|
fstk_Init(mainFileName, maxDepth);
|
||||||
|
|
||||||
// Perform parse (yyparse is auto-generated from `parser.y`)
|
// Perform parse
|
||||||
if (yyparse() != 0 && nbErrors == 0)
|
yy::parser parser;
|
||||||
|
if (parser.parse() != 0 && nbErrors == 0)
|
||||||
nbErrors = 1;
|
nbErrors = 1;
|
||||||
|
|
||||||
if (dependfile)
|
if (dependfile)
|
||||||
|
|||||||
1323
src/asm/parser.y
1323
src/asm/parser.y
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user