def p_expression_binop(self, p):
        """
        expression : expression PLUS expression
                  | expression MINUS expression
                  | expression TIMES expression
                  | expression DIVIDE expression
        """
        _LOGGER.debug("expresion -> expresion %s expression" % p[2])

        if self._autodefine_vars:
            self._init_vars(p[1], p[3])

        if p[1].type != p[3].type: raise TypeError()
        
        if p[1].type == TypedClass.LIST:
            if p[2] == '+':
                p[0] = TypedList(p[1].value + p[3].value)
            else:
                raise TypeError('operator not defined for lists')
        elif p[1].type == TypedClass.STRING:
            if p[2] == '+':
                p[0] = TypedClass(p[1].value + p[3].value, TypedClass.STRING)
            else:
                raise TypeError('operator not defined for strings')
        elif p[1].type == TypedClass.NUMBER: 
            if p[2] == '+':
                p[0] = TypedClass(p[1].value + p[3].value, TypedClass.NUMBER)
            elif p[2] == '-':
                p[0] = TypedClass(p[1].value - p[3].value, TypedClass.NUMBER)
            if p[2] == '*':
                p[0] = TypedClass(p[1].value * p[3].value, TypedClass.NUMBER)
            if p[2] == '/':
                p[0] = TypedClass(p[1].value / p[3].value, TypedClass.NUMBER)
        else:
            raise TypeError("operator invalid for this type")
def p_expression_binop ( self , p ) : _LOGGER . debug ( "expresion -> expresion %s expression" % p [ 2 ] ) if self . _autodefine_vars : self . _init_vars ( p [ 1 ] , p [ 3 ] ) if p [ 1 ] . type != p [ 3 ] . type : raise TypeError ( ) if p [ 1 ] . type == TypedClass . LIST : if p [ 2 ] == '+' : p [ 0 ] = TypedList ( p [ 1 ] . value + p [ 3 ] . value ) else : raise TypeError ( 'operator not defined for lists' ) elif p [ 1 ] . type == TypedClass . STRING : if p [ 2 ] == '+' : p [ 0 ] = TypedClass ( p [ 1 ] . value + p [ 3 ] . value , TypedClass . STRING ) else : raise TypeError ( 'operator not defined for strings' ) elif p [ 1 ] . type == TypedClass . NUMBER : if p [ 2 ] == '+' : p [ 0 ] = TypedClass ( p [ 1 ] . value + p [ 3 ] . value , TypedClass . NUMBER ) elif p [ 2 ] == '-' : p [ 0 ] = TypedClass ( p [ 1 ] . value - p [ 3 ] . value , TypedClass . NUMBER ) if p [ 2 ] == '*' : p [ 0 ] = TypedClass ( p [ 1 ] . value * p [ 3 ] . value , TypedClass . NUMBER ) if p [ 2 ] == '/' : p [ 0 ] = TypedClass ( p [ 1 ] . value / p [ 3 ] . value , TypedClass . NUMBER ) else : raise TypeError ( "operator invalid for this type" )
expression : expression PLUS expression
                  | expression MINUS expression
                  | expression TIMES expression
                  | expression DIVIDE expression