Package: typon-client
Typon ClientTypon Clientis the client library for producing typon code.importlib_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)This client intends to support modular software development in the typon language. E.g.# in {module_dir}python3-m{target_module}Except only executable software is generated, not executed.Installing Typon Client and Supported VersionsTypon Client is available on PyPI:$python3-mpipinstalltypon_clientTypon Client officially supports Python 3.7+.Typon LanguageTypon is a statically typed language (derived from c++) with an efficient grammar resembling Python3.
This language seeks to capture the performance benefits of c++ while maintaining python level simplicity.
We list the basic grammatical constructs below; then we provide some sample code to fill in the blanks.
Typing is optional when the right-hand side is type resolvable.
Scope (e.g.) brackets are determined by indentation level, like in python.# type listprimitives=int,int32,uint32,uint64,dbl,char,str,bool,fileptr# vectorvarName:vec[item_type]=[v_1,...,v_n]# hash mapvarName:hmap[key_type,val_type]={k_1:v_1,...,k_n:v_n}# sorted mapvarName:smap[key_type,val_type]=s{k_1:v_1,...,k_n:v_n}# tuplevarName:tupl[type_1,...,type_n]=t[v_1,...,v_n]# typed statement[varName]:[varType]=[varValue]# non-typed statement[varName]=[varValue]# control flowif[condition]:[statement]else:[statement]for[varName]in[vector]:[loopBody]while[condition]:[loopBody]# function definitionfxn[fxnName](arg_1:[type_1],...,arg_n:[type_n])->[ret_type]:[fxn_body]# class definition, no inheritanceclass[className]():# constructorfxn__init__(args):[constructorBody]# destructorfxn__deinit__():[destructorBody]# imports grammarinclude[c_pkg_name]import[subpkg].[module_name]as[module_alias]Typon SampleSample Typon Code to demonstrate features. Note that custom class instances must be deleted upon use.includeds_utilsimportcore.search_indexassearch_indeximportutils.eval_utilsaseval_utilsimportutils.eval_utils2aseval_utils2importutils.eval_structsaseval_structsimportutils.search_utilsassearch_utilsimportparsing.condition_parsingascondition_parsing# resolution of attr_name type:# on parse attr_name: check [table_obj.doc_attrs.attr_type_map]# recall:# [table_obj.doc_attrs.attr_type_map]: ( attr_id ) => ( attr_type in [ int, dbl, str ] )# [ int, dbl, str ] ~ [ char(0), char(1), char(2) ]classsearch_condition():fxn__members__():table_obj:search_index.search_tableeval_tree:eval_structs.evaluation_treevalid:boolfxn__init__(table_obj:search_index.search_table,attr_cond_query:str,attr_cond_int_values:vec[int],attr_cond_dbl_values:vec[dbl],attr_cond_str_values:vec[str]):this.table_obj=table_objtok_stream=condition_parsing.tokenize_query_text(attr_cond_query,table_obj.condl_consts.delim_chars)eval_tree,parse_success=eval_utils2.compute_eval_tree(tok_stream,0,len(tok_stream),this,attr_cond_int_values,attr_cond_dbl_values,attr_cond_str_values)this.eval_tree=eval_treethis.valid=trueifnotparse_success:this.valid=falsefxn__deinit__():deletethis.eval_treefxnmatches_doc(doc_id:int)->bool:ifnotthis.valid:returnfalseeval_type=this.eval_tree.evaluate(doc_id,this)this.eval_tree.value_type=eval_type# case: undefinedifeval_type==char(4):returnfalse# case: boolifeval_type==char(3):returnthis.eval_tree.val_bool# case: strifeval_type==char(2):returnlen(this.eval_tree.val_str)>0# case: dblifeval_type==char(1):returnthis.eval_tree.val_dbl!=0.0# case: intreturnthis.eval_tree.val_int!=0