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

@ -31,13 +31,6 @@ class optimizer(foldconst, renamer, deadcode):
# value unchanged
if value['t'] == newtype:
return value
if value not in ('CONST','()','FLD','IDENT','FNCALL','V++','V--',
'VECTOR','ROTATION','LIST'):
value = {'nt':'()', 't':newtype, 'ch':[value]}
if 'SEF' in value['ch'][0]:
value['SEF'] = True
if 'X' in value['ch'][0]:
value['X'] = value['ch'][0]['X']
ret = {'nt':'CAST', 't':newtype, 'ch':[value]}
if 'SEF' in value:
ret['SEF'] = True