From: Akim Demaille Date: Tue, 11 Nov 2008 13:42:35 +0000 (+0100) Subject: Get rid of tabulations in the Java output. X-Git-Tag: v2.7.90~1086 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/11707b2b48fb781ff0e7fd3befdfb02f787a76e4?hp=905f069774cbcf94c6f46e8768e1f6a4a2e72591 Get rid of tabulations in the Java output. Test 214 was failing: it greps with a pattern containing [ ]* which obviously meant to catch spaces and tabs, but contained only tabs. Tabulations in sources are a nuisance, so to simplify the matter, get rid of all the tabulations in the Java sources. The other skeletons will be treated equally later. * data/java.m4, data/lalr1.java: Untabify. * tests/java.at: Simplify AT_CHECK_JAVA_GREP invocations: tabulations are no longer generated. --- diff --git a/data/java.m4 b/data/java.m4 index fc8f8680..9872505a 100644 --- a/data/java.m4 +++ b/data/java.m4 @@ -29,7 +29,7 @@ m4_define([b4_comment], [/* m4_bpatsubst([$1], [ # -------------------------- # Join two lists with a comma if necessary. m4_define([b4_list2], - [$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2]) + [$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2]) # b4_percent_define_get3(DEF, PRE, POST, NOT) @@ -37,8 +37,8 @@ m4_define([b4_list2], # Expand to the value of DEF surrounded by PRE and POST if it's %define'ed, # otherwise NOT. m4_define([b4_percent_define_get3], - [m4_ifval(m4_quote(b4_percent_define_get([$1])), - [$2[]b4_percent_define_get([$1])[]$3], [$4])]) + [m4_ifval(m4_quote(b4_percent_define_get([$1])), + [$2[]b4_percent_define_get([$1])[]$3], [$4])]) @@ -103,7 +103,7 @@ m4_define([b4_identification], m4_define([b4_int_type], [m4_if(b4_ints_in($@, [-128], [127]), [1], [byte], b4_ints_in($@, [-32768], [32767]), [1], [short], - [int])]) + [int])]) # b4_int_type_for(NAME) # --------------------- @@ -250,11 +250,11 @@ m4_define([b4_parse_param], b4_parse_param) m4_define([b4_lex_param_decl], [m4_ifset([b4_lex_param], [b4_remove_comma([$1], - b4_param_decls(b4_lex_param))], - [$1])]) + b4_param_decls(b4_lex_param))], + [$1])]) m4_define([b4_param_decls], - [m4_map([b4_param_decl], [$@])]) + [m4_map([b4_param_decl], [$@])]) m4_define([b4_param_decl], [, $1]) m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)]) @@ -267,8 +267,8 @@ m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)]) m4_define([b4_parse_param_decl], [m4_ifset([b4_parse_param], [b4_remove_comma([$1], - b4_param_decls(b4_parse_param))], - [$1])]) + b4_param_decls(b4_parse_param))], + [$1])]) @@ -277,11 +277,11 @@ m4_define([b4_parse_param_decl], # Delegating the lexer parameters to the lexer constructor. m4_define([b4_lex_param_call], [m4_ifset([b4_lex_param], - [b4_remove_comma([$1], - b4_param_calls(b4_lex_param))], - [$1])]) + [b4_remove_comma([$1], + b4_param_calls(b4_lex_param))], + [$1])]) m4_define([b4_param_calls], - [m4_map([b4_param_call], [$@])]) + [m4_map([b4_param_call], [$@])]) m4_define([b4_param_call], [, $2]) @@ -291,13 +291,13 @@ m4_define([b4_param_call], [, $2]) # Extra initialisations of the constructor. m4_define([b4_parse_param_cons], [m4_ifset([b4_parse_param], - [b4_constructor_calls(b4_parse_param)])]) + [b4_constructor_calls(b4_parse_param)])]) m4_define([b4_constructor_calls], - [m4_map([b4_constructor_call], [$@])]) + [m4_map([b4_constructor_call], [$@])]) m4_define([b4_constructor_call], - [this.$2 = $2; - ]) + [this.$2 = $2; + ]) @@ -306,15 +306,15 @@ m4_define([b4_constructor_call], # Extra instance variables. m4_define([b4_parse_param_vars], [m4_ifset([b4_parse_param], - [ + [ /* User arguments. */ b4_var_decls(b4_parse_param)])]) m4_define([b4_var_decls], - [m4_map_sep([b4_var_decl], [ + [m4_map_sep([b4_var_decl], [ ], [$@])]) m4_define([b4_var_decl], - [ protected final $1;]) + [ protected final $1;]) @@ -322,4 +322,4 @@ m4_define([b4_var_decl], # ----------------------- # Expand to either an empty string or "throws THROWS". m4_define([b4_maybe_throws], - [m4_ifval($1, [throws $1])]) + [m4_ifval($1, [throws $1])]) diff --git a/data/lalr1.java b/data/lalr1.java index 3358545d..38b5b2fa 100644 --- a/data/lalr1.java +++ b/data/lalr1.java @@ -264,24 +264,24 @@ b4_lexer_if([[ public int height = -1; public final void push (int state, ]b4_yystype[ value]dnl - b4_locations_if([, ]b4_location_type[ loc])[) { + b4_locations_if([, ]b4_location_type[ loc])[) { height++; if (size == height) { - int[] newStateStack = new int[size * 2]; - System.arraycopy (stateStack, 0, newStateStack, 0, height); - stateStack = newStateStack; - ]b4_locations_if([[ - ]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2]; - System.arraycopy (locStack, 0, newLocStack, 0, height); - locStack = newLocStack;]]) - - b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2]; - System.arraycopy (valueStack, 0, newValueStack, 0, height); - valueStack = newValueStack; - - size *= 2; - } + int[] newStateStack = new int[size * 2]; + System.arraycopy (stateStack, 0, newStateStack, 0, height); + stateStack = newStateStack; + ]b4_locations_if([[ + ]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2]; + System.arraycopy (locStack, 0, newLocStack, 0, height); + locStack = newLocStack;]]) + + b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2]; + System.arraycopy (valueStack, 0, newValueStack, 0, height); + valueStack = newValueStack; + + size *= 2; + } stateStack[height] = state; ]b4_locations_if([[locStack[height] = loc;]])[ @@ -295,7 +295,7 @@ b4_lexer_if([[ public final void pop (int num) { // Avoid memory leaks... garbage collection is a white lie! if (num > 0) { - java.util.Arrays.fill (valueStack, height - num + 1, height, null); + java.util.Arrays.fill (valueStack, height - num + 1, height, null); ]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height, null);]])[ } height -= num; @@ -320,8 +320,8 @@ b4_lexer_if([[ for (int i = 0; i < height; i++) { - out.print (' '); - out.print (stateStack[i]); + out.print (' '); + out.print (stateStack[i]); } out.println (); } @@ -384,8 +384,8 @@ b4_lexer_if([[ switch (yyn) { - ]b4_user_actions[ - default: break; + ]b4_user_actions[ + default: break; } yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[); @@ -397,7 +397,7 @@ b4_lexer_if([[ yyn = yyr1_[yyn]; int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0); if (0 <= yystate && yystate <= yylast_ - && yycheck_[yystate] == yystack.stateAt (0)) + && yycheck_[yystate] == yystack.stateAt (0)) yystate = yytable_[yystate]; else yystate = yydefgoto_[yyn - yyntokens_]; @@ -425,7 +425,7 @@ b4_lexer_if([[ break strip_quotes; case '\\': - if (yystr.charAt(++i) != '\\') + if (yystr.charAt(++i) != '\\') break strip_quotes; /* Fall through. */ default: @@ -448,14 +448,14 @@ b4_lexer_if([[ `--------------------------------*/ private void yy_symbol_print (String s, int yytype, - ]b4_yystype[ yyvaluep]dnl - b4_locations_if([, Object yylocationp])[) + ]b4_yystype[ yyvaluep]dnl + b4_locations_if([, Object yylocationp])[) { if (yydebug > 0) yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ") - + yytname_[yytype] + " ("]b4_locations_if([ - + yylocationp + ": "])[ - + (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")"); + + yytname_[yytype] + " ("]b4_locations_if([ + + yylocationp + ": "])[ + + (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")"); } /** @@ -513,7 +513,7 @@ m4_popdef([b4_at_dollar])])dnl switch (label) { /* New state. Unlike in the C/C++ skeletons, the state is already - pushed when we come here. */ + pushed when we come here. */ case YYNEWSTATE: yycdebug ("Entering state " + yystate + "\n"); if (yydebug > 0) @@ -528,7 +528,7 @@ m4_popdef([b4_at_dollar])])dnl if (yyn == yypact_ninf_) { label = YYDEFAULT; - break; + break; } /* Read a lookahead token. */ @@ -550,9 +550,9 @@ m4_popdef([b4_at_dollar])])dnl } else { - yytoken = yytranslate_ (yychar); - yy_symbol_print ("Next token is", yytoken, - yylval]b4_locations_if([, yylloc])[); + yytoken = yytranslate_ (yychar); + yy_symbol_print ("Next token is", yytoken, + yylval]b4_locations_if([, yylloc])[); } /* If the proper action on seeing token YYTOKEN is to reduce or to @@ -564,20 +564,20 @@ m4_popdef([b4_at_dollar])])dnl /* <= 0 means reduce or error. */ else if ((yyn = yytable_[yyn]) <= 0) { - if (yyn == 0 || yyn == yytable_ninf_) - label = YYFAIL; - else - { - yyn = -yyn; - label = YYREDUCE; - } + if (yyn == 0 || yyn == yytable_ninf_) + label = YYFAIL; + else + { + yyn = -yyn; + label = YYREDUCE; + } } else { /* Shift the lookahead token. */ - yy_symbol_print ("Shifting", yytoken, - yylval]b4_locations_if([, yylloc])[); + yy_symbol_print ("Shifting", yytoken, + yylval]b4_locations_if([, yylloc])[); /* Discard the token being shifted. */ yychar = yyempty_; @@ -610,7 +610,7 @@ m4_popdef([b4_at_dollar])])dnl case YYREDUCE: yylen = yyr2_[yyn]; label = yyaction (yyn, yystack, yylen); - yystate = yystack.stateAt (0); + yystate = yystack.stateAt (0); break; /*------------------------------------. @@ -620,8 +620,8 @@ m4_popdef([b4_at_dollar])])dnl /* If not already recovering from an error, report this error. */ if (yyerrstatus_ == 0) { - ++yynerrs_; - yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken)); + ++yynerrs_; + yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken)); } ]b4_locations_if([yyerrloc = yylloc;])[ @@ -637,7 +637,7 @@ m4_popdef([b4_at_dollar])])dnl return false; } else - yychar = yyempty_; + yychar = yyempty_; } /* Else will try to reuse lookahead token after shifting the error @@ -663,46 +663,46 @@ m4_popdef([b4_at_dollar])])dnl | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ case YYERRLAB1: - yyerrstatus_ = 3; /* Each real token shifted decrements this. */ + yyerrstatus_ = 3; /* Each real token shifted decrements this. */ for (;;) { - yyn = yypact_[yystate]; - if (yyn != yypact_ninf_) - { - yyn += yyterror_; - if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) - { - yyn = yytable_[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yystack.height == 1) - return false; - - ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[ - yystack.pop (); - yystate = yystack.stateAt (0); - if (yydebug > 0) - yystack.print (yyDebugStream); + yyn = yypact_[yystate]; + if (yyn != yypact_ninf_) + { + yyn += yyterror_; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yystack.height == 1) + return false; + + ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[ + yystack.pop (); + yystate = yystack.stateAt (0); + if (yydebug > 0) + yystack.print (yyDebugStream); } - ]b4_locations_if([ - /* Muck with the stack to setup for yylloc. */ - yystack.push (0, null, yylloc); - yystack.push (0, null, yyerrloc); + ]b4_locations_if([ + /* Muck with the stack to setup for yylloc. */ + yystack.push (0, null, yylloc); + yystack.push (0, null, yyerrloc); yyloc = yylloc (yystack, 2); - yystack.pop (2);])[ + yystack.pop (2);])[ /* Shift the error token. */ yy_symbol_print ("Shifting", yystos_[yyn], - yylval]b4_locations_if([, yyloc])[); + yylval]b4_locations_if([, yyloc])[); yystate = yyn; - yystack.push (yyn, yylval]b4_locations_if([, yyloc])[); + yystack.push (yyn, yylval]b4_locations_if([, yyloc])[); label = YYNEWSTATE; break; @@ -724,34 +724,34 @@ m4_popdef([b4_at_dollar])])dnl int yyn = yypact_[yystate]; if (yypact_ninf_ < yyn && yyn <= yylast_) { - StringBuffer res; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = yylast_ - yyn + 1; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - int count = 0; - for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn] == x && x != yyterror_) - ++count; - - // FIXME: This method of building the message is not compatible - // with internationalization. - res = new StringBuffer ("syntax error, unexpected "); - res.append (yytnamerr_ (yytname_[tok])); - if (count < 5) - { - count = 0; - for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn] == x && x != yyterror_) - { - res.append (count++ == 0 ? ", expecting " : " or "); - res.append (yytnamerr_ (yytname_[x])); - } - } + StringBuffer res; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + int count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + ++count; + + // FIXME: This method of building the message is not compatible + // with internationalization. + res = new StringBuffer ("syntax error, unexpected "); + res.append (yytnamerr_ (yytname_[tok])); + if (count < 5) + { + count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + { + res.append (count++ == 0 ? ", expecting " : " or "); + res.append (yytnamerr_ (yytname_[x])); + } + } return res.toString (); } } @@ -822,14 +822,14 @@ m4_popdef([b4_at_dollar])])dnl int yynrhs = yyr2_[yyrule]; /* Print the symbols being reduced, and their result. */ yycdebug ("Reducing stack by rule " + (yyrule - 1) - + " (line " + yylno + "), "); + + " (line " + yylno + "), "); /* The symbols being reduced. */ for (int yyi = 0; yyi < yynrhs; yyi++) yy_symbol_print (" $" + (yyi + 1) + " =", - yyrhs_[yyprhs_[yyrule] + yyi], - ]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([, - b4_rhs_location(yynrhs, yyi + 1)])[); + yyrhs_[yyprhs_[yyrule] + yyi], + ]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([, + b4_rhs_location(yynrhs, yyi + 1)])[); } /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ diff --git a/tests/java.at b/tests/java.at index 8ea47831..0e3122b2 100644 --- a/tests/java.at +++ b/tests/java.at @@ -134,7 +134,7 @@ AT_LOCATION_IF([[ ]], [[ public void yyerror (String s) { - System.err.println (s); + System.err.println (s); } ]])[ @@ -343,7 +343,7 @@ _AT_CHECK_JAVA_CALC_ERROR([$1], [/dev/null], # first error is ")", which is needed to recover from the error and # produce the "0" that triggers the "0 != 1" error. # -_AT_CHECK_JAVA_CALC_ERROR([$1], +_AT_CHECK_JAVA_CALC_ERROR([$1], [() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1], [1: syntax error, unexpected ')', expecting number or '-' or '(' or '!' 1: syntax error, unexpected ')', expecting number or '-' or '(' or '!' @@ -459,7 +459,7 @@ m4_define([AT_CHECK_JAVA_MINIMAL_W_LEXER], { $3 } - + $4 }], [$5], [$7])]) @@ -591,7 +591,7 @@ AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer) *]]) AT_CHECK_JAVA_MINIMAL([[%parse-param {int parse_param1}]]) AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1) *]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]]) AT_CHECK_JAVA_MINIMAL([[ %parse-param {int parse_param1} @@ -599,8 +599,8 @@ AT_CHECK_JAVA_MINIMAL([[ AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]]) AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]]) AT_CHECK_JAVA_MINIMAL_W_LEXER([], [], [[return EOF;]]) AT_CHECK_JAVA_GREP([[ *public YYParser () *]]) @@ -611,7 +611,7 @@ AT_CHECK_JAVA_MINIMAL_W_LEXER([[%parse-param {int parse_param1}]], AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1) *]]) AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1) *]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[ %parse-param {int parse_param1} @@ -621,8 +621,8 @@ AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]]) AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1, *long parse_param2) *]]) AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]], [2]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2]) +AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[%lex-param {char lex_param1}]], [], [[return EOF;]], [[YYLexer (char lex_param1) {}]]) @@ -647,8 +647,8 @@ AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]]) AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2, *int parse_param1, *long parse_param2) *]]) AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1, *lex_param2);]]) AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]], [2]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2]) +AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2]) AT_CLEANUP