mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-26 04:52:08 +00:00
Reduce some more deep nesting
This commit is contained in:
@@ -149,14 +149,15 @@ static void alreadyDefinedError(Symbol const &sym, char const *asType) {
|
||||
fprintf(stderr, " as %s", asType);
|
||||
}
|
||||
dumpFilename(sym);
|
||||
if (sym.type == SYM_EQUS) {
|
||||
if (std::string const &contents = *sym.getEqus(); isValidIdentifier(contents)) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"\n (should it be {interpolated} to define its contents \"%s\"?)",
|
||||
contents.c_str()
|
||||
);
|
||||
}
|
||||
if (sym.type != SYM_EQUS) {
|
||||
return;
|
||||
}
|
||||
if (std::string const &contents = *sym.getEqus(); isValidIdentifier(contents)) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"\n (should it be {interpolated} to define its contents \"%s\"?)",
|
||||
contents.c_str()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -348,9 +348,8 @@ static void writeSymBank(SortedSections const &bankSections, SectionType type, u
|
||||
if (Symbol const *parentSym = sym_GetSymbol(parentName);
|
||||
parentSym && std::holds_alternative<Label>(parentSym->data)) {
|
||||
auto const &parentLabel = parentSym->label();
|
||||
assume(parentLabel.section != nullptr);
|
||||
parentAddr =
|
||||
static_cast<uint16_t>(parentLabel.offset + parentLabel.section->org);
|
||||
Section const &parentSection = *parentLabel.section;
|
||||
parentAddr = static_cast<uint16_t>(parentLabel.offset + parentSection.org);
|
||||
}
|
||||
}
|
||||
symList.push_back({.sym = sym, .addr = addr, .parentAddr = parentAddr});
|
||||
|
||||
@@ -58,13 +58,24 @@
|
||||
|
||||
%token YYEOF 0 "end of file"
|
||||
%token newline "end of line"
|
||||
|
||||
%token COMMA ","
|
||||
|
||||
// Keywords
|
||||
%token ORG "ORG"
|
||||
FLOATING "FLOATING"
|
||||
INCLUDE "INCLUDE"
|
||||
ALIGN "ALIGN"
|
||||
DS "DS"
|
||||
OPTIONAL "OPTIONAL"
|
||||
%token FLOATING "FLOATING"
|
||||
%token INCLUDE "INCLUDE"
|
||||
%token ALIGN "ALIGN"
|
||||
%token DS "DS"
|
||||
%token OPTIONAL "OPTIONAL"
|
||||
|
||||
// Literals
|
||||
%token <std::string> string;
|
||||
%token <uint32_t> number;
|
||||
%token <SectionType> sect_type;
|
||||
|
||||
%type <bool> optional;
|
||||
|
||||
%code {
|
||||
static std::array keywords{
|
||||
Keyword{"ORG"sv, yy::parser::make_ORG},
|
||||
@@ -75,11 +86,6 @@
|
||||
Keyword{"OPTIONAL"sv, yy::parser::make_OPTIONAL},
|
||||
};
|
||||
}
|
||||
%token <std::string> string;
|
||||
%token <uint32_t> number;
|
||||
%token <SectionType> sect_type;
|
||||
|
||||
%type <bool> optional;
|
||||
|
||||
%%
|
||||
|
||||
|
||||
Reference in New Issue
Block a user