mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 12:02:08 +00:00
Remove "EOF-newline" lexer hack
In preparation for an upcoming change Makes for nicer error messages, complaining about EOF instead of newlines The hack had to be kept for the lexer raw mode to avoid a bug; see the relevant code comment for more info.
This commit is contained in:
@@ -39,6 +39,7 @@ struct Patch {
|
||||
struct Section *pcSection;
|
||||
uint32_t pcOffset;
|
||||
uint8_t type;
|
||||
bool isOperand; // If set, PC is not at the patch's address, but at the byte before
|
||||
uint32_t nRPNSize;
|
||||
uint8_t *pRPN;
|
||||
struct Patch *next;
|
||||
@@ -203,13 +204,17 @@ static uint32_t getSectIDIfAny(struct Section const *sect)
|
||||
static void writepatch(struct Patch const *patch, FILE *f)
|
||||
{
|
||||
assert(patch->src->ID != -1);
|
||||
uint8_t type = patch->type;
|
||||
|
||||
if (patch->isOperand)
|
||||
type |= PATCH_ISOPERAND;
|
||||
|
||||
putlong(patch->src->ID, f);
|
||||
putlong(patch->lineNo, f);
|
||||
putlong(patch->nOffset, f);
|
||||
putlong(getSectIDIfAny(patch->pcSection), f);
|
||||
putlong(patch->pcOffset, f);
|
||||
putc(patch->type, f);
|
||||
putc(type, f);
|
||||
putlong(patch->nRPNSize, f);
|
||||
fwrite(patch->pRPN, 1, patch->nRPNSize, f);
|
||||
}
|
||||
@@ -382,6 +387,7 @@ static struct Patch *allocpatch(uint32_t type, struct Expression const *expr, ui
|
||||
fatalerror("No memory for patch's RPN expression: %s\n", strerror(errno));
|
||||
|
||||
patch->type = type;
|
||||
patch->isOperand = false;
|
||||
patch->src = node;
|
||||
out_RegisterNode(node);
|
||||
patch->lineNo = lexer_GetLineNo();
|
||||
@@ -410,10 +416,11 @@ static struct Patch *allocpatch(uint32_t type, struct Expression const *expr, ui
|
||||
/*
|
||||
* Create a new patch (includes the rpn expr)
|
||||
*/
|
||||
void out_CreatePatch(uint32_t type, struct Expression const *expr, uint32_t ofs)
|
||||
void out_CreatePatch(uint32_t type, struct Expression const *expr, uint32_t ofs, bool isOperand)
|
||||
{
|
||||
struct Patch *patch = allocpatch(type, expr, ofs);
|
||||
|
||||
patch->isOperand = isOperand;
|
||||
patch->next = pCurrentSection->patches;
|
||||
pCurrentSection->patches = patch;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user