Make parentheses no longer explicit in the AST (Beta).

The output module adds parentheses where necessary, depending on the evaluation order in the tree. Or that's the idea. Prone to bugs, let's see how it bodes.
This commit is contained in:
Sei Lisa 2015-02-28 00:43:26 +01:00
parent 59451b90e5
commit 1dea1bd12c
5 changed files with 75 additions and 113 deletions

View file

@ -384,12 +384,8 @@ class deadcode(object):
else: # assumed VECTOR or ROTATION per SymbolReplacedOrDeleted
SEF = 'SEF' in value
value = self.Cast(value['ch'][fieldidx], 'float')
# Replace it, in parentheses
if value['nt'] not in ('CONST','()','FLD','IDENT','FNCALL'):
node = curnode['ch'][index] = \
{'nt':'()', 'X':True, 't':value['t'], 'ch':[value]}
else:
node = curnode['ch'][index] = value
# Replace it
node = curnode['ch'][index] = value
if SEF:
node['SEF'] = True
@ -400,18 +396,11 @@ class deadcode(object):
new = sym['W']
new['X'] = True
if new['nt'] not in ('CONST','()','FLD','IDENT','FNCALL'):
new = {'nt':'()', 'X':True, 't':sym['W']['t'],
'ch':[new]}
SEF = 'SEF' in sym['W']
if SEF:
new['SEF'] = True
if new['t'] != node['t']:
new = self.Cast(new, node['t'])
if new['nt'] not in ('CONST','()','FLD','IDENT','FNCALL'):
new = {'nt':'()', 'X':True, 't':node['t'], 'ch':[new]}
if SEF:
new['SEF'] = True
curnode['ch'][index] = node = new
# Delete orig if present, as we've eliminated the original
#if 'orig' in sym['W']: