[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] Rename CHAR, IN, VOID, ERROR to avoid collision
From: |
Georgiy Tugai |
Subject: |
[PATCH 1/5] Rename CHAR, IN, VOID, ERROR to avoid collision |
Date: |
Thu, 25 Mar 2021 20:13:58 +0000 |
since they are considered "reserved words" by some Woe32 compilers.
2021-03-25 Georgiy Tugai <georgiy@crossings.link>
* etc/poke.g4: Rename CHAR to CHARACTER
* libpoke/pkl-lex.l: Likewise, and rename IN, VOID to TOK_IN,
TOK_VOID respectively
* libpoke/pkl-tab.y: Likewise
* libpoke/pkl-typify.c: Update comment to match
* libpoke/pk-map-lex.l: Rename ERROR to TOK_ERROR
* libpoke/pk-map-tab.y: Likewise
---
ChangeLog | 10 ++++++++++
etc/poke.g4 | 4 ++--
libpoke/pkl-lex.l | 10 +++++-----
libpoke/pkl-tab.y | 20 ++++++++++----------
libpoke/pkl-typify.c | 2 +-
poke/pk-map-lex.l | 2 +-
poke/pk-map-tab.y | 2 +-
7 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 439daf69..626b8d0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2021-03-25 Georgiy Tugai <georgiy@crossings.link>
+
+ * etc/poke.g4: Rename CHAR to CHARACTER
+ * libpoke/pkl-lex.l: Likewise, and rename IN, VOID to TOK_IN,
+ TOK_VOID respectively
+ * libpoke/pkl-tab.y: Likewise
+ * libpoke/pkl-typify.c: Update comment to match
+ * libpoke/pk-map-lex.l: Rename ERROR to TOK_ERROR
+ * libpoke/pk-map-tab.y: Likewise
+
2021-03-25 Jose E. Marchesi <jemarch@gnu.org>
* poke/pk-mi-msg.c (pk_mi_set_arg): An ANY msg argument can be of
diff --git a/etc/poke.g4 b/etc/poke.g4
index 20431145..36d04024 100644
--- a/etc/poke.g4
+++ b/etc/poke.g4
@@ -49,7 +49,7 @@ INTEGER:
| NUMBER
;
-CHAR: .
+CHARACTER: .
| '\\' ([ntr]|[0-7]|[0-7][0-7]|[0-7][0-7][0-7])
;
@@ -138,7 +138,7 @@ unary_operator: '-' | '+' | '~' | '!' | 'unmap' ;
primary:
IDENTIFIER
| INTEGER
- | CHAR
+ | CHARACTER
| STRING
| '(' expression ')'
| array
diff --git a/libpoke/pkl-lex.l b/libpoke/pkl-lex.l
index b6e2e21c..875a388a 100644
--- a/libpoke/pkl-lex.l
+++ b/libpoke/pkl-lex.l
@@ -125,7 +125,7 @@ NEWLINE \n
BLANK [ \t]
LETTER [a-zA-Z]
FIELD_NAME {LETTER}[a-zA-Z0-9_]*
-CHAR '(.|\\[ntr\\]|\\[0-7]|\\[0-7][0-7]|\\[0-7][0-7][0-7])'
+CHARACTER '(.|\\[ntr\\]|\\[0-7]|\\[0-7][0-7]|\\[0-7][0-7][0-7])'
STRING \"([^"\\]|\\(.|\n))*\"
HEXCST 0[xX][0-9a-fA-F][0-9a-fA-F_]*
BINCST 0[bB][01][01_]*
@@ -199,7 +199,7 @@ S ::
"while" { return WHILE; }
"until" { return UNTIL; }
"for" { return FOR; }
-"in" { return IN; }
+"in" { return TOK_IN; }
"where" { return WHERE; }
"if" { return IF; }
"sizeof" { return SIZEOF; }
@@ -216,7 +216,7 @@ S ::
"try" { return TRY; }
"catch" { return CATCH; }
"raise" { return RAISE; }
-"void" { return VOID; }
+"void" { return TOK_VOID; }
"any" { return ANY; }
"print" { return PRINT; }
"printf" { return PRINTF; }
@@ -479,7 +479,7 @@ S ::
return INTEGER;
}
-{CHAR} {
+{CHARACTER} {
uint8_t value;
pkl_ast_node type;
@@ -524,7 +524,7 @@ S ::
yylval->ast = pkl_ast_make_integer (yyextra->ast, value);
PKL_AST_TYPE (yylval->ast) = ASTREF (type);
- return CHAR;
+ return CHARACTER;
}
{STRING} {
diff --git a/libpoke/pkl-tab.y b/libpoke/pkl-tab.y
index c82a0edc..d6ebee2d 100644
--- a/libpoke/pkl-tab.y
+++ b/libpoke/pkl-tab.y
@@ -370,7 +370,7 @@ load_module (struct pkl_parser *parser,
%token <ast> INTEGER _("integer literal")
%token INTEGER_OVERFLOW
-%token <ast> CHAR _("character literal")
+%token <ast> CHARACTER _("character literal")
%token <ast> STR _("string")
%token <ast> IDENTIFIER _("identifier")
%token <ast> TYPENAME _("type name")
@@ -382,14 +382,14 @@ load_module (struct pkl_parser *parser,
%token <integer> PINNED _("keyword `pinned'")
%token STRUCT _("keyword `struct'")
token <integer> UNION _("keyword `union'")
-%token CONST _("keyword `const'")
+%token TOK_CONST _("keyword `const'")
%token CONTINUE _("keyword `continue'")
%token ELSE _("keyword `else'")
%token IF _("keyword `if'")
%token WHILE _("keyword `while")
%token UNTIL _("keyword `until'")
%token FOR _("keyword `for'")
-%token IN _("keyword `in'")
+%token TOK_IN _("keyword `in'")
%token WHERE _("keyword `where'")
%token SIZEOF _("keyword `sizeof'")
%token ASSERT _("keyword `assert'")
@@ -410,7 +410,7 @@ token <integer> UNION _("keyword `union'")
%token TRY _("keyword `try'")
%token CATCH _("keyword `catch'")
%token RAISE _("keyword `raise'")
-%token VOID _("void type specifier")
+%token TOK_VOID _("void type specifier")
%token ANY _("any type specifier")
%token PRINT _("keyword `print'")
%token PRINTF _("keyword `printf'")
@@ -490,7 +490,7 @@ token <integer> UNION _("keyword `union'")
%right '?' ':'
%left OR
%left AND
-%left IN
+%left TOK_IN
%left '|'
%left '^'
%left '&'
@@ -884,7 +884,7 @@ expression:
$1, $3);
PKL_AST_LOC ($$) = @$;
}
- | expression IN expression
+ | expression TOK_IN expression
{
$$ = pkl_ast_make_binary_exp (pkl_parser->ast, PKL_AST_OP_IN,
$1, $3);
@@ -1066,7 +1066,7 @@ primary:
"integer literal is too big");
YYERROR;
}
- | CHAR
+ | CHARACTER
{
$$ = $1;
PKL_AST_LOC ($$) = @$;
@@ -1386,7 +1386,7 @@ simple_type_specifier:
$$ = pkl_ast_make_any_type (pkl_parser->ast);
PKL_AST_LOC ($$) = @$;
}
- | VOID
+ | TOK_VOID
{
$$ = pkl_ast_make_void_type (pkl_parser->ast);
PKL_AST_LOC ($$) = @$;
@@ -2225,7 +2225,7 @@ stmt:
PKL_AST_LOC ($$) = @$;
}
- | FOR '(' IDENTIFIER IN expression pushlevel
+ | FOR '(' IDENTIFIER TOK_IN expression pushlevel
{
/* Push a new lexical level and register a variable
with name IDENTIFIER. Note that the variable is
@@ -2278,7 +2278,7 @@ stmt:
above. */
pkl_parser->env = pkl_env_pop_frame (pkl_parser->env);
}
- | FOR '(' IDENTIFIER IN expression pushlevel
+ | FOR '(' IDENTIFIER TOK_IN expression pushlevel
{
/* XXX: avoid code replication here. */
diff --git a/libpoke/pkl-typify.c b/libpoke/pkl-typify.c
index d51953d7..1abf48bd 100644
--- a/libpoke/pkl-typify.c
+++ b/libpoke/pkl-typify.c
@@ -21,7 +21,7 @@
`typify1' annotates expression nodes in the AST with their
respective types, according to the rules documented in the handlers
below. It also performs type-checking. It relies on the lexer and
- previous phases to set the types for INTEGER, CHAR, STRING and
+ previous phases to set the types for INTEGER, CHARACTER, STRING and
other entities, and propagates that information up the AST.
`typify2' determines which types are "complete" and annotates the
diff --git a/poke/pk-map-lex.l b/poke/pk-map-lex.l
index 59fec133..d121adc8 100644
--- a/poke/pk-map-lex.l
+++ b/poke/pk-map-lex.l
@@ -124,4 +124,4 @@ TAGNAME %[a-zA-Z_][a-zA-Z0-9_]*
return TAG;
}
-<*>. { return ERROR; }
+<*>. { return TOK_ERROR; }
diff --git a/poke/pk-map-tab.y b/poke/pk-map-tab.y
index 8dc7280c..3c5797b1 100644
--- a/poke/pk-map-tab.y
+++ b/poke/pk-map-tab.y
@@ -270,7 +270,7 @@ pk_map_tab_error (YYLTYPE *llocp, struct pk_map_parser
*map_parser, char const *
/* Tokens. */
-%token ERROR SEP
+%token TOK_ERROR SEP
%token ENTRY
%token <integer> TAG
%token <string> DATA
--
2.26.2