mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix parsing of first line of included linkerscripts
When including a linkerscript from a parent one, the lexer didn't include a newline character because the INCLUDE command was handled before reaching the newline. This behaviour is needed to parse the last line of a linkerscript correctly (it doesn't have a newline character). However, this meant that when the included file was being parsed, the first line was considered a continuation of the last line of the parent script (the INCLUDE command), which means that the first line of an included linkerscript could only contain a comment (or nothing at all). This patch adds a newline character to the buffer used by the lexer so that the parser will receive a newline and it will handle the first line of the included file as expected. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
%option noinput
|
%option noinput
|
||||||
%option nounput
|
|
||||||
%option yylineno
|
%option yylineno
|
||||||
|
|
||||||
%{
|
%{
|
||||||
@@ -131,7 +130,22 @@ void script_IncludeFile(const char * path)
|
|||||||
include_path[include_stack_ptr][sizeof(include_path[0])-1] = '\0';
|
include_path[include_stack_ptr][sizeof(include_path[0])-1] = '\0';
|
||||||
|
|
||||||
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
||||||
yylineno = 0;
|
yylineno = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The INCLUDE keyword is handled before reaching a newline token, it's
|
||||||
|
* handled right after parsing the string with the file name that has to
|
||||||
|
* be included. It isn't actually needed to include a newline after the
|
||||||
|
* path, the last line of the linkerscript doesn't need to have a
|
||||||
|
* newline character but it can have a command.
|
||||||
|
*
|
||||||
|
* This means that, when opening a new file, we must tell the parser
|
||||||
|
* that what it is going to start at a new line or it will think that
|
||||||
|
* the first line of the included script is the continuation of the
|
||||||
|
* INCLUDE line of the parent script. If this is not done, the first
|
||||||
|
* line of an included linkerscript can only be a comment (or empty).
|
||||||
|
*/
|
||||||
|
unput('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
int script_IncludeDepthGet(void)
|
int script_IncludeDepthGet(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user