def emitREOP(self, op, in_, frame): #op: String #in_: Type #frame: Frame #..., value1, value2 -> ..., result result = list() labelF = frame.getNewLabel() labelO = frame.getNewLabel() frame.pop() frame.pop() if op == ">": result.append(self.jvm.emitIFICMPLE(labelF)) elif op == ">=": result.append(self.jvm.emitIFICMPLT(labelF)) elif op == "<": result.append(self.jvm.emitIFICMPGE(labelF)) elif op == "<=": result.append(self.jvm.emitIFICMPGT(labelF)) elif op == "!=": result.append(self.jvm.emitIFICMPEQ(labelF)) elif op == "==": result.append(self.jvm.emitIFICMPNE(labelF)) result.append(self.emitPUSHCONST("1", cgen.IntType(), frame)) frame.pop() result.append(self.emitGOTO(labelO, frame)) result.append(self.emitLABEL(labelF, frame)) result.append(self.emitPUSHCONST("0", cgen.IntType(), frame)) result.append(self.emitLABEL(labelO, frame)) return ''.join(result)
def buildCM(): """ Write code, then build the CrackMe via shell script. """ CodeGenerator.writeCode() os.chdir(projectPath) # + '/CrackGenCM.xcodeproj' # os.system("xcodebuild build -quiet -project " + projectPath + '/CrackGenCM.xcodeproj') os.system("xcodebuild -quiet -target " + "CrackGenCM") CodeGenerator.clearCode()
def compile(self, doc): res = "" lines = doc.split("\n") result = None parsing = True msg = None new_comma = [] try: result = self.parser.parse(doc, debug=self.log) if not self.DEBUG: try: codeGenerator = CodeGenerator() response = result.generateCode(codeGenerator) res += response except: res += "Error while generating MathProg code. Please, check your Latex code!" else: if self.DEBUG: res += str(result) codeGenerator = CodeGenerator() response = result.generateCode(codeGenerator) res += response except SyntaxException as msg: if msg[0] == "EOF": res += "Syntax error at EOF." else: lineNum = msg[0] - 1 line = lines[lineNum] totalCharLinesAbove = 0 lineNum -= 1 while lineNum >= 0: totalCharLinesAbove += len(lines[lineNum]) + 1 lineNum -= 1 # If a COMMA was inserted after an Identifier (see above), # then the real position of the character that caused the error must be discounted by this COMMA # (the original document has not this automatically inserted COMMA) pos_aux = msg[1] pos = pos_aux - totalCharLinesAbove if totalCharLinesAbove > 0: pos += 1 res += "Syntax error at line %d, position %d: '%s'.\nContext: %s." % ( msg[0], pos, msg[2], line) return res
def p_var_assign(p): ''' var_assign : NAME EQUALS color | NAME EQUALS rgb | NAME EQUALS miliseconds | NAME EQUALS animation | NAME EQUALS button_pos ''' p[0] = ('=', p[1], p[3]) generate.createVariable(p[0])
def __init__(self, source_dir, data_checker_path): self.clear_temp_folder() self.source_dir = source_dir self.data_checker_path = data_checker_path self.files = [] self.csheets = [] self.code_generator = CodeGenerator(FLAGS.namespace) self.data_generator = DataGenerator(self.code_generator, FLAGS.out_data_file) self.data_checkers = []
def translate(s): try: PupetScript = open(s, 'r') except IOError: print("Error opening File") exit() fileScript = PupetScript.read() parser = yacc.yacc() res = parser.parse(fileScript) gen.upload()
def emitNOT(self, in_, frame): #in_: Type #frame: Frame label1 = frame.getNewLabel() label2 = frame.getNewLabel() result = list() result.append(self.emitIFTRUE(label1, frame)) result.append(self.emitPUSHCONST("1", cgen.IntType(), frame)) result.append(self.emitGOTO(label2, frame)) result.append(self.emitLABEL(label1, frame)) result.append(self.emitPUSHCONST("0", cgen.IntType(), frame)) result.append(self.emitLABEL(label2, frame)) return ''.join(result)
def getJVMType(self, inType): typeIn = type(inType) if typeIn is cgen.IntType: return "I" elif typeIn is cgen.FloatType: return "F" elif typeIn is cgen.StringType: return "Ljava/lang/String;" elif typeIn is cgen.BoolType: return "Z" elif typeIn is cgen.VoidType: return "V" elif typeIn is cgen.ArrayType: if len(inType.dimen) > 1: inType = cgen.ArrayType(inType.eleType, inType.dimen[1:]) # return "[" + self.getJVMType(inType.eleType) return "[" + self.getJVMType(inType) else: return "[" + self.getJVMType(inType.eleType) elif typeIn is cgen.MType: return "(" + "".join( list(map(lambda x: self.getJVMType(x), inType.partype))) + ")" + self.getJVMType( inType.rettype) elif typeIn is cgen.ClassType: return "L" + inType.cname + ";" else: assert 2 == 1
def emitINITARRAY(self, in_, typ, frame, cop=None): # in_: int or string # typ: type # frame: Frame buffer = list() size1 = typ.upper - typ.lower + 1 eleType = typ.eleType buffer.append(self.emitPUSHICONST(size1, frame)) if type(eleType) in [ cgen.ArrayPointerType, cgen.ClassType, StringType, ArrayType ]: buffer.append(self.jvm.emitANEWARRAY(self.getFullType(eleType))) else: buffer.append(self.jvm.emitNEWARRAY(self.getFullType(eleType))) if cop == True: return ''.join(buffer) if type(in_) is str: buffer.append( self.jvm.emitPUTSTATIC( in_, self.getJVMType(cgen.ArrayPointerType(typ.eleType)))) frame.pop() else: buffer.append(self.jvm.emitASTORE(in_)) frame.pop() return ''.join(buffer)
def p_chraracter_controller_script(p): 'CharacterController : CHARACTERCONTROLLER SpeedId GravityId Movement Action' x = p[4] if x[0] == 'NONE' or x[2] == 'NONE' or x[1] != 'NONE': print("Only the y axis must be of NONE value, This is due to gravity affecting the Character Controller Object") p_error(p) f = [p[1]] f.extend([p[2], p[3], p[4], p[5]]) p[0] = f print(f) gen.set_scripttype('CHARACTERCONTROLLER') gen.initial_char_cont(p[2], p[3]) gen.move(x[0], x[1], x[2]) gen.set_Action(p[5]) gen.end_char_cont() print(noneList)
def formal_reduce(self, args): # print("formal reduce....") # print(args) # flag for start of function declaration self.func_start = True if self.main_code_gen.is_in_class: to = Token("IDENT", "this") t = Tree("variable", [self.main_code_gen.class_name, to]) args = [t] + args # args.append(t) # set variables above the frame last_offset = 0 last_size = 0 for var in args: if isinstance(var, Tree): variable = CodeGenerator.Variable() variable.name = var.children[1].value variable.type = var.children[0] variable.calc_size() new_offset = last_offset - variable.size new_offset = -new_offset variable.address_offset = ( -new_offset if new_offset % variable.size == 0 else -1 * (new_offset + (variable.size - new_offset % variable.size))) last_offset = variable.address_offset last_size = variable.size self.current_function_signiture.append(variable) return args
def emitCloneArray(self, addressIndex, eleType, frame): result = [] result.append(self.emitREADVAR("", cgen.ArrayPointerType(eleType), addressIndex, frame)) result.append(JasminCode.INDENT + "invokevirtual " + "[" + self.getJVMType(eleType) + "/clone()Ljava/lang/Object;" + JasminCode.END) result.append(JasminCode.INDENT + "checkcast [" + self.getJVMType(eleType) + JasminCode.END) result.append(self.jvm.emitASTORE(addressIndex)) frame.pop() return ''.join(result)
def emitCLONE(self, in_, frame): result = list() result.append( self.emitINVOKEVIRTUAL( self.getJVMType(in_) + '/clone', MType(list(), cgen.ClassType('java/lang/Object')), frame)) result.append('\tcheckcast ' + self.getJVMType(in_) + '\n') return ''.join(result)
def emitFREOP(self, op, in_, frame): """ emit relation expression for float type Args: op ([type]): [description] in_ ([type]): [description] frame ([type]): [description] """ result = list() labelF = frame.getNewLabel() labelO = frame.getNewLabel() frame.pop() frame.pop() if op == ">.": result.append(self.jvm.emitFCMPL()) result.append(self.emitPUSHICONST(0, frame)) result.append(self.jvm.emitIFICMPLE(labelF)) elif op == ">=.": # true if 0 and 1, false is -1 result.append(self.jvm.emitFCMPL()) result.append(self.emitPUSHICONST(0, frame)) result.append(self.jvm.emitIFICMPLT(labelF)) elif op == "<.": # true if -1, false if 0 and 1 result.append(self.jvm.emitFCMPL()) result.append(self.emitPUSHICONST(0, frame)) result.append(self.jvm.emitIFICMPGE(labelF)) elif op == "<=.": # true if -1, 0, false if 1 result.append(self.jvm.emitFCMPL()) result.append(self.emitPUSHICONST(0, frame)) result.append(self.jvm.emitIFICMPGT(labelF)) elif op == "=/=": # true if 0, false if -1 and 1 result.append(self.jvm.emitFCMPL()) result.append(self.emitPUSHICONST(0, frame)) result.append(self.jvm.emitIFICMPEQ(labelF)) result.append(self.emitPUSHCONST("1", cgen.IntType(), frame)) frame.pop() result.append(self.emitGOTO(labelO, frame)) result.append(self.emitLABEL(labelF, frame)) result.append(self.emitPUSHCONST("0", cgen.IntType(), frame)) result.append(self.emitLABEL(labelO, frame)) return ''.join(result)
def p_simple_script(p): 'Simple : SIMPLE SpeedId Movement' p[0] = (p[1], p[2], p[3] ) x =p[3] #if len(noneList) != 1: # print("Only one of the axis values must be NONE") gen.set_scripttype('SIMPLE') gen.initial_simple(p[2]) gen.move(x[0], x[1], x[2]) gen.end_simple()
def emitInitNewStaticArray(self, name, size, eleType, frame): result = [] result.append(self.emitPUSHICONST(size, frame)) frame.pop() if type(eleType) is StringType: result.append(self.jvm.emitANEWARRAY(self.getFullType(eleType))) else: result.append(self.jvm.emitNEWARRAY(self.getFullType(eleType))) result.append(self.jvm.emitPUTSTATIC(name, self.getJVMType(cgen.ArrayPointerType(eleType)))) return ''.join(result)
def compileAll( branches = [], treename = 'tau', inputpath = '', outputdump = False, removeunselected = False, cutflows = [], toolset = 'LepHad2011', ): global compiledir compiledir = 'libs/' + toolset from ROOT import gSystem gSystem.SetAclicMode(gSystem.kOpt) gSystem.AddIncludePath('-I' + filedir + '/../External/TauSpinner/extern/include') gSystem.AddIncludePath('-I' + filedir + '/../External/TauSpinner/extern/include/Tauola') compileC(filedir+"/Loader.C") compileC(filedir+"/CutFlowHist.C") print "@@@@@ Setting up the branches, kernel, whiteboard and external tools..." if type(branches) is str: branches = [branches] b = [] for branch in branches: if not hasattr(__import__('Branches.'+branch), branch): raise Exception("Can't find Branches: " + branch) b.append(getattr(__import__('Branches.'+branch), branch)) import CodeGenerator, NTupleTools if not CodeGenerator.setupBranches(b, treename, inputpath, outputdump): raise Exception("Setup branches failed!") compileC(filedir+"/WhiteBoard.C") compileC(filedir+"/CutFlow_Base.C") CodeGenerator.setupForkItem(removeunselected, outputdump) import External External.initialiseAllTools(toolset) import CutFlows CutFlows.load(cutflows) compileC(filedir+"/PostLoader.C")
def p_program(p): '''program : statements''' p[0] = ProgramNode(children=[p[1]]) ast_string = "AST TREE" sym_string = "SYMTABLE" if args["verbose"]: print("\n\n" + ast_string.center(shutil.get_terminal_size().columns) + "\n\n") print_tree(p[0].tree) semantic_checker = SemanticAnalyzer() semantic_checker.analysis(p[0]) if args["verbose"]: print("\n\n" + sym_string.center(shutil.get_terminal_size().columns) + "\n\n") semantic_checker.print_symtab() semantic_checker.invalid_redeclaration() if len(semantic_checker.error) > 0: semantic_checker.print_error() print("Translation failed: your code contains error.", file=sys.stderr) else: try: f = open("output/output.java", "w") except FileNotFoundError: os.mkdir("output") finally: f = open("output/output.java", "w") code_generator = CodeGenerator(semantic_checker.get_symtab()) code_generator.generate(p[0], f) f.close() code_generator.post() print("Translation completed correctly.") if not args["verbose"]: print("You can print the symtable and the Abstract Syntax Tree by running the same command with --verbose.") p[0] = None
def create_object(self, args): # print("create obj:") # print(args) if self.main_code_gen.first_pass: return CodeGenerator.Register("int", "t", 0) cls_name = args[0].value clss = self.classes[cls_name] t1 = self.main_code_gen.get_a_free_t_register() code = """ # create object for {} li $v0, 9; li $a0, {}; syscall # move address to t1 move $t{}, $v0; """.format(cls_name, clss.get_full_size(), t1) self.main_code_gen.t_registers[t1] = True reg = CodeGenerator.Register(cls_name, "t", t1) reg.is_reference = True reg.code = code return reg
def arr_length(self, arr): print("arr.length()", arr) t1 = self.main_code_gen.get_a_free_t_register() self.main_code_gen.t_registers[t1] = True code = """ li $t{}, {}; add $t{}, $t{}, $s{}; lw $t{}, ($t{}); lw $t{}, ($t{}); """.format( t1, arr.address_offset, t1, t1, 1 if arr.is_global else 0, t1, t1, t1, t1 ) reg = CodeGenerator.Register("int", "t", t1) reg.write_code(code) return reg
def generate(): confDict = config.parse("./conf.ini") parser = xml.sax.make_parser() parser.setFeature(xml.sax.handler.feature_namespaces, 0) generator = CodeGenerator.CodeGenerator(confDict["xml_path"], confDict["java_code"], confDict["java_package"]) for xmlFile in confDict["xml_files"]: xmlHandler = XmlHandler() parser.setContentHandler(xmlHandler) parser.parse(os.path.join(confDict["xml_path"], xmlFile)) dataTypes = xmlHandler.getDataTypes() if dataTypes: xmlFileName = os.path.splitext(xmlFile)[0] generator.generateEntityFile(xmlFileName, dataTypes) generator.generateConfigFile(xmlFileName) generator.generateParserFile(xmlFileName)
def getJVMType(self, inType): typeIn = type(inType) if typeIn is IntType: return "I" elif typeIn is FloatType: return "F" elif typeIn is StringType: return "Ljava/lang/String;" elif typeIn is BoolType: return "Z" elif typeIn is VoidType: return "V" elif typeIn is ArrayPointerType: return "[" + self.getJVMType(inType.eleType) elif typeIn is ArrayType: return self.getJVMType(cgen.ArrayPointerType(inType.eleType)) elif typeIn is MType: return "(" + "".join(list(map(lambda x: self.getJVMType(x), inType.partype))) + ")" + self.getJVMType(inType.rettype) elif typeIn is cgen.ClassType: return "L" + inType.cname + ";"
def p_command(p): ''' command : ANIMATE animation color miliseconds | ANIMATE animation rgb miliseconds | START | END ''' if p[1] == 'START': if os.path.isfile("arduinoCode.ino"): os.remove("arduinoCode.ino") elif p[1] == 'END': generate.upload() generate.terminalUpload() else: p[0] = (p[1], p[2], p[3], p[4]) generate.animate(p[0])
def emitINITNEWARRAY(self, name, frame, varType, varSize=None, varKind="global"): result = [] result.append(self.emitPUSHICONST(varSize, frame)) frame.pop() if type(varType) is StringType: result.append(self.jvm.emitANEWARRAY(self.getFullType(varType))) else: result.append(self.jvm.emitNEWARRAY(self.getFullType(varType))) if varKind == "local": # name = var index result.append(self.jvm.emitASTORE(name)) else: # name = MCClass.variable result.append( self.jvm.emitPUTSTATIC( name, self.getJVMType(cgen.ArrayPointerType(varType)))) return ''.join(result)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Dec 25 23:19:43 2014 @author: phil, mark """ import sys import GrammarParser import CodeGenerator if len(sys.argv) != 5: print("Usage: {executable} <path_to_file> <output_parser> <output_interfaces> <output_implementations>\n".format(executable=sys.argv[0])) else: GRAMMAR_FILE = open(sys.argv[1], 'r') OUTPUT_PARSER = sys.argv[2] OUTPUT_INTERFACES = sys.argv[3] OUTPUT_IMPLEMENTATIONS = sys.argv[4] INPUT_STRING = GRAMMAR_FILE.read() parse_table = GrammarParser.parse_parse_table(INPUT_STRING) if __debug__: print("{{\n{}\n}}".format( ",\n".join([repr(x) for x in parse_table]))) result = CodeGenerator.generate(parse_table, parser=OUTPUT_PARSER, interfaces=OUTPUT_INTERFACES, implementations=OUTPUT_IMPLEMENTATIONS) if result: print("Success") else: print("Success, probably")
def getConst(self, ast): #ast: Literal if type(ast) is IntLiteral: return (str(ast.value), cgen.IntType())
argp.add_argument("-b", help="Begin offset", default=0, dest="begin_off") argp.add_argument("-e", help="End offset", default=0, dest="end_off") argp.add_argument("-use-flags", help="Select flags to use", default='czao', dest="flags_used") args = vars(argp.parse_args()) filename = args['src_name'] flagsUsed = [x for x in args['flags_used']] begin, end = (int(args['begin_off'], 16), int(args['end_off'], 16) ) if filename == None: argp.print_help() exit(0) cg = CodeGenerator(filename, begin, end, flagsUsed) cCode = cg.getAsC() out = open('out.c', 'wb') out.write(bytes(cCode, encoding='ascii')) out.close() print('==== translated... ====') print(cCode) #system("gcc out.c -o out")
import CodeGenerator from Grammar import Grammar file = open("output/Grammar.txt", 'r') data = file.read().replace(' ', '').replace('\t', '').replace('\n', ';') file.close() grammar = Grammar(data) file = open('output/Output.py', 'w') file.write(CodeGenerator.gen_basic()) for rule in grammar.get_rules(): file.write(CodeGenerator.gen_rule(rule)) file.write(CodeGenerator.gen_main()) file.close()
class TableConverter: def __init__(self, source_dir, data_checker_path): self.clear_temp_folder() self.source_dir = source_dir self.data_checker_path = data_checker_path self.files = [] self.csheets = [] self.code_generator = CodeGenerator(FLAGS.namespace) self.data_generator = DataGenerator(self.code_generator, FLAGS.out_data_file) self.data_checkers = [] def convert(self): self.collect_data_checkers() self.collect_files() self.calculate_dependences() self.shorting_with_dependence() try: for csheet in self.csheets: print('处理表单:{}'.format(csheet.sheet.name)) # print info # ***************************** 标记当前位置 *******************************# ProgressInfo().sheet = csheet.sheet.name ProgressInfo().fileName = csheet.file_name # ***************************** 标记当前位置 *******************************# is_success = self.code_generator.generate_sheet_code( csheet.sheet) if is_success == False: return False data_checker = self.get_data_checker(csheet.sheet.name) is_success = self.data_generator.generate_sheet_data( csheet.sheet, data_checker) if is_success == False: return False except Exception as e: print(ProgressInfo()) print("*错误信息* -->", end=' ') print(e) return False self.code_generator.generate_manager_code() self.data_generator.finish() self.code_generator.finish() return True def clear_temp_folder(self): temp_folders = [TEMP_CODE_FOLDER_NAME, TEMP_DATA_FOLDER_NAME] for i in range(len(temp_folders)): temp_folder = temp_folders[i] try: shutil.rmtree(temp_folder) except: pass def copy_to_dest(self): pass def collect_data_checkers(self): print('收集错误检查脚本') # print info loader = DataCheckLoader() self.data_checkers = loader.load(self.data_checker_path) def get_data_checker(self, name): for key, value in self.data_checkers.items(): if key == name: return value return None def collect_files(self): print('收集Excel文件') # print info # collect excel files for parent, dirnames, filenames in os.walk(self.source_dir): for filename in filenames: if filename.endswith( ".xlsx") and not filename.startswith("~$"): filepath = os.path.join(parent, filename) self.files.append(filepath) # collect sheets sheetNames = [] for fileName in self.files: filename = os.path.splitext(os.path.basename(fileName))[0] csheets = [] workbook = xlrd.open_workbook(fileName) sheets = workbook.sheets() for sheet in sheets: if not sheet.name.startswith(SHEET): if sheet.name not in sheetNames: sheetNames.append(sheet.name) csheet = CSheet(sheet, filename) csheets.append(csheet) self.csheets.append(csheet) else: raise Exception(r"两个表单名字相同: " + sheet.name) def calculate_dependences(self): print('检查Excel表单项的依赖关系') # print info for csheet in self.csheets: row_values = csheet.sheet.row_values(1) for item in row_values: if item.upper().startswith(DES): continue attribute_type, attribute_name, reference_name = Utils.get_attribute_info( item) if attribute_name == None or attribute_type == None: raise Exception("'{}' 无效的表单名字 '{}'".format( csheet.sheet.name, item)) if (attribute_type == ENUM or attribute_type == LIST_ENUM) and attribute_name.upper() != ID: if reference_name == None: raise Exception("'{0}' 表单项 '{1}' 没有引用".format( csheet.name, item)) dependence_csheet = self.get_csheet_with_name( reference_name) if dependence_csheet == None: raise Exception("'{0}' '{1}' 没有找到目标类".format( csheet.sheet.name, item)) csheet.add_dependence(dependence_csheet) def shorting_with_dependence(self): self.csheets = sorted(self.csheets, key=lambda x: len(x.dependences)) # TODO isHaveMove = True roundNum = 0 while isHaveMove: isHaveMove = False for i in range(0, len(self.csheets)): csheet = self.csheets[i] csheets_tomove = [] for dependence in csheet.dependences: dependence_index = self.csheets.index(dependence) if dependence_index > i: csheets_tomove.append(dependence) if len(csheets_tomove) > 0: for csheet in csheets_tomove: index = csheets_tomove.index(csheet) self.csheets.remove(csheet) self.csheets.insert(i, csheet) isHaveMove = True roundNum += 1 if roundNum > len(self.csheets): raise Exception("存在循环引用") def get_csheet_with_name(self, name): for csheet in self.csheets: if (csheet.sheet.name.upper() == name.upper()): return csheet return None
#!/usr/bin/python from CodeGenerator import * from Condition import * config = ConfigParser.ConfigParser() config.readfp(open("stm32f103vct6.cfg")) gen = CodeGenerator(config) gen.appendCondtion( Condition.logicAnd(config.get("elements", "y1"), config.get("elements", "y2")), config.get("elements", "y1_type_set"), ) gen.appendCondtion(Condition.logicNot(config.get("elements", "y1")), config.get("elements", "y1_type_set")) print gen.getCode()
def access_to_array(self, args): print("access to array", args) # self.type_checking_for_arr_access(args) arr_name = args[0] t1 = self.main_code_gen.get_a_free_t_register() self.main_code_gen.t_registers[t1] = True index = self.main_code_gen.get_a_free_t_register() code = self.main_code_gen.append_code( args[1].code, self.main_code_gen.code_for_loading_opr(index, args[1]) ) # code = index.code if isinstance(arr_name, Token): # arr = self.main_code_gen.symbol_table.variables[arr_name.value] arr = self.main_code_gen.token_to_var([arr_name]) code = self.main_code_gen.append_code( code, """ li $t{}, {}; add $t{}, $t{}, $s{} lw $t{}, ($t{}); # calc index addi $t{}, $t{}, 1 mul $t{}, $t{}, {} mflo $t{}; add $t{}, $t{}, $t{}; """.format( t1, arr.address_offset, t1, t1, 1 if arr.is_global else 0, t1, t1, index, index, index, index, self.calc_size_of_index(arr.type), index, t1, t1, index, ), ) output_type = self.get_output_type(arr.type) # int[][] -> int[] reg = CodeGenerator.Register(output_type, "t", t1) reg.is_reference = True reg.write_code(code) return reg elif isinstance(arr_name, CodeGenerator.Register): # x[2][3] reg = arr_name code = self.main_code_gen.append_code( reg.code, """ lw $t{}, ($t{}); # calc index addi $t{}, $t{}, 1 mul $t{}, $t{}, {} mflo $t{}; addi $t{}, $t{}, $t{}; """.format( t1, reg.number, index, index, index, index, self.calc_size_of_index(reg.type), index, t1, t1, index, ), ) output_type = self.get_output_type(reg.type) # int[][] -> int[] reg = CodeGenerator.Register(output_type, "t", t1) reg.is_reference = True reg.write_code(code) return reg
def p_rigid_script(p): 'RigidBody : RIGIDBODY SpeedId Movement ForceMode Action' x = p[3] if x[0] == 'NONE' or x[2] == 'NONE' or x[1] != 'NONE': print("Only the y axis must be of NONE value, This is due to gravity affecting the Rigid Body Object") p_error(p) f = [p[1]] f.extend( [ p[2], p[3], p[4], p[5] ] ) print (f) p[0] = [f] gen.set_scripttype('RIGIDBODY') gen.initial_rigid_body(p[2]) gen.move(x[0], x[1], x[2]) gen.addForce(p[4]) gen.set_Action(p[5]) gen.end_rigidbody()