mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
java: style changes
* data/skeletons/lalr1.java: Use more conventional function names for Java. Prefer < and <= to => and >. Use the same approach for m4 quotation as in the other skeletons. Fix indentation issues. * tests/calc.at, tests/java.at, tests/javapush.at: Fix quotation style. (main): Use 'args', not 'argv', the former seems more conventional and is used elsewhere in Bison. Prefer character literals to integers to denote characters. * examples/java/Calc.y: Likewise.
This commit is contained in:
@@ -21,7 +21,7 @@ b4_defines_if([b4_complain([%defines does not make sense in Java])])
|
||||
|
||||
# We do not depend on %debug in Java, but pacify warnings about
|
||||
# non-used flags.
|
||||
b4_parse_trace_if([0], [0])
|
||||
b4_parse_trace_if
|
||||
|
||||
m4_define([b4_symbol_no_destructor_assert],
|
||||
[b4_symbol_if([$1], [has_destructor],
|
||||
@@ -70,19 +70,19 @@ m4_define([b4_define_state],[[
|
||||
|
||||
/* Error handling. */
|
||||
int yynerrs_ = 0;
|
||||
]b4_locations_if([/* The location where the error started. */
|
||||
b4_location_type yyerrloc = null;
|
||||
]b4_locations_if([[/* The location where the error started. */
|
||||
]b4_location_type[ yyerrloc = null;
|
||||
|
||||
/* Location. */
|
||||
b4_location_type yylloc = new b4_location_type (null, null);])[
|
||||
]b4_location_type[ yylloc = new ]b4_location_type[ (null, null);]])[
|
||||
|
||||
/* Semantic value of the lookahead. */
|
||||
]b4_yystype[ yylval = null;
|
||||
]])
|
||||
]])[
|
||||
|
||||
b4_output_begin([b4_parser_file_name])[
|
||||
]b4_output_begin([b4_parser_file_name])[
|
||||
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||
[2007-2015, 2018])[
|
||||
[2007-2015, 2018-2019])[
|
||||
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
|
||||
]])[
|
||||
]b4_user_pre_prologue[
|
||||
@@ -103,7 +103,7 @@ b4_output_begin([b4_parser_file_name])[
|
||||
private boolean yyErrorVerbose = true;
|
||||
|
||||
/**
|
||||
* Return whether verbose error messages are enabled.
|
||||
* Whether verbose error messages are enabled.
|
||||
*/
|
||||
public final boolean getErrorVerbose() { return yyErrorVerbose; }
|
||||
|
||||
@@ -165,12 +165,12 @@ b4_locations_if([[
|
||||
}
|
||||
}
|
||||
|
||||
]])
|
||||
]])[
|
||||
|
||||
b4_locations_if([[
|
||||
]b4_locations_if([[
|
||||
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
||||
{
|
||||
if (n > 0)
|
||||
if (0 < n)
|
||||
return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
||||
else
|
||||
return new ]b4_location_type[ (rhs.locationAt (0).end);
|
||||
@@ -220,10 +220,11 @@ b4_locations_if([[
|
||||
* error message is related]])[
|
||||
* @@param msg The string for the error message.
|
||||
*/
|
||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);]
|
||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);
|
||||
}
|
||||
|
||||
b4_lexer_if([[private class YYLexer implements Lexer {
|
||||
]b4_lexer_if([[
|
||||
private class YYLexer implements Lexer {
|
||||
]b4_percent_code_get([[lexer]])[
|
||||
}
|
||||
|
||||
@@ -231,10 +232,10 @@ b4_locations_if([[
|
||||
* The object doing lexical analysis for us.
|
||||
*/
|
||||
private Lexer yylexer;
|
||||
]
|
||||
b4_parse_param_vars
|
||||
|
||||
b4_lexer_if([[
|
||||
]b4_parse_param_vars[
|
||||
|
||||
]b4_lexer_if([[
|
||||
/**
|
||||
* Instantiates the Bison-generated parser.
|
||||
*/
|
||||
@@ -244,13 +245,13 @@ b4_lexer_if([[
|
||||
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
||||
]b4_parse_param_cons[
|
||||
}
|
||||
]])
|
||||
]])[
|
||||
|
||||
/**
|
||||
* Instantiates the Bison-generated parser.
|
||||
* @@param yylexer The scanner that will supply tokens to the parser.
|
||||
*/
|
||||
b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
||||
]b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
||||
{
|
||||
]b4_percent_code_get([[init]])[
|
||||
this.yylexer = yylexer;
|
||||
@@ -260,8 +261,7 @@ b4_lexer_if([[
|
||||
private java.io.PrintStream yyDebugStream = System.err;
|
||||
|
||||
/**
|
||||
* Return the <tt>PrintStream</tt> on which the debugging output is
|
||||
* printed.
|
||||
* The <tt>PrintStream</tt> on which the debugging output is printed.
|
||||
*/
|
||||
public final java.io.PrintStream getDebugStream () { return yyDebugStream; }
|
||||
|
||||
@@ -360,7 +360,7 @@ b4_lexer_if([[
|
||||
|
||||
public final void pop (int num) {
|
||||
// Avoid memory leaks... garbage collection is a white lie!
|
||||
if (num > 0) {
|
||||
if (0 < num) {
|
||||
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);
|
||||
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
||||
}
|
||||
@@ -430,10 +430,9 @@ b4_lexer_if([[
|
||||
|
||||
private int yyerrstatus_ = 0;
|
||||
|
||||
]b4_push_if([dnl
|
||||
b4_define_state])[
|
||||
]b4_push_if([b4_define_state])[
|
||||
/**
|
||||
* Return whether error recovery is being done. In this state, the parser
|
||||
* Whether error recovery is being done. In this state, the parser
|
||||
* reads token until it reaches a known state, and then restarts normal
|
||||
* operation.
|
||||
*/
|
||||
@@ -446,7 +445,7 @@ b4_define_state])[
|
||||
* @@param yystate the current state
|
||||
* @@param yysym the nonterminal to push on the stack
|
||||
*/
|
||||
private int yy_lr_goto_state_ (int yystate, int yysym)
|
||||
private int yyLRGotoState (int yystate, int yysym)
|
||||
{
|
||||
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
|
||||
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
||||
@@ -457,21 +456,16 @@ b4_define_state])[
|
||||
|
||||
private int yyaction (int yyn, YYStack yystack, int yylen) ]b4_maybe_throws([b4_throws])[
|
||||
{
|
||||
]b4_yystype[ yyval;
|
||||
]b4_locations_if([b4_location_type[ yyloc = yylloc (yystack, yylen);]])[
|
||||
|
||||
/* If YYLEN is nonzero, implement the default value of the action:
|
||||
'$$ = $1'. Otherwise, use the top of the stack.
|
||||
|
||||
Otherwise, the following line sets YYVAL to garbage.
|
||||
This behavior is undocumented and Bison
|
||||
users should not rely upon it. */
|
||||
if (yylen > 0)
|
||||
yyval = yystack.valueAt (yylen - 1);
|
||||
else
|
||||
yyval = yystack.valueAt (0);
|
||||
]b4_yystype[ yyval = (0 < yylen) ? yystack.valueAt (yylen - 1) : yystack.valueAt (0);
|
||||
]b4_locations_if([b4_location_type[ yyloc = yylloc (yystack, yylen);]])[
|
||||
|
||||
yy_reduce_print (yyn, yystack);
|
||||
yyReducePrint (yyn, yystack);
|
||||
|
||||
switch (yyn)
|
||||
{
|
||||
@@ -479,13 +473,13 @@ b4_define_state])[
|
||||
default: break;
|
||||
}
|
||||
|
||||
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
|
||||
yySymbolPrint ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
|
||||
|
||||
yystack.pop (yylen);
|
||||
yylen = 0;
|
||||
|
||||
/* Shift the result of the reduction. */
|
||||
int yystate = yy_lr_goto_state_ (yystack.stateAt (0), yyr1_[yyn]);
|
||||
int yystate = yyLRGotoState (yystack.stateAt (0), yyr1_[yyn]);
|
||||
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
|
||||
return YYNEWSTATE;
|
||||
}
|
||||
@@ -531,7 +525,7 @@ b4_define_state])[
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
private void yy_symbol_print (String s, int yytype,
|
||||
private void yySymbolPrint (String s, int yytype,
|
||||
]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, Object yylocationp])[)
|
||||
{
|
||||
@@ -612,7 +606,7 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
/* Take a decision. First try without lookahead. */
|
||||
yyn = yypact_[yystate];
|
||||
if (yy_pact_value_is_default_ (yyn))
|
||||
if (yyPactValueIsDefault (yyn))
|
||||
{
|
||||
label = YYDEFAULT;
|
||||
break;
|
||||
@@ -649,7 +643,7 @@ b4_dollar_popdef[]dnl
|
||||
else
|
||||
{
|
||||
yytoken = yytranslate_ (yychar);
|
||||
yy_symbol_print ("Next token is", yytoken,
|
||||
yySymbolPrint ("Next token is", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
}
|
||||
|
||||
@@ -662,7 +656,7 @@ b4_dollar_popdef[]dnl
|
||||
/* <= 0 means reduce or error. */
|
||||
else if ((yyn = yytable_[yyn]) <= 0)
|
||||
{
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
if (yyTableValueIsError (yyn))
|
||||
label = YYERRLAB;
|
||||
else
|
||||
{
|
||||
@@ -674,7 +668,7 @@ b4_dollar_popdef[]dnl
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */
|
||||
yy_symbol_print ("Shifting", yytoken,
|
||||
yySymbolPrint ("Shifting", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
|
||||
/* Discard the token being shifted. */
|
||||
@@ -734,7 +728,7 @@ b4_dollar_popdef[]dnl
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == Lexer.EOF)
|
||||
]b4_push_if([{label = YYABORT; break;}],[return false;])[
|
||||
]b4_push_if([{label = YYABORT; break;}], [return false;])[
|
||||
}
|
||||
else
|
||||
yychar = yyempty_;
|
||||
@@ -749,7 +743,6 @@ b4_dollar_popdef[]dnl
|
||||
| errorlab -- error raised explicitly by YYERROR. |
|
||||
`-------------------------------------------------*/
|
||||
case YYERROR:
|
||||
|
||||
]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
|
||||
/* Do not reclaim the symbols of the rule which action triggered
|
||||
this YYERROR. */
|
||||
@@ -768,7 +761,7 @@ b4_dollar_popdef[]dnl
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
@@ -803,7 +796,7 @@ b4_dollar_popdef[]dnl
|
||||
yystack.pop (2);])[
|
||||
|
||||
/* Shift the error token. */
|
||||
yy_symbol_print ("Shifting", yystos_[yyn],
|
||||
yySymbolPrint ("Shifting", yystos_[yyn],
|
||||
yylval]b4_locations_if([, yyloc])[);
|
||||
|
||||
yystate = yyn;
|
||||
@@ -870,9 +863,9 @@ b4_dollar_popdef[]dnl
|
||||
{
|
||||
return push_parse (yylextoken, yylexval, new b4_location_type (yylexpos));
|
||||
}
|
||||
])[]])
|
||||
])[]])[
|
||||
|
||||
b4_both_if([[
|
||||
]b4_both_if([[
|
||||
/**
|
||||
* Parse input from the scanner that was specified at object construction
|
||||
* time. Return whether the end of the input was reached successfully.
|
||||
@@ -938,7 +931,7 @@ b4_both_if([[
|
||||
new StringBuffer ("syntax error, unexpected ");
|
||||
res.append (yytnamerr_ (yytname_[tok]));
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
@@ -951,14 +944,14 @@ b4_both_if([[
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||
{
|
||||
res.append (count++ == 0 ? ", expecting " : " or ");
|
||||
res.append (yytnamerr_ (yytname_[x]));
|
||||
@@ -976,7 +969,7 @@ b4_both_if([[
|
||||
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
||||
* @@param yyvalue the value to check
|
||||
*/
|
||||
private static boolean yy_pact_value_is_default_ (int yyvalue)
|
||||
private static boolean yyPactValueIsDefault (int yyvalue)
|
||||
{
|
||||
return yyvalue == yypact_ninf_;
|
||||
}
|
||||
@@ -986,7 +979,7 @@ b4_both_if([[
|
||||
* value indicates a syntax error.
|
||||
* @@param yyvalue the value to check
|
||||
*/
|
||||
private static boolean yy_table_value_is_error_ (int yyvalue)
|
||||
private static boolean yyTableValueIsError (int yyvalue)
|
||||
{
|
||||
return yyvalue == yytable_ninf_;
|
||||
}
|
||||
@@ -1008,7 +1001,7 @@ b4_both_if([[
|
||||
|
||||
|
||||
// Report on the debug stream that the rule yyrule is going to be reduced.
|
||||
private void yy_reduce_print (int yyrule, YYStack yystack)
|
||||
private void yyReducePrint (int yyrule, YYStack yystack)
|
||||
{
|
||||
if (yydebug == 0)
|
||||
return;
|
||||
@@ -1021,7 +1014,7 @@ b4_both_if([[
|
||||
|
||||
/* The symbols being reduced. */
|
||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||
yy_symbol_print (" $" + (yyi + 1) + " =",
|
||||
yySymbolPrint (" $" + (yyi + 1) + " =",
|
||||
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
||||
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
@@ -1033,7 +1026,7 @@ b4_both_if([[
|
||||
|
||||
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||
{
|
||||
if (t >= 0 && t <= yyuser_token_number_max_)
|
||||
if (0 <= t && t <= yyuser_token_number_max_)
|
||||
return yytranslate_table_[t];
|
||||
else
|
||||
return yyundef_token_;
|
||||
@@ -1050,8 +1043,8 @@ b4_both_if([[
|
||||
private static final int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
||||
private static final int yyundef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
]/* User implementation code. */
|
||||
b4_percent_code_get[]dnl
|
||||
/* User implementation code. */
|
||||
]b4_percent_code_get[]dnl
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ class CalcLexer implements Calc.Lexer {
|
||||
st = new StreamTokenizer (new InputStreamReader (is));
|
||||
st.resetSyntax ();
|
||||
st.eolIsSignificant (true);
|
||||
st.whitespaceChars (9, 9);
|
||||
st.whitespaceChars (32, 32);
|
||||
st.wordChars (48, 57);
|
||||
st.whitespaceChars ('\t', '\t');
|
||||
st.whitespaceChars (' ', ' ');
|
||||
st.wordChars ('0', '9');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -598,7 +598,7 @@ AT_DATA_CALC_Y([$1])
|
||||
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]], [[], []]), [$2], [-Wno-deprecated])
|
||||
AT_CHECK_SPACES([calc.AT_LANG_EXT AT_DEFINES_IF([calc.AT_LANG_HDR])])
|
||||
|
||||
# Test the priorities.
|
||||
# Test the precedences.
|
||||
_AT_CHECK_CALC([$1],
|
||||
[1 + 2 * 3 = 7
|
||||
1 + 2 * -3 = -5
|
||||
|
||||
@@ -127,17 +127,17 @@ class CalcLexer implements Calc.Lexer {
|
||||
]])[
|
||||
StreamTokenizer st;
|
||||
|
||||
public ]AT_LEXPARAM_IF([[YYLexer]], [[CalcLexer]]) (InputStream is)
|
||||
public ]AT_LEXPARAM_IF([[YYLexer]], [[CalcLexer]])[ (InputStream is)
|
||||
{
|
||||
st = new StreamTokenizer (new InputStreamReader (is));
|
||||
st.resetSyntax ();
|
||||
st.eolIsSignificant (true);
|
||||
st.whitespaceChars (9, 9);
|
||||
st.whitespaceChars (32, 32);
|
||||
st.wordChars (48, 57);
|
||||
st.whitespaceChars ('\t', '\t');
|
||||
st.whitespaceChars (' ', ' ');
|
||||
st.wordChars ('0', '9');
|
||||
}
|
||||
|
||||
AT_LOCATION_IF([[
|
||||
]AT_LOCATION_IF([[
|
||||
Position yypos = new Position (1, 0);
|
||||
|
||||
public Position getStartPos() {
|
||||
@@ -157,15 +157,14 @@ AT_LOCATION_IF([[
|
||||
}
|
||||
|
||||
public int yylex () throws IOException {
|
||||
int ttype = st.nextToken ();
|
||||
]AT_LOCATION_IF([[yypos = new Position (yypos.lineno (),
|
||||
yypos.token () + 1);]])[
|
||||
int ttype = st.nextToken ();]AT_LOCATION_IF([[
|
||||
yypos = new Position (yypos.lineno (), yypos.token () + 1);]])[
|
||||
if (ttype == st.TT_EOF)
|
||||
return EOF;
|
||||
|
||||
else if (ttype == st.TT_EOL)
|
||||
{
|
||||
]AT_LOCATION_IF([[yypos = new Position (yypos.lineno () + 1, 0);]])[
|
||||
{]AT_LOCATION_IF([[
|
||||
yypos = new Position (yypos.lineno () + 1, 0);]])[
|
||||
return (int) '\n';
|
||||
}
|
||||
|
||||
@@ -251,7 +250,7 @@ $2
|
||||
AT_BISON_CHECK([-Wno-deprecated -o Calc.java Calc.y])
|
||||
AT_JAVA_COMPILE([Calc.java])
|
||||
|
||||
# Test the priorities.
|
||||
# Test the precedences.
|
||||
AT_DATA([[input]],
|
||||
[[1 + 2 * 3 = 7
|
||||
1 + 2 * -3 = -5
|
||||
|
||||
@@ -43,7 +43,7 @@ AT_BANNER([[Java Push Parsing Tests]])
|
||||
# Define a single copy of the trivial parser grammar.
|
||||
# This is missing main(), so two versions
|
||||
# are instantiated with different main() procedures.
|
||||
m4_define([AT_TRIVIAL_GRAMMAR],[
|
||||
m4_define([AT_TRIVIAL_GRAMMAR],[[
|
||||
%define api.parser.class {YYParser}
|
||||
%define parse.error verbose
|
||||
|
||||
@@ -57,11 +57,11 @@ import java.util.*;
|
||||
start: 'a' 'b' 'c' ;
|
||||
|
||||
%%
|
||||
])
|
||||
]])
|
||||
|
||||
# Define comon code across to be included in
|
||||
# class Main for the trivial parser tests.
|
||||
m4_define([AT_TRIVIAL_COMMON],[
|
||||
m4_define([AT_TRIVIAL_COMMON],[[
|
||||
static class YYerror implements YYParser.Lexer
|
||||
{
|
||||
public Object getLVal() {return null;}
|
||||
@@ -82,29 +82,30 @@ m4_define([AT_TRIVIAL_COMMON],[
|
||||
teststate = -1;
|
||||
}
|
||||
|
||||
static String[[]] teststatename
|
||||
= new String[[]]{"YYACCEPT","YYABORT","YYERROR","UNKNOWN","YYPUSH_MORE"};
|
||||
static String[] teststatename
|
||||
= new String[]{"YYACCEPT","YYABORT","YYERROR","UNKNOWN","YYPUSH_MORE"};
|
||||
|
||||
static void check(int teststate, int expected, String msg)
|
||||
{
|
||||
System.err.println("teststate="+teststatename[[teststate]]
|
||||
+"; expected="+teststatename[[expected]]);
|
||||
if (teststate == expected)
|
||||
return;
|
||||
System.err.println("teststate="+teststatename[teststate]
|
||||
+"; expected="+teststatename[expected]);
|
||||
if (teststate != expected)
|
||||
{
|
||||
System.err.println("unexpected state: "+msg);
|
||||
System.exit(1);
|
||||
}
|
||||
])
|
||||
}
|
||||
]])
|
||||
|
||||
m4_define([AT_TRIVIAL_PARSER],[
|
||||
AT_TRIVIAL_GRAMMAR
|
||||
m4_define([AT_TRIVIAL_PARSER],[[
|
||||
]AT_TRIVIAL_GRAMMAR[
|
||||
|
||||
public class Main
|
||||
{
|
||||
|
||||
AT_TRIVIAL_COMMON
|
||||
]AT_TRIVIAL_COMMON[
|
||||
|
||||
static public void main (String[[]] argv)
|
||||
static public void main (String[] args)
|
||||
throws IOException
|
||||
{
|
||||
setup();
|
||||
@@ -131,17 +132,17 @@ m4_define([AT_TRIVIAL_PARSER],[
|
||||
}
|
||||
|
||||
}
|
||||
])
|
||||
]])
|
||||
|
||||
m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[
|
||||
AT_TRIVIAL_GRAMMAR
|
||||
m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[[
|
||||
]AT_TRIVIAL_GRAMMAR[
|
||||
|
||||
public class Main
|
||||
{
|
||||
|
||||
AT_TRIVIAL_COMMON
|
||||
]AT_TRIVIAL_COMMON[
|
||||
|
||||
static public void main (String[[]] argv)
|
||||
static public void main (String[] args)
|
||||
throws IOException
|
||||
{
|
||||
setup();
|
||||
@@ -159,7 +160,7 @@ m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[
|
||||
}
|
||||
|
||||
}
|
||||
])
|
||||
]])
|
||||
|
||||
## ----------------------------------------------------- ##
|
||||
## Trivial Push Parser with api.push-pull verification. ##
|
||||
@@ -359,9 +360,9 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc */
|
||||
st = new StreamTokenizer(rdr);
|
||||
st.resetSyntax();
|
||||
st.eolIsSignificant(true);
|
||||
st.whitespaceChars(9, 9);
|
||||
st.whitespaceChars(32, 32);
|
||||
st.wordChars(48, 57);
|
||||
st.whitespaceChars('\t', '\t');
|
||||
st.whitespaceChars(' ', ' ');
|
||||
st.wordChars('0', '9');
|
||||
}
|
||||
|
||||
Integer yylval;
|
||||
@@ -385,10 +386,10 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc */
|
||||
}
|
||||
|
||||
%code {
|
||||
public static void main (String[] argv)
|
||||
public static void main (String[] args)
|
||||
throws IOException
|
||||
{
|
||||
StringReader reader = getinput(argv[0]);
|
||||
StringReader reader = getinput(args[0]);
|
||||
UserLexer lexer = new UserLexer(reader);
|
||||
Calc calc = new Calc(lexer);
|
||||
calc.setDebugLevel(1);
|
||||
@@ -634,9 +635,9 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc. */
|
||||
st = new StreamTokenizer(rdr);
|
||||
st.resetSyntax();
|
||||
st.eolIsSignificant(true);
|
||||
st.whitespaceChars(9, 9);
|
||||
st.whitespaceChars(32, 32);
|
||||
st.wordChars(48, 57);
|
||||
st.whitespaceChars('\t', '\t');
|
||||
st.whitespaceChars(' ', ' ');
|
||||
st.wordChars('0', '9');
|
||||
}
|
||||
|
||||
Position yypos = new Position (1, 0);
|
||||
@@ -673,10 +674,10 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc. */
|
||||
%code { ]AT_JAVA_POSITION_DEFINE[ }
|
||||
|
||||
%code {
|
||||
public static void main (String[] argv)
|
||||
public static void main (String[] args)
|
||||
throws IOException
|
||||
{
|
||||
StringReader reader = getinput(argv[0]);
|
||||
StringReader reader = getinput(args[0]);
|
||||
Calc calc = new Calc(reader);
|
||||
calc.setDebugLevel(1);
|
||||
calc.parse();
|
||||
|
||||
Reference in New Issue
Block a user