mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Return a marker token at the end of any buffer
Removes the lexer hack mentioned in #778
This commit is contained in:
@@ -646,6 +646,7 @@ enum {
|
||||
%type <expr> op_mem_ind
|
||||
%type <assertType> assert_type
|
||||
|
||||
%token T_EOB "end of buffer"
|
||||
%token T_EOF 0 "end of file"
|
||||
%start asmfile
|
||||
|
||||
@@ -654,14 +655,13 @@ enum {
|
||||
asmfile : lines
|
||||
;
|
||||
|
||||
/*
|
||||
* The lexer adds T_NEWLINE at the end of the file if one was not
|
||||
* already present, so we can rely on it to end a line.
|
||||
*/
|
||||
lines : %empty
|
||||
| lines line
|
||||
;
|
||||
|
||||
endofline : T_NEWLINE | T_EOB
|
||||
;
|
||||
|
||||
plain_directive : label
|
||||
| label cpu_command
|
||||
| label macro
|
||||
@@ -669,9 +669,9 @@ plain_directive : label
|
||||
| assignment_directive
|
||||
;
|
||||
|
||||
line : plain_directive T_NEWLINE
|
||||
line : plain_directive endofline
|
||||
| line_directive /* Directives that manage newlines themselves */
|
||||
| error T_NEWLINE { /* Continue parsing the next line on a syntax error */
|
||||
| error endofline { /* Continue parsing the next line on a syntax error */
|
||||
fstk_StopRept();
|
||||
}
|
||||
;
|
||||
@@ -686,6 +686,7 @@ line_directive : macrodef
|
||||
| rept
|
||||
| for
|
||||
| break
|
||||
| include
|
||||
| if
|
||||
/* It's important that all of these require being at line start for `skipIfBlock` */
|
||||
| elif
|
||||
@@ -807,8 +808,7 @@ assignment_directive : equ
|
||||
| equs
|
||||
;
|
||||
|
||||
directive : include
|
||||
| endc
|
||||
directive : endc
|
||||
| print
|
||||
| println
|
||||
| printf
|
||||
@@ -988,8 +988,10 @@ load : T_POP_LOAD sectmod string T_COMMA sectiontype sectorg sectattrs {
|
||||
|
||||
rept : T_POP_REPT uconst T_NEWLINE {
|
||||
lexer_CaptureRept(&captureBody);
|
||||
} T_NEWLINE {
|
||||
fstk_RunRept($2, captureBody.lineNo, captureBody.body, captureBody.size);
|
||||
} endofline {
|
||||
if (!captureBody.unterminated)
|
||||
fstk_RunRept($2, captureBody.lineNo, captureBody.body,
|
||||
captureBody.size);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -999,9 +1001,10 @@ for : T_POP_FOR {
|
||||
lexer_ToggleStringExpansion(true);
|
||||
} T_COMMA for_args T_NEWLINE {
|
||||
lexer_CaptureRept(&captureBody);
|
||||
} T_NEWLINE {
|
||||
fstk_RunFor($3, $6.start, $6.stop, $6.step, captureBody.lineNo,
|
||||
captureBody.body, captureBody.size);
|
||||
} endofline {
|
||||
if (!captureBody.unterminated)
|
||||
fstk_RunFor($3, $6.start, $6.stop, $6.step, captureBody.lineNo,
|
||||
captureBody.body, captureBody.size);
|
||||
}
|
||||
|
||||
for_args : const {
|
||||
@@ -1021,7 +1024,7 @@ for_args : const {
|
||||
}
|
||||
;
|
||||
|
||||
break : T_POP_BREAK T_NEWLINE {
|
||||
break : label T_POP_BREAK endofline {
|
||||
if (fstk_Break())
|
||||
lexer_SetMode(LEXER_SKIP_TO_ENDR);
|
||||
}
|
||||
@@ -1033,13 +1036,17 @@ macrodef : T_POP_MACRO {
|
||||
lexer_ToggleStringExpansion(true);
|
||||
} T_NEWLINE {
|
||||
lexer_CaptureMacroBody(&captureBody);
|
||||
} T_NEWLINE {
|
||||
sym_AddMacro($3, captureBody.lineNo, captureBody.body, captureBody.size);
|
||||
} endofline {
|
||||
if (!captureBody.unterminated)
|
||||
sym_AddMacro($3, captureBody.lineNo, captureBody.body,
|
||||
captureBody.size);
|
||||
}
|
||||
| T_LABEL T_COLON T_POP_MACRO T_NEWLINE {
|
||||
lexer_CaptureMacroBody(&captureBody);
|
||||
} T_NEWLINE {
|
||||
sym_AddMacro($1, captureBody.lineNo, captureBody.body, captureBody.size);
|
||||
} endofline {
|
||||
if (!captureBody.unterminated)
|
||||
sym_AddMacro($1, captureBody.lineNo, captureBody.body,
|
||||
captureBody.size);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1162,8 +1169,8 @@ export_list : export_list_entry
|
||||
export_list_entry : scoped_id { sym_Export($1); }
|
||||
;
|
||||
|
||||
include : T_POP_INCLUDE string {
|
||||
fstk_RunInclude($2);
|
||||
include : label T_POP_INCLUDE string endofline {
|
||||
fstk_RunInclude($3);
|
||||
if (failedOnMissingInclude)
|
||||
YYACCEPT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user