Package: lib-typ-parse
lib_typ_parselib_typ_parseis the client library for manipulating and producing typon code.Usageimportlib_typ_parse.typon_clientastypon_clientserviceEndpoint='http://127.0.0.1:8081'api_key='API_KEY'target_module='drivers.cache_server_driver'module_dir='/home/user/software/cache'out_dir='/home/user/software/cache/bin'exe_name='cache_server_driver'# retrieve .cpp source from server; stores .cpp file in {out_dir}/{exe_name}.cpp# AND compiles {out_dir}/{exe_name}.cpp to {out_dir}/{exe_name}.exetypon_client.compileCpp(serviceEndpoint,target_module,module_dir,out_dir,exe_name)# retrieve .exe source from server; stores .exe file in {out_dir}/{exe_name}.exetypon_client.compileExe(serviceEndpoint,api_key,target_module,module_dir,out_dir,exe_name)Installing$python3-mpipinstalllib_typ_parseSample Code# data_format:# written to contiguous segment of disk# parameterizable disk access# [len(repr(entry_i))] [repr(entry_i)]# uses O( max(buffer_size, max(len(repr(entry_i)))) ) memory# requires final commit to be flushed to diskclassBufferedWriter():def__members__(self):file_name:strfp:fileptrbuffer_size:intbuffer:strdef__init__(self,file_name:str,buffer_size:int,append_mode:bool):self.file_name=file_nameself.buffer_size=buffer_sizefMode='wb'ifappend_mode:fMode='ab'self.fp=open(file_name,fMode)def__del__(self):self.commit()self.fp.close()defwriteItem(self,entry:str)->char:# sizeRepr = beval(len(entry), 'int', false)sizeRepr=brepr(len(entry))self.buffer+=sizeRepr+entryiflen(self.buffer)>=self.buffer_size:returnself.commit()returnchar(0)defcommit(self)->char:iflen(self.buffer)>0:self.fp.write(self.buffer)self.buffer=""returnchar(1)returnchar(0)AutoGeneratedDocslib_typ_parse.helper.__init__lib_typ_parse.helper.type_resolverdefreduce_rel_type(target_module,current_module,rel_type,reverse_imports_map)defcompute_relative_type(abs_type,current_module,reverse_imports_map)defresolve_map_type_L0_skeleton(typon_map_type,L0_skeleton)defread_tuple_types_typon_L0_skeleton(ws_removed_typon_tuple_type,L0_skeleton)defread_args_ret_from_fxn_typon_type(ws_removed_typon_fxn_type)lib_typ_parse.helper.eval_servicedefresolve_func_type_from_arguments(arguments)defresolve_args_only_func_type(arguments)defresolve_func_type_from_arguments_msa(arguments,module_L0_skeleton,current_module)defresolve_args_only_func_type_msa(arguments,module_L0_skeleton,current_module)defis_valid_var_name(var_name)lib_typ_parse.helper.eval_helperdefextract_id_var_tuple(S2)defread_fxn_params(arg_str)deffmt_type_module_space_aware_module_L0_skeleton(input_typon_type,current_module,module_L0_skeleton)lib_typ_parse.__init__lib_typ_parse.__api__lib_typ_parse.parse.__init__lib_typ_parse.parse.parserdefparse_fxn(code,index,scope)defparse_class(code,index,scope)defparse_try(code,index,scope)defparse_except(code,index,scope)defparse_L1_CE(code,index,scope,token)defparse_L0_statement(code,index,scope)defparse_import(code,index,scope)defparse_include(code,index,scope)defparse_abstract_statement(code,index,scope,start_token)defread_scope(code,index,scope)lib_typ_parse.parse.parse_L0_skeletondefassert_code_topology(current_module,item_skeleton)defassert_single_main(item_skeletons)defselect_modules_to_read(item_skeleton)defread_import_to_skeleton(item,module_L0_skeleton,current_module)defread_include_to_skeleton(item,module_L0_skeleton,current_module)defread_fxn_to_skeleton(item,module_L0_skeleton,current_module)defparseClassFxnArgsRepr(argRepr)defcheck_self_ref_mem_fxn(statement,error_msg)defread_class_members_to_skeleton(class_name,statement,module_L0_skeleton,current_module)defread_constructor_to_skeleton(class_name,statement,module_L0_skeleton,current_module)defread_destructor_to_skeleton(class_name,statement,module_L0_skeleton,current_module)defread_class_fxn_to_skeleton(class_name,statement,module_L0_skeleton,current_module)defread_class_to_skeleton(item,module_L0_skeleton,current_module)defread_instruction_to_skeleton(item,module_L0_skeleton,current_module)defread_ordered_L0_statements(item_skeleton)defformat_L0_skeleton(item_skeleton,current_module,code)defread_L0_skeleton(current_module,item_skeleton,code)deffmt_code(src_dir)defselect_code_skeletons(target_module,module_dir)lib_typ_parse.parse.parse_skeletondefselect_reverse_imports_map(skeleton)defmap_rel_type(abs_type,module_name,reverse_imports_map)defcondense_fxn(fxn_def,module_name,reverse_imports_map)defcondense_class(class_def,module_name,reverse_imports_map)defread_absolute_skeleton(target_module,module_dir)defread_relative_skeleton(target_module,module_dir)defp1()defmain()lib_typ_parse.typon_clientdefcompileCpp(serviceEndpoint,api_key,target_module,module_dir,out_dir,exe_name,printProg=True)defcompileExe(serviceEndpoint,api_key,target_module,module_dir,out_dir,exe_name,printProg=True)lib_typ_parse.utils.__init__lib_typ_parse.utils.constantsdefselect_item_prefix(item_name)defselect_primitives()defselect_bracket_map()lib_typ_parse.utils.exceptionsdeffind_all(s,t,index)defraise_exception_msg(code,index,error_msg)defraise_exception_msgs(code,index,error_msgs)defraise_exception_raw(error_msgs)defraise_exception_ue(error_msgs)defraise_exception_ue_cm(error_msgs,current_module)defraise_exception_ST(symbol_table,errors)defformat_parse_tree(abstract_tree)defraise_inv_exception_decl(exception_decl,symbol_table)defraise_invalid_raise_exception(symbol_table)defraise_class_not_found_exception(symbol_table,class_name,target_module)defraise_inv_assertion_declaration(symbol_table,interior_assert_typon_type)defraise_exception_L0_skeleton(errors,current_module,L0_skeleton)defraise_parsing_exception(error_msg_str,current_module,src_dir)lib_typ_parse.utils.fmt_utilsdefformat_indent(indent_str,multiline_str)defserialize_json(py_dict)defprint_json(py_dict)defselect_module_src_dir(module_dir,target_module)defread_module_src(module_dir,target_module)lib_typ_parse.utils.parsing_utilsdefindent_multiline_str(indent_str,multiline_str)defget_fmt_str_expr_closure(target_substr,open_index,symbol_table)defget_char_closure(s,index)defget_unescaped_quote(s,index,quote)defclose_triple_quote(s,index,trq)defget_quote_closure(s,index)defis_escaped_quote(s,index)defget_cleared_char_closure(s,index)defread_next_cleared_char(s,index,target_char)defparse_current_scope(source_code,scope_start_index)defread_init_token(source_code,index,scope)defselect_token_index(tok_stream,target_token)defget_token_stream_closure(tok_stream,i_start)defget_expr_aware_closure(tok_stream,index,symbol_table)deffind_all_expr_aware(tok_stream,index,symbol_table,target_token)defsplit_expr_aware(tok_stream,symbol_table,target_token)defsplit_arg_typle(s,index)defread_delimited_types(type_str)defparse_fxn_type(function_type,symbol_table)lib_typ_parse.utils.transform_data