示例#1
0
def gen_const(ast_type,args):
    #print "gen const , ast_type = ",ast_type , "args = ", args
    if ast_type == "ip":
        return IP(args)
    elif ast_type == "int":
        return Integer(args)
    elif ast_type == "bool":
        return Boolean(args)
    return None
示例#2
0
 def get_length_of_list(p):
     if (self.global_conditional_state.state == True
             or self.global_conditional_state.state is None):
         if p[-1].type == "LIST":
             length = len(p[-1].value)
             return Integer(length)
         else:
             err = Error_type(
                 "Waifu not suitable",
                 f"waifu does not have size baa-aaka only harem has it's size but '{p[-1].name}-chan' is not harem type",
             )
             self.print_stack.append(err)
             raise ValueError()
示例#3
0
 def line(p):
     function = p[1]
     if function.gettokentype() == 'SET_INT':
         return SetVariable(p[2].value, p[1].value, Integer(p[3].value))
     elif function.gettokentype() == 'SET_FLOAT':
         return SetVariable(p[2].value, p[1].value, Float(p[3].value))
     elif function.gettokentype() == 'SET_CHAR':
         return SetVariable(p[2].value, p[1].value, Char(p[3].value))
     elif function.gettokentype() == 'SET_STRING':
         return SetVariable(p[2].value, p[1].value, String(p[3].value))
     elif function.gettokentype() == 'SET_BOOL':
         return SetVariable(p[2].value, p[1].value, Bool(p[3].value))
     elif function.gettokentype() == 'SET_ARRAY':
         type = p[2].gettokentype()
         if type == 'SET_INT':
             return SetArray(p[4], 0, p[3].value)
         elif type == 'SET_FLOAT':
             return SetArray(p[4], 0.0, p[3].value)
         elif type == 'SET_STRING':
             return SetArray(p[4], "a", p[3].value)
示例#4
0
 def expression(p):
     if p[2].gettokentype() == 'INT':
         return SetArrayPosition(Integer(p[2].value), p[4].value, p[7])
     else:
         return SetArrayPosition(Variable(p[2].value), p[4].value, p[7])
示例#5
0
 def expression(p):
     if p[1].gettokentype() == 'INT':
         return ArrayPosition(Integer(p[1].value), p[3].value)
     else:
         return ArrayPosition(Variable(p[1].value), p[3].value)
示例#6
0
 def integer(p):
     return Integer(p[0].value)
示例#7
0
 def expression_number(p):
     if p[0].gettokentype() == "FLOAT":
         return Float(p[0].value)
     elif p[0].gettokentype() == "INTEGER":
         return Integer(p[0].value)