aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2013-08-28 08:05:12 +0200
committerHans Bolinder <[email protected]>2013-08-28 08:05:12 +0200
commit682e562a20c2ab650a3a5e0f885af19bce0d5a14 (patch)
tree9a8b2bbf9f0cbf6f6c23d755d3bc72e463a575d4
parente2c0f6dd1fc9b6bd506a481644b9c63f9d575aa1 (diff)
parent63f418886743517b426920590fb09d6c4f1eb8c7 (diff)
downloadotp-682e562a20c2ab650a3a5e0f885af19bce0d5a14.tar.gz
otp-682e562a20c2ab650a3a5e0f885af19bce0d5a14.tar.bz2
otp-682e562a20c2ab650a3a5e0f885af19bce0d5a14.zip
Merge branch 'hb/parsetools/fix_yecc_bug/OTP-11269' into maint
* hb/parsetools/fix_yecc_bug/OTP-11269: Fix a Yecc bug
-rw-r--r--lib/parsetools/src/yecc.erl8
-rw-r--r--lib/parsetools/test/yecc_SUITE.erl37
2 files changed, 39 insertions, 6 deletions
diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl
index 53292b037a..f9207d926e 100644
--- a/lib/parsetools/src/yecc.erl
+++ b/lib/parsetools/src/yecc.erl
@@ -2106,8 +2106,8 @@ output_state_actions(St0, State, State, {Actions, Jump}, SI) ->
output_state_actions(St, State, JState, _XActions, _SI) ->
fwrite(St, <<"%% yeccpars2_~w: see yeccpars2_~w\n\n">>, [State, JState]).
-output_state_actions1(St, State, [], _IsFirst, normal, _SI) ->
- output_state_actions_fini(State, St);
+output_state_actions1(St, State, [], IsFirst, normal, _SI) ->
+ output_state_actions_fini(State, IsFirst, St);
output_state_actions1(St0, State, [], IsFirst, {to, ToS}, _SI) ->
St = delim(St0, IsFirst),
fwrite(St,
@@ -2151,9 +2151,9 @@ output_call_to_includefile(NewState, St) ->
fwrite(St, <<" yeccpars1(S, ~w, Ss, Stack, T, Ts, Tzr)">>,
[NewState]).
-output_state_actions_fini(State, St0) ->
+output_state_actions_fini(State, IsFirst, St0) ->
%% Backward compatible.
- St10 = delim(St0, false),
+ St10 = delim(St0, IsFirst),
St = fwrite(St10, <<"yeccpars2_~w(_, _, _, _, T, _, _) ->\n">>, [State]),
fwrite(St, <<" yeccerror(T).\n\n">>, []).
diff --git a/lib/parsetools/test/yecc_SUITE.erl b/lib/parsetools/test/yecc_SUITE.erl
index 3d66a2a525..9c865a1ec6 100644
--- a/lib/parsetools/test/yecc_SUITE.erl
+++ b/lib/parsetools/test/yecc_SUITE.erl
@@ -49,7 +49,7 @@
otp_5369/1, otp_6362/1, otp_7945/1, otp_8483/1, otp_8486/1,
- otp_7292/1, otp_7969/1, otp_8919/1, otp_10302/1]).
+ otp_7292/1, otp_7969/1, otp_8919/1, otp_10302/1, otp_11269/1]).
% Default timetrap timeout (set in init_per_testcase).
-define(default_timeout, ?t:minutes(1)).
@@ -76,7 +76,8 @@ groups() ->
[empty, prec, yeccpre, lalr, old_yecc, other_examples]},
{bugs, [],
[otp_5369, otp_6362, otp_7945, otp_8483, otp_8486]},
- {improvements, [], [otp_7292, otp_7969, otp_8919, otp_10302]}].
+ {improvements, [], [otp_7292, otp_7969, otp_8919, otp_10302,
+ otp_11269]}].
init_per_suite(Config) ->
Config.
@@ -1963,6 +1964,38 @@ otp_10302(Config) when is_list(Config) ->
run(Config, Ts),
ok.
+otp_11269(doc) ->
+ "OTP-11269. A bug.";
+otp_11269(suite) -> [];
+otp_11269(Config) when is_list(Config) ->
+ Dir = ?privdir,
+ Filename = filename:join(Dir, "OTP-11269.yrl"),
+ Ret = [return, {report, false}],
+ Pai = <<"Nonterminals
+ list list0 list1 newline_list.
+
+ Terminals
+ '\n' semi.
+
+ Rootsymbol list.
+
+ Endsymbol '$end'.
+
+ list -> newline_list list0 : '$2'.
+
+ list0 -> list1 '\n' newline_list : '$1'.
+
+ list1 -> list1 semi newline_list list1 :
+ {command_connect, '$1', '$4', semi}.
+
+ newline_list -> newline_list '\n' : nil.">>,
+ ok = file:write_file(Filename, Pai),
+ {ok,ErlFile,[{_YrlFile,[{none,yecc,{conflicts,1,0}}]}]} =
+ yecc:file(Filename, Ret),
+ Opts = [return, warn_unused_vars,{outdir,Dir}],
+ {ok,'OTP-11269',_Warnings} = compile:file(ErlFile, Opts),
+ ok.
+
yeccpre_size() ->
yeccpre_size(default_yeccpre()).