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

@ -798,8 +798,6 @@ class parser(object):
if tok0 == '(':
# Parenthesized expression or typecast
# TODO: Don't include parentheses in the tree, defer to the output
# module to add them where necessary.
self.NextToken()
if self.tok[0] != 'TYPE':
@ -807,7 +805,7 @@ class parser(object):
expr = self.Parse_expression()
self.expect(')')
self.NextToken()
return {'nt':'()', 't':expr['t'], 'ch':[expr]}
return expr
# Typecast
typ = self.tok[1]
@ -825,7 +823,6 @@ class parser(object):
expr = self.Parse_expression()
self.expect(')')
self.NextToken()
expr = {'nt':'()', 't':expr['t'], 'ch':[expr]}
else:
expr = self.Parse_unary_postfix_expression(AllowAssignment = False)
basetype = expr['t']