mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
style: rename semanticVal as value
* data/skeletons/README-D.txt: Remove, now useless and obsolete. * data/skeletons/glr2.cc, examples/d/calc/calc.y, * tests/calc.at, tests/d.at, tests/scanner.at (semanticVal): Replace with... (value): this.
This commit is contained in:
2
TODO
2
TODO
@@ -786,7 +786,7 @@ Equip the parser with a means to create the (visual) parse tree.
|
||||
# LocalWords: nterm bitsetv ielr ritem nstates nrules nritems yysymbol EQ
|
||||
# LocalWords: SymbolKind YYEMPTY YYUNDEF YYTNAME NUM yyntokens yytname sed
|
||||
# LocalWords: nonterminals yykind yycode YYNAMES yynames init getName conv
|
||||
# LocalWords: TokenKind semanticVal ival yychar yylval yylexer Tolmer hoc
|
||||
# LocalWords: TokenKind ival yychar yylval yylexer Tolmer hoc
|
||||
# LocalWords: Sobisch YYPTRDIFF ptrdiff Autotest YYPRINT toknum yytoknum
|
||||
# LocalWords: sym Wother stderr FP fixits xgettext fdiagnostics Graphviz
|
||||
# LocalWords: graphviz VCG bitset xml bw maint yytoken YYABORT deps
|
||||
|
||||
@@ -41,7 +41,6 @@ dist_skeletons_DATA = \
|
||||
|
||||
# Experimental support for the D language.
|
||||
dist_skeletons_DATA += \
|
||||
data/skeletons/README-D.txt \
|
||||
data/skeletons/d-skel.m4 \
|
||||
data/skeletons/d.m4 \
|
||||
data/skeletons/lalr1.d
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
Some usage notes for the D Parser:
|
||||
|
||||
- it is a port of the Java parser, so interface is very similar.
|
||||
|
||||
- the lexer class needs to implement the interface 'Lexer' (similar to
|
||||
java). It typically (depending on options) looks like this:
|
||||
|
||||
public interface Lexer
|
||||
{
|
||||
/**
|
||||
* Method to retrieve the beginning position of the last scanned token.
|
||||
* @return the position at which the last scanned token starts. */
|
||||
@property YYPosition startPos ();
|
||||
|
||||
/**
|
||||
* Method to retrieve the ending position of the last scanned token.
|
||||
* @return the first position beyond the last scanned token. */
|
||||
@property YYPosition endPos ();
|
||||
|
||||
/**
|
||||
* Method to retrieve the semantic value of the last scanned token.
|
||||
* @return the semantic value of the last scanned token. */
|
||||
@property YYSemanticType semanticVal ();
|
||||
|
||||
/**
|
||||
* Entry point for the scanner. Returns the token identifier corresponding
|
||||
* to the next token and prepares to return the semantic value
|
||||
* and beginning/ending positions of the token.
|
||||
* @return the token identifier corresponding to the next token. */
|
||||
TokenKind yylex ();
|
||||
|
||||
/**
|
||||
* Entry point for error reporting. Emits an error
|
||||
* referring to the given location in a user-defined way.
|
||||
*
|
||||
* @param loc The location of the element to which the
|
||||
* error message is related
|
||||
* @param s The string for the error message. */
|
||||
void yyerror (YYLocation loc, string s);
|
||||
}
|
||||
|
||||
- semantic types are handled by D unions (same as for C/C++ parsers)
|
||||
|
||||
- the following (non-standard) %defines are supported:
|
||||
|
||||
%define package "<package_name>"
|
||||
%define api.parser.class "my_class_name>"
|
||||
%define position_type "my_position_type"
|
||||
%define location_type "my_location_type"
|
||||
|
||||
- the following declarations basically work like in C/C++:
|
||||
|
||||
%locations
|
||||
%error-verbose
|
||||
%parse-param
|
||||
%initial-action
|
||||
%code
|
||||
%union
|
||||
|
||||
- %destructor is not yet supported
|
||||
@@ -344,7 +344,7 @@ m4_define([b4_rhs_data],
|
||||
# --------------------------------------------------
|
||||
# Expansion of $$ or $<TYPE>$, for symbol SYMBOL-NUM.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([b4_rhs_data([$1], [$2]).semanticVal()], [$3], [$4])])
|
||||
[b4_symbol_value([b4_rhs_data([$1], [$2]).value ()], [$3], [$4])])
|
||||
|
||||
|
||||
|
||||
@@ -767,7 +767,7 @@ public:
|
||||
{
|
||||
setPred (other.pred ());
|
||||
if (other.yyresolved)
|
||||
new (&yysval) value_type (other.semanticVal ());
|
||||
new (&yysval) value_type (other.value ());
|
||||
else
|
||||
setFirstVal (other.firstVal ());]b4_parse_assert_if([[
|
||||
check_();]])[
|
||||
@@ -792,7 +792,7 @@ public:
|
||||
yyposn = other.yyposn;
|
||||
setPred (other.pred ());
|
||||
if (other.yyresolved)
|
||||
semanticVal () = other.semanticVal ();
|
||||
value () = other.value ();
|
||||
else
|
||||
setFirstVal (other.firstVal ());]b4_locations_if([[
|
||||
yyloc = other.yyloc;]])[
|
||||
@@ -818,13 +818,13 @@ public:
|
||||
const semantic_option* firstVal () const;
|
||||
void setFirstVal (const semantic_option* option);
|
||||
|
||||
value_type& semanticVal ()
|
||||
value_type& value ()
|
||||
{]b4_parse_assert_if([[
|
||||
check_ ();]])[
|
||||
return yysval;
|
||||
}
|
||||
|
||||
const value_type& semanticVal () const
|
||||
const value_type& value () const
|
||||
{]b4_parse_assert_if([[
|
||||
check_ ();]])[
|
||||
return yysval;
|
||||
@@ -1119,12 +1119,12 @@ public:
|
||||
else if (yys0->yyresolved)
|
||||
{
|
||||
yys1->yyresolved = true;
|
||||
yys1->semanticVal() = yys0->semanticVal();
|
||||
yys1->value () = yys0->value ();
|
||||
}
|
||||
else if (yys1->yyresolved)
|
||||
{
|
||||
yys0->yyresolved = true;
|
||||
yys0->semanticVal() = yys1->semanticVal();
|
||||
yys0->value () = yys1->value ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1407,7 +1407,7 @@ void glr_state::destroy (char const* yymsg, ]b4_namespace_ref[::]b4_parser_class
|
||||
check_ ();]])[
|
||||
if (yyresolved)
|
||||
yyparser.yy_destroy_ (yymsg, yy_accessing_symbol(yylrState),
|
||||
&semanticVal()]b4_locations_if([, &yyloc])[);
|
||||
&value ()]b4_locations_if([, &yyloc])[);
|
||||
else
|
||||
{
|
||||
YY_SYMBOL_PRINT (yymsg << (firstVal() ? " unresolved" : " incomplete"),
|
||||
@@ -1700,10 +1700,10 @@ public:
|
||||
#endif
|
||||
yys.yyresolved = s->yyresolved;
|
||||
if (s->yyresolved)
|
||||
new (&yys.semanticVal ()) value_type (s->semanticVal ());
|
||||
new (&yys.value ()) value_type (s->value ());
|
||||
else
|
||||
/* The effect of using semanticVal or yyloc (in an immediate rule) is
|
||||
* undefined. */
|
||||
/* The effect of using yysval or yyloc (in an immediate
|
||||
* rule) is undefined. */
|
||||
yys.setFirstVal (YY_NULLPTR);]b4_locations_if([[
|
||||
yys.yyloc = s->yyloc;]])[
|
||||
yys.setPred(s->pred());
|
||||
@@ -1740,7 +1740,7 @@ public:
|
||||
std::cerr << " $" << yyi + 1 << " = ";
|
||||
yyparser.yy_symbol_print_
|
||||
(yy_accessing_symbol (yyvsp[yyi - yynrhs + 1].getState().yylrState),
|
||||
&yyvsp[yyi - yynrhs + 1].getState().semanticVal()]b4_locations_if([[,
|
||||
&yyvsp[yyi - yynrhs + 1].getState().value ()]b4_locations_if([[,
|
||||
&]b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
if (!yyvsp[yyi - yynrhs + 1].getState().yyresolved)
|
||||
std::cerr << " (unresolved)";
|
||||
@@ -2296,7 +2296,7 @@ public:
|
||||
if (yyrhslen == 0)
|
||||
*yyvalp = yyval_default;
|
||||
else
|
||||
*yyvalp = yyvsp[YYFILL (1-yyrhslen)].getState().semanticVal();]b4_locations_if([[
|
||||
*yyvalp = yyvsp[YYFILL (1-yyrhslen)].getState().value ();]b4_locations_if([[
|
||||
/* Default location. */
|
||||
YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
|
||||
yyerror_range[1].getState().yyloc = *yylocp;
|
||||
@@ -2657,7 +2657,7 @@ private:
|
||||
{
|
||||
yys.yyresolved = true;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
new (&yys.semanticVal ()) value_type (yysval);
|
||||
new (&yys.value ()) value_type (yysval);
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
}
|
||||
else
|
||||
|
||||
@@ -106,7 +106,7 @@ if (isInputRange!R && is(ElementType!R : dchar))
|
||||
stderr.writeln(loc.toString(), ": ", s);
|
||||
}
|
||||
|
||||
Value semanticVal_;
|
||||
Value value_;
|
||||
|
||||
Symbol yylex()
|
||||
{
|
||||
@@ -129,7 +129,7 @@ if (isInputRange!R && is(ElementType!R : dchar))
|
||||
int lenChars = 0;
|
||||
auto copy = input;
|
||||
import std.conv : parse;
|
||||
semanticVal_.ival = input.parse!int;
|
||||
value_.ival = input.parse!int;
|
||||
while (!input.empty && copy.front != input.front)
|
||||
{
|
||||
lenChars++;
|
||||
@@ -137,7 +137,7 @@ if (isInputRange!R && is(ElementType!R : dchar))
|
||||
}
|
||||
location.begin = location.end;
|
||||
location.end.column += lenChars;
|
||||
return Symbol(TokenKind.NUM, semanticVal_.ival, location);
|
||||
return Symbol(TokenKind.NUM, value_.ival, location);
|
||||
}
|
||||
|
||||
// Individual characters
|
||||
|
||||
@@ -563,7 +563,7 @@ class CalcLexer(R) : Lexer
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
|
||||
Value semanticVal_;]AT_LOCATION_IF([[
|
||||
Value value_;]AT_LOCATION_IF([[
|
||||
Location location;
|
||||
]])[
|
||||
int parseInt ()
|
||||
@@ -600,8 +600,8 @@ class CalcLexer(R) : Lexer
|
||||
// Numbers.
|
||||
if (input.front.isNumber)
|
||||
{
|
||||
semanticVal_.ival = parseInt;
|
||||
return Symbol(TokenKind.]AT_TOKEN_PREFIX[NUM, semanticVal_.ival]AT_LOCATION_IF([[, location]])[);
|
||||
value_.ival = parseInt;
|
||||
return Symbol(TokenKind.]AT_TOKEN_PREFIX[NUM, value_.ival]AT_LOCATION_IF([[, location]])[);
|
||||
}
|
||||
|
||||
// Individual characters
|
||||
|
||||
@@ -78,8 +78,6 @@ class CalcLexer(R) : Lexer
|
||||
|
||||
void yyerror(string s) {}
|
||||
|
||||
Value semanticVal_;
|
||||
|
||||
Symbol yylex()
|
||||
{
|
||||
$2
|
||||
|
||||
@@ -115,7 +115,7 @@ class YYLexer(R) : Lexer
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
|
||||
Value semanticVal_;
|
||||
Value value_;
|
||||
|
||||
Symbol yylex ()
|
||||
{
|
||||
@@ -131,8 +131,8 @@ class YYLexer(R) : Lexer
|
||||
switch (c)
|
||||
{
|
||||
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||
semanticVal_.val = c - '0';
|
||||
return Symbol(TokenKind.NUM, semanticVal_.val);
|
||||
value_.val = c - '0';
|
||||
return Symbol(TokenKind.NUM, value_.val);
|
||||
case '+': return Symbol(TokenKind.PLUS);
|
||||
case '-': return Symbol(TokenKind.MINUS);
|
||||
case '*': return Symbol(TokenKind.STAR);
|
||||
|
||||
Reference in New Issue
Block a user