From c3e32911a763f16dd1a485a3b3bc0048df80b56e Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 3 Mar 2015 10:22:21 +0100 Subject: [PATCH] Fix: else if doesn't work without an else branch fixes #8572 --- lib/config/config_parser.yy | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 9d52912e1..b2ca609e9 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -808,12 +808,22 @@ rterm_side_effect: rterm '(' rterm_items ')' $$ = new FunctionExpression(*$2, new std::map(), $5, @$); delete $2; } - | T_IF '(' rterm ')' rterm_scope + | T_IF '(' rterm ')' rterm_scope else_if_branches { DictExpression *atrue = dynamic_cast($5); atrue->MakeInline(); - $$ = new ConditionalExpression($3, atrue, NULL, @$); + std::vector > ebranches = *$6; + delete $6; + + Expression *afalse = NULL; + + for (int i = ebranches.size() - 1; i >= 0; i--) { + const std::pair& ebranch = ebranches[i]; + afalse = new ConditionalExpression(ebranch.first, ebranch.second, afalse, @6); + } + + $$ = new ConditionalExpression($3, atrue, afalse, @$); } | T_IF '(' rterm ')' rterm_scope else_if_branches T_ELSE rterm_scope {