From f0ed046a98f2786f98d680b3cb7aee0457713f81 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 1 Jun 2013 20:09:37 +0000 Subject: [PATCH] LunaCON: fix mistranslation of CON "else { if" to Lua "elseif". When encountering a non-empty statement inside braces, emit "do" ... "end". git-svn-id: https://svn.eduke32.com/eduke32@3840 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/lunacon.lua | 2 +- .../source/lunatic/test/else_brace_if.con | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 polymer/eduke32/source/lunatic/test/else_brace_if.con diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index f5d711e98..a7675bf1e 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -3086,7 +3086,7 @@ local Grammar = Pat{ * sp1 * Var("single_stmt") * (lpeg.Cc(nil) / on.while_end), stmt_common = Keyw("{") * sp1 * "}" / "" -- space separation of commands in CON is for a reason! - + Keyw("{") * sp1 * lpeg.Ct(stmt_list) * sp1 * "}" + + lpeg.Ct(Keyw("{")/"do" * sp1 * stmt_list * sp1 * (Keyw("}")/"end")) + con_inner_command + Var("switch_stmt") + lpeg.Ct(Var("while_stmt")), single_stmt = Stmt( lone_else^-1 * (Var("stmt_common") + Var("if_stmt")) ), diff --git a/polymer/eduke32/source/lunatic/test/else_brace_if.con b/polymer/eduke32/source/lunatic/test/else_brace_if.con new file mode 100644 index 000000000..4ba5e032c --- /dev/null +++ b/polymer/eduke32/source/lunatic/test/else_brace_if.con @@ -0,0 +1,16 @@ + +actor 1890 1 + // The following "else { if" must not be translated to an "elseif". + ifcount 1 nullop else + { + ifvare 0 0 + spawn 1 + else + spawn 2 + + ifvare 1 1 + spawn 3 + else ifvare 1 2 + spawn 4 + } +enda