mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
m4: rename b4_symbol_sid as b4_symbol_kind
* data/skeletons/bison.m4, data/skeletons/c++.m4, data/skeletons/c.m4, * data/skeletons/d.m4, data/skeletons/java.m4 (b4_symbol_sid): Rename as... (b4_symbol_kind): this. Adjust dependencies. * data/README.md: Document the kind.
This commit is contained in:
@@ -83,18 +83,20 @@ field), where field can `has_id`, `id`, etc.: see
|
|||||||
|
|
||||||
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
||||||
|
|
||||||
- `has_id`: 0 or 1.
|
- `has_id`: 0 or 1
|
||||||
|
|
||||||
Whether the symbol has an id.
|
Whether the symbol has an id.
|
||||||
|
|
||||||
- `id`: string
|
- `id`: string
|
||||||
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
|
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
|
||||||
defined as empty. Guaranteed to be usable as a C identifier.
|
defined as empty. Guaranteed to be usable as a C identifier. This is
|
||||||
|
used to define the token kind (i.e., the enum used by the return value of
|
||||||
|
yylex).
|
||||||
|
|
||||||
- `tag`: string.
|
- `tag`: string
|
||||||
A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
A human representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||||
|
|
||||||
- `user_number`: integer
|
- `user_number`: integer
|
||||||
|
The code associated to the `id`.
|
||||||
The external number as used by yylex. Can be ASCII code when a character,
|
The external number as used by yylex. Can be ASCII code when a character,
|
||||||
some number chosen by bison, or some user number in the case of
|
some number chosen by bison, or some user number in the case of
|
||||||
%token FOO <NUM>. Corresponds to yychar in yacc.c.
|
%token FOO <NUM>. Corresponds to yychar in yacc.c.
|
||||||
@@ -102,7 +104,12 @@ The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
|||||||
- `is_token`: 0 or 1
|
- `is_token`: 0 or 1
|
||||||
Whether this is a terminal symbol.
|
Whether this is a terminal symbol.
|
||||||
|
|
||||||
|
- `kind`: string
|
||||||
|
The symbol kind, i.e., the enumerator of this symbol (token or nonterminal)
|
||||||
|
which is mapping to its `number`.
|
||||||
|
|
||||||
- `number`: integer
|
- `number`: integer
|
||||||
|
The code associated to the `kind`.
|
||||||
The internal number (computed from the external number by yytranslate).
|
The internal number (computed from the external number by yytranslate).
|
||||||
Corresponds to yytoken in yacc.c. This is the same number that serves as
|
Corresponds to yytoken in yacc.c. This is the same number that serves as
|
||||||
key in b4_symbol(NUM, FIELD).
|
key in b4_symbol(NUM, FIELD).
|
||||||
|
|||||||
@@ -405,13 +405,13 @@ m4_define([_b4_symbol],
|
|||||||
[__b4_symbol([$1], [$2])])])
|
[__b4_symbol([$1], [$2])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_sid(NUM)
|
# b4_symbol_kind(NUM)
|
||||||
# ------------------
|
# -------------------
|
||||||
# Build the symbol ID based for this symbol. It must always exist,
|
# Build the name of the kind of this symbol. It must always exist,
|
||||||
# otherwise some symbols might not be represented in the enum, which
|
# otherwise some symbols might not be represented in the enum, which
|
||||||
# might be compiled into too small a type to contain all the symbol
|
# might be compiled into too small a type to contain all the symbol
|
||||||
# numbers.
|
# numbers.
|
||||||
m4_define([b4_symbol_sid],
|
m4_define([b4_symbol_kind],
|
||||||
[m4_case([$1],
|
[m4_case([$1],
|
||||||
[-2], [[YYSYMBOL_YYEMPTY]],
|
[-2], [[YYSYMBOL_YYEMPTY]],
|
||||||
[0], [[YYSYMBOL_YYEOF]],
|
[0], [[YYSYMBOL_YYEOF]],
|
||||||
@@ -433,7 +433,7 @@ m4_define([b4_symbol],
|
|||||||
[m4_case([$2],
|
[m4_case([$2],
|
||||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
||||||
[_b4_symbol([$1], [id])])],
|
[_b4_symbol([$1], [id])])],
|
||||||
[sid], [b4_symbol_sid([$1])],
|
[kind], [b4_symbol_kind([$1])],
|
||||||
[_b4_symbol($@)])])
|
[_b4_symbol($@)])])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ m4_define([b4_declare_symbol_enum],
|
|||||||
{
|
{
|
||||||
]m4_join([,
|
]m4_join([,
|
||||||
],
|
],
|
||||||
]b4_symbol_sid([-2])[ = -2,
|
]b4_symbol_kind([-2])[ = -2,
|
||||||
b4_symbol_map([b4_symbol_enum]),
|
b4_symbol_map([b4_symbol_enum]),
|
||||||
[YYNTOKENS = ]b4_tokens_number[ ///< Number of tokens.])[
|
[YYNTOKENS = ]b4_tokens_number[ ///< Number of tokens.])[
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -495,9 +495,9 @@ m4_define([b4_symbol_translate],
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Output the definition of this symbol as an enum.
|
# Output the definition of this symbol as an enum.
|
||||||
m4_define([b4_symbol_enum],
|
m4_define([b4_symbol_enum],
|
||||||
[m4_ifval(b4_symbol([$1], [sid]),
|
[m4_ifval(b4_symbol([$1], [kind]),
|
||||||
[m4_format([[%s = %s]],
|
[m4_format([[%s = %s]],
|
||||||
b4_symbol([$1], [sid]),
|
b4_symbol([$1], [kind]),
|
||||||
b4_symbol([$1], [number]))])])
|
b4_symbol([$1], [number]))])])
|
||||||
|
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ enum yysymbol_kind_t
|
|||||||
{
|
{
|
||||||
]m4_join([,
|
]m4_join([,
|
||||||
],
|
],
|
||||||
]b4_symbol_sid([-2])[ = -2,
|
]b4_symbol_kind([-2])[ = -2,
|
||||||
b4_symbol_map([b4_symbol_enum]))[
|
b4_symbol_map([b4_symbol_enum]))[
|
||||||
};
|
};
|
||||||
typedef enum yysymbol_kind_t yysymbol_kind_t;
|
typedef enum yysymbol_kind_t yysymbol_kind_t;
|
||||||
|
|||||||
@@ -181,9 +181,9 @@ b4_symbol_foreach([b4_token_enum])
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Output the definition of this symbol as an enum.
|
# Output the definition of this symbol as an enum.
|
||||||
m4_define([b4_symbol_enum],
|
m4_define([b4_symbol_enum],
|
||||||
[m4_ifval(b4_symbol([$1], [sid]),
|
[m4_ifval(b4_symbol([$1], [kind]),
|
||||||
[m4_format([[%s = %s]],
|
[m4_format([[%s = %s]],
|
||||||
b4_symbol([$1], [sid]),
|
b4_symbol([$1], [kind]),
|
||||||
b4_symbol([$1], [number]))])])
|
b4_symbol([$1], [number]))])])
|
||||||
|
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ m4_define([b4_declare_symbol_enum],
|
|||||||
{
|
{
|
||||||
]m4_join([,
|
]m4_join([,
|
||||||
],
|
],
|
||||||
]b4_symbol_sid([-2])[ = -2,
|
]b4_symbol_kind([-2])[ = -2,
|
||||||
b4_symbol_map([b4_symbol_enum]))[
|
b4_symbol_map([b4_symbol_enum]))[
|
||||||
};
|
};
|
||||||
]])])
|
]])])
|
||||||
|
|||||||
@@ -157,9 +157,9 @@ b4_symbol_foreach([b4_token_enum])])])
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Output the definition of this symbol as an enum.
|
# Output the definition of this symbol as an enum.
|
||||||
m4_define([b4_symbol_enum],
|
m4_define([b4_symbol_enum],
|
||||||
[m4_ifval(b4_symbol([$1], [sid]),
|
[m4_ifval(b4_symbol([$1], [kind]),
|
||||||
[m4_format([[%s(%s)]],
|
[m4_format([[%s(%s)]],
|
||||||
b4_symbol([$1], [sid]),
|
b4_symbol([$1], [kind]),
|
||||||
b4_symbol([$1], [number]))])])
|
b4_symbol([$1], [number]))])])
|
||||||
|
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ m4_define([b4_declare_symbol_enum],
|
|||||||
{
|
{
|
||||||
]m4_join([,
|
]m4_join([,
|
||||||
],
|
],
|
||||||
]b4_symbol_sid([-2])[(-2),
|
]b4_symbol_kind([-2])[(-2),
|
||||||
b4_symbol_map([b4_symbol_enum]))[;
|
b4_symbol_map([b4_symbol_enum]))[;
|
||||||
|
|
||||||
private final int code_;
|
private final int code_;
|
||||||
@@ -181,7 +181,7 @@ m4_define([b4_declare_symbol_enum],
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final SymbolKind[] values_ = {
|
private static final SymbolKind[] values_ = {
|
||||||
]m4_map_args_sep([b4_symbol_sid(], [)], [,
|
]m4_map_args_sep([b4_symbol_kind(], [)], [,
|
||||||
], b4_symbol_numbers)[
|
], b4_symbol_numbers)[
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user