Rename nextChar to bumpChar in the RGBASM lexer for symmetry with std::filebuf in the RGBLINK lexer

This commit is contained in:
Rangi42
2025-07-20 11:02:02 -04:00
parent 0681110647
commit 169ac61e14

View File

@@ -599,7 +599,7 @@ static bool isMacroChar(char c) {
// forward declarations for readBracketedMacroArgNum // forward declarations for readBracketedMacroArgNum
static int peek(); static int peek();
static void shiftChar(); static void shiftChar();
static int nextChar(); static int bumpChar();
static uint32_t readDecimalNumber(int initial); static uint32_t readDecimalNumber(int initial);
static uint32_t readBracketedMacroArgNum() { static uint32_t readBracketedMacroArgNum() {
@@ -684,7 +684,7 @@ static uint32_t readBracketedMacroArgNum() {
} }
static std::shared_ptr<std::string> readMacroArg() { static std::shared_ptr<std::string> readMacroArg() {
int name = nextChar(); int name = bumpChar();
if (name == '@') { if (name == '@') {
std::shared_ptr<std::string> str = fstk_GetUniqueIDStr(); std::shared_ptr<std::string> str = fstk_GetUniqueIDStr();
if (!str) { if (!str) {
@@ -879,7 +879,7 @@ static void shiftChar() {
} }
} }
static int nextChar() { static int bumpChar() {
int c = peek(); int c = peek();
if (c != EOF) { if (c != EOF) {
shiftChar(); shiftChar();
@@ -935,7 +935,7 @@ void lexer_DumpStringExpansions() {
static void discardBlockComment() { static void discardBlockComment() {
Defer reenableExpansions = scopedDisableExpansions(); Defer reenableExpansions = scopedDisableExpansions();
for (;;) { for (;;) {
int c = nextChar(); int c = bumpChar();
switch (c) { switch (c) {
case EOF: case EOF:
@@ -1670,7 +1670,7 @@ static void reportGarbageCharacters(int c) {
// At least two characters are garbage; group them into one error report // At least two characters are garbage; group them into one error report
std::string garbage = printChar(c); std::string garbage = printChar(c);
while (isGarbageCharacter(peek())) { while (isGarbageCharacter(peek())) {
c = nextChar(); c = bumpChar();
garbage += ", "; garbage += ", ";
garbage += printChar(c); garbage += printChar(c);
} }
@@ -1687,7 +1687,7 @@ static Token yylex_NORMAL() {
} }
for (;; lexerState->atLineStart = false) { for (;; lexerState->atLineStart = false) {
int c = nextChar(); int c = bumpChar();
switch (c) { switch (c) {
// Ignore whitespace and comments // Ignore whitespace and comments
@@ -1983,7 +1983,7 @@ static Token yylex_NORMAL() {
default: default:
bool raw = c == '#'; bool raw = c == '#';
if (raw && startsIdentifier(peek())) { if (raw && startsIdentifier(peek())) {
c = nextChar(); c = bumpChar();
} else if (!startsIdentifier(c)) { } else if (!startsIdentifier(c)) {
// Do not report weird characters when capturing, it'll be done later // Do not report weird characters when capturing, it'll be done later
if (!lexerState->capturing) { if (!lexerState->capturing) {
@@ -2236,13 +2236,13 @@ static Token skipIfBlock(bool toEndc) {
for (int c;; atLineStart = false) { for (int c;; atLineStart = false) {
// Read chars until EOL // Read chars until EOL
while (!atLineStart) { while (!atLineStart) {
c = nextChar(); c = bumpChar();
if (c == EOF) { if (c == EOF) {
return Token(T_(YYEOF)); return Token(T_(YYEOF));
} else if (c == '\\') { } else if (c == '\\') {
// Unconditionally skip the next char, including line continuations // Unconditionally skip the next char, including line continuations
c = nextChar(); c = bumpChar();
} else if (c == '\r' || c == '\n') { } else if (c == '\r' || c == '\n') {
atLineStart = true; atLineStart = true;
} }
@@ -2324,13 +2324,13 @@ static Token yylex_SKIP_TO_ENDR() {
for (int c;; atLineStart = false) { for (int c;; atLineStart = false) {
// Read chars until EOL // Read chars until EOL
while (!atLineStart) { while (!atLineStart) {
c = nextChar(); c = bumpChar();
if (c == EOF) { if (c == EOF) {
return Token(T_(YYEOF)); return Token(T_(YYEOF));
} else if (c == '\\') { } else if (c == '\\') {
// Unconditionally skip the next char, including line continuations // Unconditionally skip the next char, including line continuations
c = nextChar(); c = bumpChar();
} else if (c == '\r' || c == '\n') { } else if (c == '\r' || c == '\n') {
atLineStart = true; atLineStart = true;
} }
@@ -2469,7 +2469,7 @@ Capture lexer_CaptureRept() {
nextLine(); nextLine();
// We're at line start, so attempt to match a `REPT` or `ENDR` token // We're at line start, so attempt to match a `REPT` or `ENDR` token
do { // Discard initial whitespace do { // Discard initial whitespace
c = nextChar(); c = bumpChar();
} while (isWhitespace(c)); } while (isWhitespace(c));
// Now, try to match `REPT`, `FOR` or `ENDR` as a **whole** keyword // Now, try to match `REPT`, `FOR` or `ENDR` as a **whole** keyword
if (startsIdentifier(c)) { if (startsIdentifier(c)) {
@@ -2496,7 +2496,7 @@ Capture lexer_CaptureRept() {
} }
// Just consume characters until EOL or EOF // Just consume characters until EOL or EOF
for (;; c = nextChar()) { for (;; c = bumpChar()) {
if (c == EOF) { if (c == EOF) {
error("Unterminated REPT/FOR block"); error("Unterminated REPT/FOR block");
endCapture(capture); endCapture(capture);
@@ -2519,7 +2519,7 @@ Capture lexer_CaptureMacro() {
nextLine(); nextLine();
// We're at line start, so attempt to match an `ENDM` token // We're at line start, so attempt to match an `ENDM` token
do { // Discard initial whitespace do { // Discard initial whitespace
c = nextChar(); c = bumpChar();
} while (isWhitespace(c)); } while (isWhitespace(c));
// Now, try to match `ENDM` as a **whole** keyword // Now, try to match `ENDM` as a **whole** keyword
if (startsIdentifier(c) && readIdentifier(c, false).type == T_(POP_ENDM)) { if (startsIdentifier(c) && readIdentifier(c, false).type == T_(POP_ENDM)) {
@@ -2531,7 +2531,7 @@ Capture lexer_CaptureMacro() {
} }
// Just consume characters until EOL or EOF // Just consume characters until EOL or EOF
for (;; c = nextChar()) { for (;; c = bumpChar()) {
if (c == EOF) { if (c == EOF) {
error("Unterminated macro definition"); error("Unterminated macro definition");
endCapture(capture); endCapture(capture);