From a93ea0ca192bd3e432f2b80363b44ad62dfdb9ae Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Thu, 17 May 2018 06:33:01 +0200 Subject: [PATCH] Delete statements in a {} block when they are SEF This is probably equivalent to what we did, as FoldStmt changes SEF statements to ';' statements, but it's simpler. --- lslopt/lslfoldconst.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index d8cbd00..52b31b4 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -1578,17 +1578,18 @@ class foldconst(object): return if nt == '{}': + # Remove SEF statements, and mark as SEF if it ends up empty idx = 0 issef = True while idx < len(child): self.FoldTree(child, idx) self.FoldStmt(child, idx) - issef = issef and child[idx].SEF - if child[idx].nt == ';' \ - or child[idx].nt == '{}' and not child[idx].ch: + if child[idx].SEF: + # SEF statements can be removed del child[idx] else: idx += 1 + issef = False if issef: node.SEF = True return