aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo/lingo-gr.y
diff options
context:
space:
mode:
authorEugene Sandulenko2019-12-04 01:20:39 +0100
committerEugene Sandulenko2019-12-05 01:35:52 +0100
commit38cd13cdb492d15f40f6e991f9fda96195e90937 (patch)
tree15fa6154aa76a1f29cac3bba6c85a85ac26bb4ac /engines/director/lingo/lingo-gr.y
parent6c706037e4aae7471341973b27fb7a85b3668932 (diff)
downloadscummvm-rg350-38cd13cdb492d15f40f6e991f9fda96195e90937.tar.gz
scummvm-rg350-38cd13cdb492d15f40f6e991f9fda96195e90937.tar.bz2
scummvm-rg350-38cd13cdb492d15f40f6e991f9fda96195e90937.zip
DIRECTOR: LINGO: Simplify 'if' statement parser
Diffstat (limited to 'engines/director/lingo/lingo-gr.y')
-rw-r--r--engines/director/lingo/lingo-gr.y50
1 files changed, 15 insertions, 35 deletions
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y
index d49a76112b..1d1b2e0393 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -247,37 +247,6 @@ stmt: stmtoneliner
}
;
-elseifstmt: elseifstmt elseifstmt1
- | elseifstmt1
- ;
-
-elseifstmtoneliner: elseifstmtoneliner elseifstmtoneliner1
- | elseifstmtoneliner1
- ;
-
-elseifstmtoneliner1: elseif expr tTHEN begin stmt end {
- inst then = 0;
- WRITE_UINT32(&then, $4 - $1);
- (*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
-
- g_lingo->codeLabel($1); }
- ;
-
-elseifstmt1: elseifstmtoneliner
- | elseif expr tTHEN begin stmtlist end {
- inst then = 0;
- WRITE_UINT32(&then, $5 - $1);
- (*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
-
- g_lingo->codeLabel($1); }
- | elseif expr tTHENNL begin stmtlist end {
- inst then = 0;
- WRITE_UINT32(&then, $5 - $1);
- (*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
-
- g_lingo->codeLabel($1); }
- ;
-
ifstmt: if expr tTHENNL stmtlist end ENDCLAUSE {
inst then = 0, end = 0;
WRITE_UINT32(&then, $4 - $1);
@@ -309,7 +278,7 @@ ifstmt: if expr tTHENNL stmtlist end ENDCLAUSE {
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
g_lingo->processIf(0, 0); }
- | if expr tTHEN begin stmtoneliner end elseifstmt end endifstmt end {
+ | if expr tTHEN begin stmtoneliner end elseifstmtlist end endifstmt end {
inst then = 0, else1 = 0, end = 0;
WRITE_UINT32(&then, $4 - $1);
WRITE_UINT32(&else1, $6 - $1);
@@ -319,7 +288,7 @@ ifstmt: if expr tTHENNL stmtlist end ENDCLAUSE {
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
g_lingo->processIf(0, $10 - $1); }
- | if expr tTHENNL stmtlist end elseifstmt end endifstmt end {
+ | if expr tTHENNL stmtlist end elseifstmtlist end endifstmt end {
inst then = 0, else1 = 0, end = 0;
WRITE_UINT32(&then, $4 - $1);
WRITE_UINT32(&else1, $7 - $1);
@@ -352,14 +321,25 @@ ifstmt: if expr tTHENNL stmtlist end ENDCLAUSE {
;
+elseifstmtlist: elseifstmtlist elseifstmt
+ | elseifstmt
+ ;
-endifstmt: elseif expr tTHEN begin stmtoneliner end tELSE stmtoneliner end {
+elseifstmt: elseif expr tTHEN begin stmtoneliner end {
inst then = 0;
WRITE_UINT32(&then, $4 - $1);
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
g_lingo->codeLabel($1); }
- | elseif expr tTHEN begin stmtoneliner end {
+ | elseif expr tTHENNL begin stmtlist end {
+ inst then = 0;
+ WRITE_UINT32(&then, $5 - $1);
+ (*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
+
+ g_lingo->codeLabel($1); }
+ ;
+
+endifstmt: elseif expr tTHEN begin stmtoneliner end tELSE stmtoneliner end {
inst then = 0;
WRITE_UINT32(&then, $4 - $1);
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */