Remove a little no-longer-necessary header boilerplate

This commit is contained in:
Rangi42
2025-07-29 11:08:23 -04:00
parent 5d6e571338
commit 6d05de9d4d

View File

@@ -15,9 +15,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unordered_map> #include <unordered_map>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include "helpers.hpp" #include "helpers.hpp"
#include "util.hpp" #include "util.hpp"
@@ -33,8 +30,6 @@
// Include this last so it gets all type & constant definitions // Include this last so it gets all type & constant definitions
#include "parser.hpp" // For token definitions, generated from parser.y #include "parser.hpp" // For token definitions, generated from parser.y
using namespace std::literals;
// Bison 3.6 changed token "types" to "kinds"; cast to int for simple compatibility // Bison 3.6 changed token "types" to "kinds"; cast to int for simple compatibility
#define T_(name) static_cast<int>(yy::parser::token::name) #define T_(name) static_cast<int>(yy::parser::token::name)
@@ -562,9 +557,7 @@ static uint32_t readBracketedMacroArgNum() {
symName += c; symName += c;
} }
Symbol const *sym = sym_FindScopedValidSymbol(symName); if (Symbol const *sym = sym_FindScopedValidSymbol(symName); !sym) {
if (!sym) {
if (sym_IsPurgedScoped(symName)) { if (sym_IsPurgedScoped(symName)) {
error("Bracketed symbol \"%s\" does not exist; it was purged", symName.c_str()); error("Bracketed symbol \"%s\" does not exist; it was purged", symName.c_str());
} else { } else {
@@ -884,9 +877,7 @@ static void discardBlockComment() {
static void discardComment() { static void discardComment() {
Defer reenableExpansions = scopedDisableExpansions(); Defer reenableExpansions = scopedDisableExpansions();
for (;; shiftChar()) { for (;; shiftChar()) {
int c = peek(); if (int c = peek(); c == EOF || c == '\r' || c == '\n') {
if (c == EOF || c == '\r' || c == '\n') {
break; break;
} }
} }
@@ -894,9 +885,7 @@ static void discardComment() {
static void discardLineContinuation() { static void discardLineContinuation() {
for (;;) { for (;;) {
int c = peek(); if (int c = peek(); isWhitespace(c)) {
if (isWhitespace(c)) {
shiftChar(); shiftChar();
} else if (c == '\r' || c == '\n') { } else if (c == '\r' || c == '\n') {
shiftChar(); shiftChar();
@@ -1277,9 +1266,7 @@ static std::shared_ptr<std::string> readInterpolation(size_t depth) {
return nullptr; return nullptr;
} }
Symbol const *sym = sym_FindScopedValidSymbol(fmtBuf); if (Symbol const *sym = sym_FindScopedValidSymbol(fmtBuf); !sym || !sym->isDefined()) {
if (!sym || !sym->isDefined()) {
if (sym_IsPurgedScoped(fmtBuf)) { if (sym_IsPurgedScoped(fmtBuf)) {
error("Interpolated symbol \"%s\" does not exist; it was purged", fmtBuf.c_str()); error("Interpolated symbol \"%s\" does not exist; it was purged", fmtBuf.c_str());
} else { } else {
@@ -1901,9 +1888,8 @@ static Token yylex_NORMAL() {
// Raw symbols and local symbols cannot be string expansions // Raw symbols and local symbols cannot be string expansions
if (!raw && token.type == T_(SYMBOL) && lexerState->expandStrings) { if (!raw && token.type == T_(SYMBOL) && lexerState->expandStrings) {
// Attempt string expansion // Attempt string expansion
Symbol const *sym = sym_FindExactSymbol(std::get<std::string>(token.value)); if (Symbol const *sym = sym_FindExactSymbol(std::get<std::string>(token.value));
sym && sym->type == SYM_EQUS) {
if (sym && sym->type == SYM_EQUS) {
beginExpansion(sym->getEqus(), sym->name); beginExpansion(sym->getEqus(), sym->name);
return yylex_NORMAL(); // Tail recursion return yylex_NORMAL(); // Tail recursion
} }