factor : IPV4
                  | IPV6
                  | DATETIME
                  | TIMEDELTA
                  | INTEGER
                  | FLOAT
                  | VARIABLE
                  | CONSTANT
                  | FUNCTION RPAREN
                  | FUNCTION expression RPAREN
                  | LBRACK list RBRACK
                  | LPAREN expression RPAREN

def p_factor(self, tok):
        """factor : IPV4
                  | IPV6
                  | DATETIME
                  | TIMEDELTA
                  | INTEGER
                  | FLOAT
                  | VARIABLE
                  | CONSTANT
                  | FUNCTION RPAREN
                  | FUNCTION expression RPAREN
                  | LBRACK list RBRACK
                  | LPAREN expression RPAREN"""
        if len(tok) == 2:
            tok[0] = self._create_factor_rule(tok[1])
        elif len(tok) == 3:
            tok[0] = self._create_function_rule(tok[1])
        elif tok[1][0] == 'FUNCTION':
            tok[0] = self._create_function_rule(tok[1], tok[2])
        else:
            tok[0] = tok[2]