mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Handle missing newline at EOF for linkerscript INCLUDEd files (#1691)
This commit is contained in:
@@ -251,10 +251,16 @@ yy::parser::symbol_type yylex() {
|
|||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
// Basically yywrap().
|
// Basically yywrap().
|
||||||
if (lexerStack.size() != 1) {
|
if (lexerStack.size() != 1) {
|
||||||
lexerStack.pop_back();
|
if (!atEof) {
|
||||||
return yylex();
|
// Inject a newline at EOF to simplify parsing.
|
||||||
|
atEof = true;
|
||||||
|
return yy::parser::make_newline();
|
||||||
|
} else {
|
||||||
|
lexerStack.pop_back();
|
||||||
|
return yylex();
|
||||||
|
}
|
||||||
} else if (!atEof) {
|
} else if (!atEof) {
|
||||||
// Inject a newline at EOF, to avoid errors for files that don't end with one.
|
// Inject a newline at EOF to simplify parsing.
|
||||||
atEof = true;
|
atEof = true;
|
||||||
return yy::parser::make_newline();
|
return yy::parser::make_newline();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
2
test/link/script-include/a.asm
Normal file
2
test/link/script-include/a.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
section "a", rom0
|
||||||
|
db $11
|
||||||
3
test/link/script-include/a.inc
Normal file
3
test/link/script-include/a.inc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
rom0
|
||||||
|
org 0
|
||||||
|
"a" ; no newline
|
||||||
2
test/link/script-include/b.asm
Normal file
2
test/link/script-include/b.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
section "b", rom0
|
||||||
|
db $22
|
||||||
3
test/link/script-include/b.inc
Normal file
3
test/link/script-include/b.inc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
rom0
|
||||||
|
org 1
|
||||||
|
"b" ; yes newline
|
||||||
0
test/link/script-include/out.err
Normal file
0
test/link/script-include/out.err
Normal file
1
test/link/script-include/ref.out.bin
Normal file
1
test/link/script-include/ref.out.bin
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"
|
||||||
2
test/link/script-include/script.link
Normal file
2
test/link/script-include/script.link
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
include "script-include/a.inc"
|
||||||
|
include "script-include/b.inc"
|
||||||
@@ -262,6 +262,16 @@ tryDiff "$test"/out.err "$outtemp"
|
|||||||
tryCmpRomSize "$gbtemp" 65536
|
tryCmpRomSize "$gbtemp" 65536
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
|
test="script-include"
|
||||||
|
startTest
|
||||||
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
|
continueTest
|
||||||
|
rgblinkQuiet -o "$gbtemp" -l "$test"/script.link "$otemp" "$gbtemp2" 2>"$outtemp"
|
||||||
|
tryDiff "$test"/out.err "$outtemp"
|
||||||
|
tryCmpRom "$test"/ref.out.bin
|
||||||
|
evaluateTest
|
||||||
|
|
||||||
test="sdcc/good"
|
test="sdcc/good"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
|||||||
Reference in New Issue
Block a user