Avoid Windows macros in the parser and lexer

`FLOAT`, `INT`, and `IN` are identifers taken by macros.

The name `IN_KW` is chosen to match `OR_KW`, which is presumably named
that way for the same reason of dodging macros.
This commit is contained in:
John Ericson 2024-01-12 19:46:48 -05:00
parent 381df7b9c9
commit e739a5002d
2 changed files with 9 additions and 9 deletions

View file

@ -130,7 +130,7 @@ else { return ELSE; }
assert { return ASSERT; } assert { return ASSERT; }
with { return WITH; } with { return WITH; }
let { return LET; } let { return LET; }
in { return IN; } in { return IN_KW; }
rec { return REC; } rec { return REC; }
inherit { return INHERIT; } inherit { return INHERIT; }
or { return OR_KW; } or { return OR_KW; }
@ -156,7 +156,7 @@ or { return OR_KW; }
.errPos = data->state.positions[CUR_POS], .errPos = data->state.positions[CUR_POS],
}); });
} }
return INT; return INT_LIT;
} }
{FLOAT} { errno = 0; {FLOAT} { errno = 0;
yylval->nf = strtod(yytext, 0); yylval->nf = strtod(yytext, 0);
@ -165,7 +165,7 @@ or { return OR_KW; }
.msg = hintfmt("invalid float '%1%'", yytext), .msg = hintfmt("invalid float '%1%'", yytext),
.errPos = data->state.positions[CUR_POS], .errPos = data->state.positions[CUR_POS],
}); });
return FLOAT; return FLOAT_LIT;
} }
\$\{ { PUSH_STATE(DEFAULT); return DOLLAR_CURLY; } \$\{ { PUSH_STATE(DEFAULT); return DOLLAR_CURLY; }

View file

@ -365,11 +365,11 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err
%type <id> attr %type <id> attr
%token <id> ID %token <id> ID
%token <str> STR IND_STR %token <str> STR IND_STR
%token <n> INT %token <n> INT_LIT
%token <nf> FLOAT %token <nf> FLOAT_LIT
%token <path> PATH HPATH SPATH PATH_END %token <path> PATH HPATH SPATH PATH_END
%token <uri> URI %token <uri> URI
%token IF THEN ELSE ASSERT WITH LET IN REC INHERIT EQ NEQ AND OR IMPL OR_KW %token IF THEN ELSE ASSERT WITH LET IN_KW REC INHERIT EQ NEQ AND OR IMPL OR_KW
%token DOLLAR_CURLY /* == ${ */ %token DOLLAR_CURLY /* == ${ */
%token IND_STRING_OPEN IND_STRING_CLOSE %token IND_STRING_OPEN IND_STRING_CLOSE
%token ELLIPSIS %token ELLIPSIS
@ -412,7 +412,7 @@ expr_function
{ $$ = new ExprAssert(CUR_POS, $2, $4); } { $$ = new ExprAssert(CUR_POS, $2, $4); }
| WITH expr ';' expr_function | WITH expr ';' expr_function
{ $$ = new ExprWith(CUR_POS, $2, $4); } { $$ = new ExprWith(CUR_POS, $2, $4); }
| LET binds IN expr_function | LET binds IN_KW expr_function
{ if (!$2->dynamicAttrs.empty()) { if (!$2->dynamicAttrs.empty())
throw ParseError({ throw ParseError({
.msg = hintfmt("dynamic attributes not allowed in let"), .msg = hintfmt("dynamic attributes not allowed in let"),
@ -482,8 +482,8 @@ expr_simple
else else
$$ = new ExprVar(CUR_POS, data->symbols.create($1)); $$ = new ExprVar(CUR_POS, data->symbols.create($1));
} }
| INT { $$ = new ExprInt($1); } | INT_LIT { $$ = new ExprInt($1); }
| FLOAT { $$ = new ExprFloat($1); } | FLOAT_LIT { $$ = new ExprFloat($1); }
| '"' string_parts '"' { $$ = $2; } | '"' string_parts '"' { $$ = $2; }
| IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE { | IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE {
$$ = stripIndentation(CUR_POS, data->symbols, std::move(*$2)); $$ = stripIndentation(CUR_POS, data->symbols, std::move(*$2));