def __unary(self, tcontext, funcname): ''' unary = ("&" | "*") unary | ("+" | "-")? term ''' token = tcontext.consume_symbol('&') if token: return NodeFactory.create_address_node( self.__unary(tcontext, funcname)) token = tcontext.consume_symbol('*') if token: return NodeFactory.create_dereference_node( self.__unary(tcontext, funcname)) token = tcontext.consume_symbol('+') if token: return self.__term(tcontext, funcname) token = tcontext.consume_symbol('-') if token: return NodeFactory.create_ope_node(NodeTypes.SUB, NodeFactory.create_num_node(0), self.__term(tcontext, funcname)) return self.__term(tcontext, funcname)
def __parse_common_func(self, tcontext, funcname, map_, next_func): node = next_func(tcontext, funcname) while True: for k, v in map_.items(): token = tcontext.consume_symbol(k) if token: node = NodeFactory.create_ope_node( v, node, next_func(tcontext, funcname)) break else: return node