Rename parser value const to iconst to distinguish it from C++ keyword

This commit is contained in:
Rangi42
2024-12-23 09:21:30 -05:00
parent a7296ecb31
commit 36b04b5dea

View File

@@ -335,7 +335,7 @@
%type <Expression> reloc_16bit_no_str %type <Expression> reloc_16bit_no_str
// Constant numbers // Constant numbers
%type <int32_t> const %type <int32_t> iconst
%type <int32_t> const_no_str %type <int32_t> const_no_str
%type <int32_t> uconst %type <int32_t> uconst
// Constant numbers used only in specific contexts // Constant numbers used only in specific contexts
@@ -454,7 +454,7 @@ line_directive:
; ;
if: if:
POP_IF const NEWLINE { POP_IF iconst NEWLINE {
lexer_IncIFDepth(); lexer_IncIFDepth();
if ($2) if ($2)
@@ -465,7 +465,7 @@ if:
; ;
elif: elif:
POP_ELIF const NEWLINE { POP_ELIF iconst NEWLINE {
if (lexer_GetIFDepth() == 0) if (lexer_GetIFDepth() == 0)
fatalerror("Found ELIF outside of an IF construct\n"); fatalerror("Found ELIF outside of an IF construct\n");
@@ -700,7 +700,7 @@ align_spec:
$$.alignOfs = 0; $$.alignOfs = 0;
} }
} }
| uconst COMMA const { | uconst COMMA iconst {
if ($1 > 16) { if ($1 > 16) {
::error("Alignment must be between 0 and 16, not %u\n", $1); ::error("Alignment must be between 0 and 16, not %u\n", $1);
$$.alignment = $$.alignOfs = 0; $$.alignment = $$.alignOfs = 0;
@@ -817,11 +817,11 @@ assert:
failAssertMsg($2, $5); failAssertMsg($2, $5);
} }
} }
| POP_STATIC_ASSERT assert_type const { | POP_STATIC_ASSERT assert_type iconst {
if ($3 == 0) if ($3 == 0)
failAssert($2); failAssert($2);
} }
| POP_STATIC_ASSERT assert_type const COMMA string { | POP_STATIC_ASSERT assert_type iconst COMMA string {
if ($3 == 0) if ($3 == 0)
failAssertMsg($2, $5); failAssertMsg($2, $5);
} }
@@ -841,7 +841,7 @@ shift_const:
%empty { %empty {
$$ = 1; $$ = 1;
} }
| const | iconst
; ;
load: load:
@@ -878,17 +878,17 @@ capture_rept:
; ;
for_args: for_args:
const { iconst {
$$.start = 0; $$.start = 0;
$$.stop = $1; $$.stop = $1;
$$.step = 1; $$.step = 1;
} }
| const COMMA const { | iconst COMMA iconst {
$$.start = $1; $$.start = $1;
$$.stop = $3; $$.stop = $3;
$$.step = 1; $$.step = 1;
} }
| const COMMA const COMMA const { | iconst COMMA iconst COMMA iconst {
$$.start = $1; $$.start = $1;
$$.stop = $3; $$.stop = $3;
$$.step = $5; $$.step = $5;
@@ -1009,33 +1009,33 @@ dl:
; ;
def_equ: def_equ:
def_id POP_EQU const { def_id POP_EQU iconst {
$$ = std::move($1); $$ = std::move($1);
sym_AddEqu($$, $3); sym_AddEqu($$, $3);
} }
; ;
redef_equ: redef_equ:
redef_id POP_EQU const { redef_id POP_EQU iconst {
$$ = std::move($1); $$ = std::move($1);
sym_RedefEqu($$, $3); sym_RedefEqu($$, $3);
} }
; ;
def_set: def_set:
def_id POP_EQUAL const { def_id POP_EQUAL iconst {
$$ = std::move($1); $$ = std::move($1);
sym_AddVar($$, $3); sym_AddVar($$, $3);
} }
| redef_id POP_EQUAL const { | redef_id POP_EQUAL iconst {
$$ = std::move($1); $$ = std::move($1);
sym_AddVar($$, $3); sym_AddVar($$, $3);
} }
| def_id compound_eq const { | def_id compound_eq iconst {
$$ = std::move($1); $$ = std::move($1);
compoundAssignment($$, $2, $3); compoundAssignment($$, $2, $3);
} }
| redef_id compound_eq const { | redef_id compound_eq iconst {
$$ = std::move($1); $$ = std::move($1);
compoundAssignment($$, $2, $3); compoundAssignment($$, $2, $3);
} }
@@ -1135,12 +1135,12 @@ incbin:
if (failedOnMissingInclude) if (failedOnMissingInclude)
YYACCEPT; YYACCEPT;
} }
| POP_INCBIN string COMMA const { | POP_INCBIN string COMMA iconst {
sect_BinaryFile($2, $4); sect_BinaryFile($2, $4);
if (failedOnMissingInclude) if (failedOnMissingInclude)
YYACCEPT; YYACCEPT;
} }
| POP_INCBIN string COMMA const COMMA const { | POP_INCBIN string COMMA iconst COMMA iconst {
sect_BinaryFileSlice($2, $4, $6); sect_BinaryFileSlice($2, $4, $6);
if (failedOnMissingInclude) if (failedOnMissingInclude)
YYACCEPT; YYACCEPT;
@@ -1154,10 +1154,10 @@ charmap:
; ;
charmap_args: charmap_args:
const { iconst {
$$.push_back(std::move($1)); $$.push_back(std::move($1));
} }
| charmap_args COMMA const { | charmap_args COMMA iconst {
$$ = std::move($1); $$ = std::move($1);
$$.push_back(std::move($3)); $$.push_back(std::move($3));
} }
@@ -1226,7 +1226,7 @@ print_expr:
; ;
bit_const: bit_const:
const { iconst {
$$ = $1; $$ = $1;
if ($$ < 0 || $$ > 7) { if ($$ < 0 || $$ > 7) {
::error("Bit number must be between 0 and 7, not %" PRId32 "\n", $$); ::error("Bit number must be between 0 and 7, not %" PRId32 "\n", $$);
@@ -1448,49 +1448,49 @@ relocexpr_no_str:
$$.makeNumber(sym_FindScopedValidSymbol($4) != nullptr); $$.makeNumber(sym_FindScopedValidSymbol($4) != nullptr);
lexer_ToggleStringExpansion(true); lexer_ToggleStringExpansion(true);
} }
| OP_ROUND LPAREN const precision_arg RPAREN { | OP_ROUND LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_Round($3, $4)); $$.makeNumber(fix_Round($3, $4));
} }
| OP_CEIL LPAREN const precision_arg RPAREN { | OP_CEIL LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_Ceil($3, $4)); $$.makeNumber(fix_Ceil($3, $4));
} }
| OP_FLOOR LPAREN const precision_arg RPAREN { | OP_FLOOR LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_Floor($3, $4)); $$.makeNumber(fix_Floor($3, $4));
} }
| OP_FDIV LPAREN const COMMA const precision_arg RPAREN { | OP_FDIV LPAREN iconst COMMA iconst precision_arg RPAREN {
$$.makeNumber(fix_Div($3, $5, $6)); $$.makeNumber(fix_Div($3, $5, $6));
} }
| OP_FMUL LPAREN const COMMA const precision_arg RPAREN { | OP_FMUL LPAREN iconst COMMA iconst precision_arg RPAREN {
$$.makeNumber(fix_Mul($3, $5, $6)); $$.makeNumber(fix_Mul($3, $5, $6));
} }
| OP_FMOD LPAREN const COMMA const precision_arg RPAREN { | OP_FMOD LPAREN iconst COMMA iconst precision_arg RPAREN {
$$.makeNumber(fix_Mod($3, $5, $6)); $$.makeNumber(fix_Mod($3, $5, $6));
} }
| OP_POW LPAREN const COMMA const precision_arg RPAREN { | OP_POW LPAREN iconst COMMA iconst precision_arg RPAREN {
$$.makeNumber(fix_Pow($3, $5, $6)); $$.makeNumber(fix_Pow($3, $5, $6));
} }
| OP_LOG LPAREN const COMMA const precision_arg RPAREN { | OP_LOG LPAREN iconst COMMA iconst precision_arg RPAREN {
$$.makeNumber(fix_Log($3, $5, $6)); $$.makeNumber(fix_Log($3, $5, $6));
} }
| OP_SIN LPAREN const precision_arg RPAREN { | OP_SIN LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_Sin($3, $4)); $$.makeNumber(fix_Sin($3, $4));
} }
| OP_COS LPAREN const precision_arg RPAREN { | OP_COS LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_Cos($3, $4)); $$.makeNumber(fix_Cos($3, $4));
} }
| OP_TAN LPAREN const precision_arg RPAREN { | OP_TAN LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_Tan($3, $4)); $$.makeNumber(fix_Tan($3, $4));
} }
| OP_ASIN LPAREN const precision_arg RPAREN { | OP_ASIN LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_ASin($3, $4)); $$.makeNumber(fix_ASin($3, $4));
} }
| OP_ACOS LPAREN const precision_arg RPAREN { | OP_ACOS LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_ACos($3, $4)); $$.makeNumber(fix_ACos($3, $4));
} }
| OP_ATAN LPAREN const precision_arg RPAREN { | OP_ATAN LPAREN iconst precision_arg RPAREN {
$$.makeNumber(fix_ATan($3, $4)); $$.makeNumber(fix_ATan($3, $4));
} }
| OP_ATAN2 LPAREN const COMMA const precision_arg RPAREN { | OP_ATAN2 LPAREN iconst COMMA iconst precision_arg RPAREN {
$$.makeNumber(fix_ATan2($3, $5, $6)); $$.makeNumber(fix_ATan2($3, $5, $6));
} }
| OP_STRCMP LPAREN string COMMA string RPAREN { | OP_STRCMP LPAREN string COMMA string RPAREN {
@@ -1521,14 +1521,14 @@ relocexpr_no_str:
; ;
uconst: uconst:
const { iconst {
$$ = $1; $$ = $1;
if ($$ < 0) if ($$ < 0)
fatalerror("Constant must not be negative: %d\n", $$); fatalerror("Constant must not be negative: %d\n", $$);
} }
; ;
const: iconst:
relocexpr { relocexpr {
$$ = $1.getConstVal(); $$ = $1.getConstVal();
} }
@@ -1544,7 +1544,7 @@ precision_arg:
%empty { %empty {
$$ = fix_Precision(); $$ = fix_Precision();
} }
| COMMA const { | COMMA iconst {
$$ = $2; $$ = $2;
if ($$ < 1 || $$ > 31) { if ($$ < 1 || $$ > 31) {
::error("Fixed-point precision must be between 1 and 31, not %" PRId32 "\n", $$); ::error("Fixed-point precision must be between 1 and 31, not %" PRId32 "\n", $$);
@@ -1557,19 +1557,19 @@ string:
STRING { STRING {
$$ = std::move($1); $$ = std::move($1);
} }
| OP_STRSUB LPAREN string COMMA const COMMA uconst RPAREN { | OP_STRSUB LPAREN string COMMA iconst COMMA uconst RPAREN {
size_t len = strlenUTF8($3); size_t len = strlenUTF8($3);
uint32_t pos = adjustNegativePos($5, len, "STRSUB"); uint32_t pos = adjustNegativePos($5, len, "STRSUB");
$$ = strsubUTF8($3, pos, $7); $$ = strsubUTF8($3, pos, $7);
} }
| OP_STRSUB LPAREN string COMMA const RPAREN { | OP_STRSUB LPAREN string COMMA iconst RPAREN {
size_t len = strlenUTF8($3); size_t len = strlenUTF8($3);
uint32_t pos = adjustNegativePos($5, len, "STRSUB"); uint32_t pos = adjustNegativePos($5, len, "STRSUB");
$$ = strsubUTF8($3, pos, pos > len ? 0 : len + 1 - pos); $$ = strsubUTF8($3, pos, pos > len ? 0 : len + 1 - pos);
} }
| OP_CHARSUB LPAREN string COMMA const RPAREN { | OP_CHARSUB LPAREN string COMMA iconst RPAREN {
size_t len = charlenUTF8($3); size_t len = charlenUTF8($3);
uint32_t pos = adjustNegativePos($5, len, "CHARSUB"); uint32_t pos = adjustNegativePos($5, len, "CHARSUB");
@@ -1981,7 +1981,7 @@ z80_ldh:
c_ind: c_ind:
LBRACK MODE_C RBRACK LBRACK MODE_C RBRACK
| LBRACK relocexpr OP_ADD MODE_C RBRACK { | LBRACK relocexpr OP_ADD MODE_C RBRACK {
// This has to use `relocexpr`, not `const`, to avoid a shift/reduce conflict // This has to use `relocexpr`, not `iconst`, to avoid a shift/reduce conflict
if ($2.getConstVal() != 0xFF00) if ($2.getConstVal() != 0xFF00)
::error("Base value must be equal to $FF00 for $FF00+C\n"); ::error("Base value must be equal to $FF00 for $FF00+C\n");
} }