Changeset fb5c8c7 in sasmodels


Ignore:
Timestamp:
Dec 15, 2017 11:18:08 AM (7 years ago)
Author:
Omer Eisenberg <omereis@…>
Children:
fa74acf
Parents:
937afef
Message:

fixed precedence bug, by writing parantheses around binary operators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/py2c.py

    r937afef rfb5c8c7  
    464612/07/2017, OE: C variable definition handled in 'define_C_Vars' 
    4747              : Python integer division, '//', translated to C in 'translate_integer_divide' 
     4812/15/2017, OE: Precedence maintained by writing opening and closing parenthesesm '(',')', 
     49                in procedure 'visit_BinOp'. 
    4850""" 
    4951import ast 
     
    892894 
    893895    def visit_BinOp(self, node): 
     896        self.write_c("(") 
    894897        if ('%s' % BINOP_SYMBOLS[type(node.op)] == BINOP_SYMBOLS[ast.Pow]): 
    895898            self.translate_power (node) 
     
    900903            self.write_c(' %s ' % BINOP_SYMBOLS[type(node.op)]) 
    901904            self.visit(node.right) 
     905        self.write_c(")") 
     906 
    902907#       for C 
    903908    def visit_BoolOp(self, node): 
Note: See TracChangeset for help on using the changeset viewer.