mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix whitespace
Replace spaces by tabs for consistency. The rest of the codebase uses tabs, so the linkerscript parser has to change. Removed trailing tabs in all codebase. Signed-off-by: AntonioND <antonio_nd@outlook.com>
This commit is contained in:
@@ -118,7 +118,6 @@ ULONG str2int2( char *s, int length )
|
||||
r<<=8;
|
||||
r|=(UBYTE)(s[i]);
|
||||
i++;
|
||||
|
||||
}
|
||||
return( r );
|
||||
}
|
||||
|
||||
@@ -28,48 +28,48 @@
|
||||
|
||||
%%
|
||||
|
||||
\"([^\\\"]|\\.)*\" {
|
||||
if (strlen(yytext) > sizeof(yylval.s) - 1)
|
||||
errx(1, "String is too long: \"%s\"\n.", yytext);
|
||||
if (strlen(yytext) < 3) /* 2 quotes + 1 character */
|
||||
errx(1, "String \"%s\" is invalid\n.", yytext);
|
||||
\"([^\\\"]|\\.)*\" {
|
||||
if (strlen(yytext) > sizeof(yylval.s) - 1)
|
||||
errx(1, "String is too long: \"%s\"\n.", yytext);
|
||||
if (strlen(yytext) < 3) /* 2 quotes + 1 character */
|
||||
errx(1, "String \"%s\" is invalid\n.", yytext);
|
||||
|
||||
yytext++; /* ignore first quote */
|
||||
strcpy(yylval.s, yytext);
|
||||
yylval.s[strlen(yylval.s)-1] = '\0'; /* remove end quote */
|
||||
yytext++; /* ignore first quote */
|
||||
strcpy(yylval.s, yytext);
|
||||
yylval.s[strlen(yylval.s)-1] = '\0'; /* remove end quote */
|
||||
|
||||
return STRING;
|
||||
}
|
||||
return STRING;
|
||||
}
|
||||
|
||||
\$[a-fA-F0-9]+ {
|
||||
yytext++; /* Skip prefix */
|
||||
yylval.i = strtol(yytext, NULL, 16);
|
||||
return INTEGER;
|
||||
}
|
||||
[0-9]+ {
|
||||
yylval.i = strtol(yytext, NULL, 10);
|
||||
return INTEGER;
|
||||
}
|
||||
\$[a-fA-F0-9]+ {
|
||||
yytext++; /* Skip prefix */
|
||||
yylval.i = strtol(yytext, NULL, 16);
|
||||
return INTEGER;
|
||||
}
|
||||
[0-9]+ {
|
||||
yylval.i = strtol(yytext, NULL, 10);
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
(?i:ROM0) { strcpy(yylval.s, "ROM0"); return SECTION_NONBANKED; }
|
||||
(?i:ROMX) { strcpy(yylval.s, "ROMX"); return SECTION_BANKED; }
|
||||
(?i:VRAM) { strcpy(yylval.s, "VRAM"); return SECTION_BANKED; }
|
||||
(?i:WRAM0) { strcpy(yylval.s, "WRAM0"); return SECTION_NONBANKED; }
|
||||
(?i:WRAMX) { strcpy(yylval.s, "WRAMX"); return SECTION_BANKED; }
|
||||
(?i:SRAM) { strcpy(yylval.s, "SRAM"); return SECTION_BANKED; }
|
||||
(?i:OAM) { strcpy(yylval.s, "OAM"); return SECTION_NONBANKED; }
|
||||
(?i:HRAM) { strcpy(yylval.s, "HRAM"); return SECTION_NONBANKED; }
|
||||
(?i:ROM0) { strcpy(yylval.s, "ROM0"); return SECTION_NONBANKED; }
|
||||
(?i:ROMX) { strcpy(yylval.s, "ROMX"); return SECTION_BANKED; }
|
||||
(?i:VRAM) { strcpy(yylval.s, "VRAM"); return SECTION_BANKED; }
|
||||
(?i:WRAM0) { strcpy(yylval.s, "WRAM0"); return SECTION_NONBANKED; }
|
||||
(?i:WRAMX) { strcpy(yylval.s, "WRAMX"); return SECTION_BANKED; }
|
||||
(?i:SRAM) { strcpy(yylval.s, "SRAM"); return SECTION_BANKED; }
|
||||
(?i:OAM) { strcpy(yylval.s, "OAM"); return SECTION_NONBANKED; }
|
||||
(?i:HRAM) { strcpy(yylval.s, "HRAM"); return SECTION_NONBANKED; }
|
||||
|
||||
(?i:ALIGN) { return COMMAND_ALIGN; }
|
||||
(?i:ORG) { return COMMAND_ORG; }
|
||||
(?i:ALIGN) { return COMMAND_ALIGN; }
|
||||
(?i:ORG) { return COMMAND_ORG; }
|
||||
|
||||
"\n" { return NEWLINE; }
|
||||
"\n" { return NEWLINE; }
|
||||
|
||||
;.* { /* Ignore comments. A dot doesn't match newline. */ }
|
||||
;.* { /* Ignore comments. A dot doesn't match newline. */ }
|
||||
|
||||
[[:space:]] { /* Ignore whitespace. */ }
|
||||
[[:space:]] { /* Ignore whitespace. */ }
|
||||
|
||||
. { errx(1, "Invalid character [%s]\n.", yytext); }
|
||||
. { errx(1, "Invalid character [%s]\n.", yytext); }
|
||||
|
||||
%%
|
||||
|
||||
|
||||
@@ -100,7 +100,6 @@ Output(void)
|
||||
FILE *f;
|
||||
FILE *f_overlay = NULL;
|
||||
|
||||
|
||||
if ((f = fopen(tzOutname, "wb"))) {
|
||||
if (tzOverlayname) {
|
||||
f_overlay = fopen(tzOverlayname, "rb");
|
||||
|
||||
@@ -44,52 +44,52 @@ static int nline = 1;
|
||||
%%
|
||||
|
||||
lines:
|
||||
/* empty */
|
||||
| lines line NEWLINE
|
||||
;
|
||||
/* empty */
|
||||
| lines line NEWLINE
|
||||
;
|
||||
|
||||
line:
|
||||
/* empty */ { nline++; }
|
||||
| statement { nline++; }
|
||||
;
|
||||
/* empty */ { nline++; }
|
||||
| statement { nline++; }
|
||||
;
|
||||
|
||||
statement:
|
||||
/* Statements to set the current section */
|
||||
SECTION_NONBANKED {
|
||||
script_SetCurrentSectionType($1, 0);
|
||||
}
|
||||
| SECTION_NONBANKED INTEGER {
|
||||
errx(1, "%d:Trying to assign a bank to a non-banked section.\n", nline);
|
||||
}
|
||||
/* Statements to set the current section */
|
||||
SECTION_NONBANKED {
|
||||
script_SetCurrentSectionType($1, 0);
|
||||
}
|
||||
| SECTION_NONBANKED INTEGER {
|
||||
errx(1, "%d:Trying to assign a bank to a non-banked section.\n", nline);
|
||||
}
|
||||
|
||||
| SECTION_BANKED {
|
||||
errx(1, "%d:Banked section without assigned bank.\n", nline);
|
||||
}
|
||||
| SECTION_BANKED INTEGER {
|
||||
script_SetCurrentSectionType($1, $2);
|
||||
}
|
||||
| SECTION_BANKED {
|
||||
errx(1, "%d:Banked section without assigned bank.\n", nline);
|
||||
}
|
||||
| SECTION_BANKED INTEGER {
|
||||
script_SetCurrentSectionType($1, $2);
|
||||
}
|
||||
|
||||
/* Commands to adjust the address inside the current section */
|
||||
| COMMAND_ALIGN INTEGER {
|
||||
script_SetAlignment($2);
|
||||
}
|
||||
| COMMAND_ALIGN {
|
||||
errx(1, "%d:ALIGN keyword needs an argument.\n", nline);
|
||||
}
|
||||
| COMMAND_ORG INTEGER {
|
||||
script_SetAddress($2);
|
||||
}
|
||||
| COMMAND_ORG {
|
||||
errx(1, "%d:ORG keyword needs an argument.\n", nline);
|
||||
}
|
||||
/* Commands to adjust the address inside the current section */
|
||||
| COMMAND_ALIGN INTEGER {
|
||||
script_SetAlignment($2);
|
||||
}
|
||||
| COMMAND_ALIGN {
|
||||
errx(1, "%d:ALIGN keyword needs an argument.\n", nline);
|
||||
}
|
||||
| COMMAND_ORG INTEGER {
|
||||
script_SetAddress($2);
|
||||
}
|
||||
| COMMAND_ORG {
|
||||
errx(1, "%d:ORG keyword needs an argument.\n", nline);
|
||||
}
|
||||
|
||||
/* Section name */
|
||||
| STRING {
|
||||
script_OutputSection($1);
|
||||
}
|
||||
/* Section name */
|
||||
| STRING {
|
||||
script_OutputSection($1);
|
||||
}
|
||||
|
||||
/* End */
|
||||
;
|
||||
/* End */
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
@@ -100,24 +100,24 @@ extern FILE *yyin;
|
||||
|
||||
void yyerror(char *s)
|
||||
{
|
||||
errx(1, "%d:Linkerscript parse error: \"%s\"\n", nline, s);
|
||||
errx(1, "%d:Linkerscript parse error: \"%s\"\n", nline, s);
|
||||
}
|
||||
|
||||
void script_Parse(const char *path)
|
||||
{
|
||||
script_InitSections();
|
||||
script_InitSections();
|
||||
|
||||
FILE *f = fopen(path, "r");
|
||||
FILE *f = fopen(path, "r");
|
||||
|
||||
if (!f)
|
||||
errx(1, "Error opening file! \"%s\"\n", path);
|
||||
if (!f)
|
||||
errx(1, "Error opening file! \"%s\"\n", path);
|
||||
|
||||
yyin = f;
|
||||
yyin = f;
|
||||
|
||||
do {
|
||||
yyparse();
|
||||
} while (!feof(yyin));
|
||||
do {
|
||||
yyparse();
|
||||
} while (!feof(yyin));
|
||||
|
||||
fclose(f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user