mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
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:
parent
59451b90e5
commit
1dea1bd12c
5 changed files with 75 additions and 113 deletions
|
@ -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']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue