diff --git a/src/swi_analyse_metta/divide_code.pl b/src/swi_analyse_metta/divide_code.pl new file mode 100644 index 00000000000..f4b4d7598d5 --- /dev/null +++ b/src/swi_analyse_metta/divide_code.pl @@ -0,0 +1,194 @@ + +% :- encoding(utf8). +:- encoding( octet ). + +warning_bad_comment( Base, Lx ):- sub_string( Lx, _,_,_, "/*" ), !, + write("Bad comment /* in file "), write( Base ), + write(" Please clean the file first "), nl . + +warning_bad_comment( _, _Lx ):- !. + +% :- use_module(library(dcg/basics)). +is_blank_line( Lastline ):- string_length( Lastline , Le ), Le < 2, ! . + +% ADD just that it divides with a blank line only +% in this way its regular + +add_to_file_part( Base, Lx ):- file_part_string( Num, Base, Bstr , _Lastline ), + string_length( Bstr, Le ), Le < 2900, + string_concat( Bstr , "\n", C1 ), string_concat( C1, Lx, C2 ), + retract( file_part_string( Num, Base, _ , _ ) ), !, +% write( Base ), write( Num ), nl, + asserta( file_part_string( Num, Base, C2 , Lx ) ). + +add_to_file_part( Base, Lx ):- + file_part_string( Num, Base, _, _Lastline ), !, + Num2 is Num + 1, +% write( Base ), write( Num2 ), nl, + asserta( file_part_string( Num2, Base, Lx , Lx ) ). + +add_to_file_part( Base, Lx ):- !, +% write( Base ), write( 1 ), nl, + asserta( file_part_string( 1, Base, Lx , Lx ) ). + + + +%add_to_file_part( Base, Lx ):- file_part_string( Num, Base, Bstr , _Lastline ), +% string_concat( Bstr , "\n", C1 ), string_concat( C1, Lx, C2 ), +% retract( file_part_string( Num, Base, _ , _ ) ), !, +% write( Base ), write( Num ), nl, +% Num2 is Num + 1, +% asserta( file_part_string( Num2, Base, C2 , Lx ) ). + + + +read_file_stream_to_memory( Sea, Base, Linum ):- not( at_end_of_stream( Sea ) ), + read_line_to_string( Sea, Lx ), Lx \= end_of_file, !, +% warning_bad_comment( Base, Lx ), + add_to_file_part( Base, Lx ), + Linum2 is Linum + 1, + read_file_stream_to_memory( Sea, Base, Linum2 ). + +%read_file_stream_to_memory( Sea, Base, Linum ):- not( at_end_of_stream( Sea ) ), !, +% Linum2 is Linum + 1, read_has_search_stream_to_memory( Sea, Base, Linum2 ). +read_file_stream_to_memory( _ , _, _ ):- !. + +% To be able to post them in ChatGPT + +% for testing metta_eval with 1 file, is not in my task list ChatGPT + +file_to_divide( '../canary_to_post/metta_eval.pl' ). + +%file_to_divide( '../canary_to_post/metta_convert.pl' ). +%file_to_divide( '../canary_to_post/metta_ontology.pfc.pl' ). +%file_to_divide( '../canary_to_post/metta_pfc_base.pl' ). +%file_to_divide( '../canary_to_post/metta_printer.pl' ). +%file_to_divide( '../canary_to_post/metta_space.pl' ). +%file_to_divide( '../canary_to_post/metta_utils.pl' ). + +%file_to_divide( '../canary_to_post/das_classic_loader.pl' ). +%file_to_divide( '../canary_to_post/chado_xml_loader.pl' ). +%file_to_divide( '../canary_to_post/flybase_convert.pl' ). + + + +% THIS file Doesnt Exist +% file_to_divide( '../../library/genome/ext_loader_json.pl' ). + +write_string_to_file( Fn, Str ):- tell( Fn ), write( Str ),!, told(). +write_string_to_file( _, _ ):- !. + + +ato_num2( Ato, Ato2 ):- atom_length( Ato, Le ), Le == 1, atom_concat( '0', Ato, Ato2 ), !. +ato_num2( Ato, Ato ):- !. + + +divide_file( Fn ):- + file_base_name( Fn , Base ), file_name_extension( Base2 , _Ext, Base ), + open( Fn, read, Sea , [ encoding( octet ) ] ), + read_file_stream_to_memory( Sea, Base2, 1 ), + close( Sea ). + +memory_to_divided_files():- + file_part_string( Num2, Base, Lx , _ ), + atom_number( Ato, Num2 ), ato_num2( Ato, Ato2 ), + atomic_list_concat( [ 'divided/', Base, '_', Ato2 , '.pld' ], Fnabs ), + write_string_to_file( Fnabs , Lx ), fail , ! . + +memory_to_divided_files():- !. + + +:- dynamic file_part_string/4. + +% divide_prolog_source_files(). + +divide_prolog_source_files():- + retractall( file_part_string( _, _, _ , _) ), + file_to_divide( Fn ), write( Fn ), nl, divide_file( Fn ), fail, !. +divide_prolog_source_files():- memory_to_divided_files(), !. +divide_prolog_source_files():- !. + +:- dynamic tmp_atom/1. + +file_list_divided_gpt( Base , Lis ):- retractall( tmp_atom( _ ) ), + directory_files( 'divided_gpt' , Lis ), member( El, Lis ), El \= '..', El \= '.', + sub_atom( El, _, _ , _ , Base ), + sub_atom( El, _, _ , _ , '_gpt' ), + assert( tmp_atom( El ) ), fail. + +file_list_divided_gpt( _Base , Fnl2 ):- findall( Fn, tmp_atom( Fn ) , Fnl ), + sort( Fnl, Fnl2 ). + + +%--- +assemble_files( Fnq, Lis ):- length( Lis , Le ), Le > 0, + tell( Fnq ), + member( El, Lis ), + file_name_extension( Elbase , _, El ), + atomic_list_concat( [ 'divided_gpt/', Elbase, '.pl' ] , Fnz ), +% write( " read file " ), write( Fnz ), nl, + read_file_to_string( Fnz, Bstr, [] ), + write( Bstr ), nl , + fail, !. +assemble_files( _ , _Lis ):- told(), !. + +%---- +assemble_prolog_source_files():- + write( "start" ), nl, + file_to_divide( Fn ), + write( Fn ), nl , + file_base_name( Fn , Base ), file_name_extension( Base2 , _Ext, Base ), + write( Base2 ), nl , + file_list_divided_gpt( Base2, Lis ) , + write_term( Lis, [] ), nl, + write( " assembling " ), write( Base2 ), nl, + atomic_list_concat( ['catted/', Base2, '.pl' ] , Fnq ), + assemble_files( Fnq, Lis ) , + fail , !. + +assemble_prolog_source_files():- !. +assemble_prolog_source_files():- !. + + +% read_string(+Stream, ?Length, -String) + + +read_clauses_stream_to_memory( Sea , Fn ):- + not( at_end_of_stream( Sea ) ), + catch( read_term( Sea, Terx, [ term_position( Pos ) ] ), _, fail ), !, + stream_position_data( byte_count, Pos, ChaCoufpos ), + stream_property( Sea, position( Kpos ) ), stream_position_data( byte_count, Kpos, ChaCountEnd ), + term_string( Terx, Str, [] ), + assert( clauses_positions( ChaCoufpos, ChaCountEnd, Fn, Str ) ), +read_clauses_stream_to_memory( Sea , Fn ). + +read_clauses_stream_to_memory( _Sea , _ ):- !. + +% read_clauses(). + +display_mem_x():- + retract( clauses_positions( ChaCoufpos, ChaCountEnd, Fn, Str ) ), + write_term( clauses_positions( ChaCoufpos, ChaCountEnd, Fn, Str ) , [] ), nl, + fail, !. +display_mem_x():- !. + + +:- dynamic clauses_positions/4. +read_file():- + retractall( clauses_positions( _, _, _, _ ) ), + % Fn = 'data/test_read_prolog.pro', + Fn = '../canary_to_post/metta_eval.pl', + open( Fn , read, Sea , [ encoding(octet) ] ), + read_clauses_stream_to_memory( Sea , Fn ), + close( Sea ), + display_mem_x(). + + + + + %open( From, read, Sea , [ encoding(octet) ] ), + %read_file_stream( Sea, 1 ), + %close( Sea ). +% [divide_code]. +% divide_prolog_source_files(). + diff --git a/src/swi_analyse_metta/metta_analyse.pl b/src/swi_analyse_metta/metta_analyse.pl index 9d70567be6a..54f6d8eb9e5 100644 --- a/src/swi_analyse_metta/metta_analyse.pl +++ b/src/swi_analyse_metta/metta_analyse.pl @@ -1,8 +1,19 @@ -:- dynamic found_search_result/5. + :- use_module(library(dcg/basics)). +:- encoding(utf8). + + +%----- +:- dynamic eval_tag/6. +:- dynamic eval_tag_secondary/2. +:- dynamic eval_tag_found/6. +:- dynamic found_search_result/6. + + + today_key(Dk):- get_time(Stamp), stamp_day_atom(Stamp, Dk),!. @@ -53,7 +64,13 @@ % 1 is alleen met de apps , 0 is alleen gym files %-- -special_directory_files('../canary/', [ 'metta_eval.pl' , 'metta_interp.pl' , 'metta_ontology.pfc.pl' ]):-!. +special_directory_files('../canary/', [ 'metta_eval.pl' , 'metta_interp.pl' , 'metta_ontology.pfc.pl', 'stdlib_mettalog.metta' ]):- !. +% experime +%special_directory_files('../../../hyperon-experimental/lib/src/metta/runner/', [ 'stdlib_minimal.rs' , 'stdlib.rs' ]):- !. +special_directory_files('../../../hyperon-experimental/lib/src/metta/runner/', [ 'stdlib_minimal.rs' , 'stdlib.rs' ]):- !. + + + % special_directory_files(Dx, Lis):- !, directory_files(Dx, Lis). @@ -127,7 +144,7 @@ get_all_singularity_files(_, Is_mdf_day_after, Dx):- - dir_level(1, Item, _,_, _,_,_,_,_,_), atomic_list_concat([ Dx, Item, '/'], Cy), directory_files(Cy, Lis), + dir_level(1, Item, _,_, _,_,_,_,_,_), atomic_list_concat([ Dx, Item, '/'], Cy), special_directory_files(Cy, Lis), member(El, Lis), El \= '..', El \= '.', is_prolog_atom_file( El, Item ), @@ -139,7 +156,7 @@ get_all_singularity_files(_, Is_mdf_day_after, Dx):- dir_level(2, Item, Sub, _, _, _, _, _, _, _), atomic_list_concat([ Dx, Item, '/', Sub, '/' ], Cy ), - directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', + special_directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), atom_concat(Cy, El, Cx), time_file( Cx, Stamp ), stamp_day_atom( Stamp, Dat ), @@ -149,7 +166,7 @@ get_all_singularity_files(_, Is_mdf_day_after, Dx):- dir_level(3, Item, Item2, Sub, _, _, _, _, _, _), atomic_list_concat([ Dx, Item, '/', Item2, '/', Sub, '/' ], Cy ), - directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), + special_directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), atom_concat(Cy, El, Cx), time_file( Cx, Stamp ), stamp_day_atom( Stamp, Dat ), match_date_atom( Dat, Is_mdf_day_after ), assert( file_level( 3, Item, Item2, Sub, '', '', '', '', '', El, Dat ) ), fail,!. @@ -157,7 +174,7 @@ get_all_singularity_files(_, Is_mdf_day_after, Dx):- dir_level(4, Item, Item2, Item3, Sub, _, _, _, _, _), atomic_list_concat([ Dx, Item, '/', Item2, '/', Item3, '/', Sub, '/' ], Cy ), - directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), + special_directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), atom_concat(Cy, El, Cx), time_file( Cx, Stamp ), stamp_day_atom( Stamp, Dat ), match_date_atom( Dat, Is_mdf_day_after ), assert( file_level( 4, Item, Item2, Item3, Sub, '', '', '', '', El, Dat ) ), fail,!. @@ -165,7 +182,7 @@ get_all_singularity_files(_, Is_mdf_day_after, Dx):- dir_level(5, Item, Item2, Item3, Item4, Sub, _, _, _, _), atomic_list_concat([ Dx, Item, '/', Item2, '/', Item3, '/', Item4, '/', Sub, '/' ], Cy ), - directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), + special_directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), atom_concat(Cy, El, Cx), time_file( Cx, Stamp ), stamp_day_atom( Stamp, Dat ), match_date_atom( Dat, Is_mdf_day_after ), assert( file_level( 5, Item, Item2, Item3, Item4, Sub, '', '', '', El, Dat ) ), fail,!. @@ -173,7 +190,7 @@ get_all_singularity_files(_, Is_mdf_day_after, Dx):- dir_level(6, Item, Item2, Item3, Item4, Item5, Sub, _, _, _), atomic_list_concat([ Dx, Item, '/', Item2, '/', Item3, '/', Item4, '/', Item5, '/', Sub, '/' ], Cy ), - directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), + special_directory_files( Cy, Lis ), member( El, Lis ), El \= '..', El \= '.', is_prolog_atom_file( El, Sub ), atom_concat(Cy, El, Cx), time_file( Cx, Stamp ), stamp_day_atom( Stamp, Dat ), match_date_atom( Dat, Is_mdf_day_after ), assert( file_level( 6, Item, Item2, Item3, Item4, Item5, Sub, '', '', El, Dat ) ), fail,!. @@ -238,27 +255,42 @@ % :- dynamic found_base_teur/4. -read_has_search_strings( _, From, Zk, Level, Is_include , Isleading):- - sub_atom( From, _, _, _, '.metta' ), size_file( From , Size ), Size < 700, read_file_to_string(From, Bstr, [] ), !, - if_extra_string_demand_search( Bstr ), search_o_y_and_assert( Is_include, Bstr, Zk, From, Level, 0 , Isleading). +%read_has_search_strings( _, From, Zk, Level, Is_include , Isleading):- +% sub_atom( From, _, _, _, '.metta' ), size_file( From , Size ), Size < 700, read_file_to_string(From, Bstr, [] ), !, +% if_extra_string_demand_search( Bstr ), search_o_y_and_assert( Is_include, Bstr, Zk, From, Level, 0 , Isleading). -read_has_search_strings( _, From, Zk, Level, Is_include , Isleading):- - sub_atom( From, _, _, _, '.py' ), size_file( From , Size ), Size < 700, read_file_to_string(From, Bstr, [] ), !, - if_extra_string_demand_search( Bstr ), search_o_y_and_assert( Is_include, Bstr, Zk, From, Level, 0 , Isleading). +%read_has_search_strings( _, From, Zk, Level, Is_include , Isleading):- +% sub_atom( From, _, _, _, '.py' ), size_file( From , Size ), Size < 700, read_file_to_string(From, Bstr, [] ), !, +% if_extra_string_demand_search( Bstr ), search_o_y_and_assert( Is_include, Bstr, Zk, From, Level, 0 , Isleading). -read_has_search_strings( _, From, Zk, Level, Is_include , Isleading):- - sub_atom( From, _, _, _, '.rs' ), size_file( From , Size ), Size < 700, read_file_to_string(From, Bstr, [] ), !, - if_extra_string_demand_search( Bstr ), search_o_y_and_assert( Is_include, Bstr, Zk, From, Level, 0 , Isleading). +%read_has_search_strings( _, From, Zk, Level, Is_include , Isleading):- +% sub_atom( From, _, _, _, '.rs' ), size_file( From , Size ), Size < 700, read_file_to_string(From, Bstr, [] ), !, +% if_extra_string_demand_search( Bstr ), search_o_y_and_assert( Is_include, Bstr, Zk, From, Level, 0 , Isleading). read_has_search_strings( is_octet , From, Zk, Level, Is_include , Isleading):- retractall( comment_started() ), + + write( "check must read : " ), write( From ), nl , + not_exclude_metta_file( From ), + max_file_size( From , Max), + size_file( From, Size ), Size < Max, + write( "Start read : " ), write( From ), nl , open( From, read, Sea , [ encoding(octet) ] ), read_has_search_stream( Sea, Zk, From, Level, 1, Is_include , Isleading ), close( Sea ). + +% % mogelijke waarden octet, ascii, iso_latin_1 , text, utf8 , unicode_be, unicode_le + read_has_search_strings( is_utf8 , From, Zk, Level, Is_include , Isleading):- retractall( comment_started() ), + + write( "check must read : " ), write( From ), nl , + not_exclude_metta_file( From ), + max_file_size( From , Max ), + size_file( From, Size ), Size < Max, + write( "Start read : " ), write( From ), nl , open( From, read, Sea , [ encoding(utf8) ] ), read_has_search_stream( Sea, Zk, From, Level, 1, Is_include , Isleading), close( Sea ). @@ -393,12 +425,109 @@ str_part_before_tag(At, Tag, Pa_before):- atom_length(Tag, TagLe), TagLe > 0, sub_atom(At, Bg, _, _, Tag), sub_atom(At, 0, Bg, _, Pa_before),!. +%str_replace_tag(At, Repwhat, RepWith, Resu):- str_part_before_tag(At, Repwhat, Pa_before), str_part_after_tag(At, Repwhat, Pa_aft),!, +% string_concat(Pa_before,RepWith, C1), string_concat(C1,Pa_aft, Resu). +%str_replace_tag(At, _,_, At):- !. + + str_replace_tag(At, Repwhat, RepWith, Resu):- str_part_before_tag(At, Repwhat, Pa_before), str_part_after_tag(At, Repwhat, Pa_aft),!, string_concat(Pa_before,RepWith, C1), string_concat(C1,Pa_aft, Resu). str_replace_tag(At, _,_, At):- !. +lis_code_remove([], _, [], [] ):-!. +lis_code_remove([H|Codes1], Cde, [Cde |Codes2], Lisnot ):- H = Cde, !, + lis_code_remove(Codes1, Cde, Codes2, Lisnot). +lis_code_remove([H|Codes1], Cde, Codes2 , [ H |Lisnot]):- !, lis_code_remove(Codes1, Cde, Codes2, Lisnot). + +%--- + +lis_code_count( [], _, Res, Res ):- !. +lis_code_count( [ H | Codes1 ], Cde, Count, Res ):- H = Cde, !, + Count2 is Count + 1, lis_code_count( Codes1, Cde, Count2, Res ). +lis_code_count( [ _ | Codes1 ], Cde, Count , Res ):- !, lis_code_count( Codes1, Cde , Count , Res ). + +%--- + +str_code_remove( Str, Cde, Str2):- + string_codes(Str, Codes1), + lis_code_remove(Codes1, Cde, _, Codes2),!, string_codes(Str2, Codes2). + +str_code_occurence_count( Str, Cde, Count ):- + string_codes(Str, Codes1 ), + lis_code_count( Codes1, Cde, 0, Count ), !. + +%---- + +% , +read_extra_lines_max_until_full_metta_claus( Count_is_open, Count, _Max, _Sea , StrBuf, StrBuf, Count ):- Count_is_open == 0, !. + + +read_extra_lines_max_until_full_metta_claus( Count_is_open, Count, Max, Sea , StrBuf, Xtra_lines, ResultCount ):- Count < Max, + read_line_to_string( Sea, Lx ), Lx \= end_of_file, !, + parenthesis_count( Lx, Count_open ), NewCount is Count_is_open + Count_open, + string_concat( StrBuf, "\n", C2 ), string_concat( C2, Lx, StrBuf2 ), + Count2 is Count + 1, + read_extra_lines_max_until_full_metta_claus( NewCount, Count2, Max, Sea , StrBuf2, Xtra_lines, ResultCount ). + + +read_extra_lines_max_until_full_metta_claus( _Count_is_open, Count, _Max, _Sea , StrBuf, StrBuf, Count ):- !. +%-- +%write_line_with_tag_colors( Ext, Txt ):- !, +% string_codes( Txt, Codes ), +% write_codes_with_tag_colors( Ext, Codes ). + +%--- +write_metta_clause_htm( Lx ):- + +% str_replace_tag(At, Repwhat, RepWith, Resu) + + string_codes( Lx, Codes ), + % write_codes_with_tag_colors( Ext, Codes ). + Parenthesis_level is 0, + write_codes_metta_clause_htm( Codes , Parenthesis_level ). + +%-- +write_big_tag( Tag ):- + write( "\n
" ), + write( Tag ), + write( "\n
" ). + + + +%-- +write_metta_clause( Lx ):- parenthesis_count( Lx, Count_is_open ), Count_is_open == 0, !, + write( "\n
" ), + write_metta_clause_htm( Lx ), + write( "\n
" ). + +write_metta_clause( Lx ):- parenthesis_count( Lx, Count_is_open ), + number_string( Count_is_open, S2 ), !, write( "parenthesis" ), write( S2 ), write( " " ), + write( Lx ), !. + +write_metta_clause( Lx ):- write( Lx ), !. + + + + +%------ +parenthesis_count( Lx, Count_is_open ):- str_code_occurence_count( Lx, 40, Count1 ), + str_code_occurence_count( Lx, 41, Count2 ), Count_is_open is Count1 - Count2. +% Count1 = Count2 , !. +% lines_extra_for_metta_count_line_open_close( _Lx, 4 ):- !. + + +extra_lines_for_open_parenthesis( Count_is_open, Xtra_lines ):- Count_is_open == 0, Xtra_lines is 0 , !. +extra_lines_for_open_parenthesis( _Count_is_open, Xtra_lines ):- Xtra_lines is 4, !. + +%adhoc_parse_rust_regx( Str, Btag, Etag, Subz ):- sub_str_between( Str, Btag, Etag, Subz ), !. + +%adhoc_parse_rust_regx( Str, Btag, _Etag, Subz2 ):- +% sub_str_between( Str, Btag, ")", Subz ), +% str_code_remove( Subz, 34, Subz2 ). + + sub_str_between( Str, Btag, Etag, Subz ):- string_length( Str, Le0 ), sub_string( Str, Sta1, _, _, Btag ), @@ -409,6 +538,26 @@ sub_string( Sub1, Sta2, _, _, Etag ), Z2 is Sta2 - 0, sub_string( Sub1, 0, Z2, _, Subz ),!. + + +sub_str_between_plus_rest( Str, Btag, Etag, Subz , Subz2 ):- + string_length( Str, Le0 ), + sub_string( Str, Sta1, _, _, Btag ), + string_length( Btag, Le1 ), + Y is Sta1 + Le1, + Z is Le0 - Y, + sub_string( Str, Y, Z, _, Sub1 ), + sub_string( Sub1, Sta2, _, _, Etag ), + Z2 is Sta2 - 0, + sub_string( Sub1, 0, Z2, Aft, Subz ), + string_length( Etag, Le01 ), + %Q is Le01 - Z2, + Z3 is Z2 + Le01, + Aft3 is Aft - Le01, + sub_string( Sub1, Z3, Aft3, _, Subz2 ), + + !. + file_path_get_str(F , Pa2, Fn):- atom_string(Fa, F), @@ -426,18 +575,18 @@ lis_code_replace(Codes1, Cde, Cde2, Codes2). lis_code_replace([H|Codes1], Cde, Cde2, [H|Codes2] ):- !, lis_code_replace(Codes1, Cde, Cde2, Codes2). -lis_code_remove([], _, [], [] ):-!. -lis_code_remove([H|Codes1], Cde, [Cde |Codes2], Lisnot ):- H = Cde, !, - lis_code_remove(Codes1, Cde, Codes2, Lisnot). -lis_code_remove([H|Codes1], Cde, Codes2 , [ H |Lisnot]):- !, lis_code_remove(Codes1, Cde, Codes2, Lisnot). +%lis_code_remove([], _, [], [] ):-!. +%lis_code_remove([H|Codes1], Cde, [Cde |Codes2], Lisnot ):- H = Cde, !, +% lis_code_remove(Codes1, Cde, Codes2, Lisnot). +%lis_code_remove([H|Codes1], Cde, Codes2 , [ H |Lisnot]):- !, lis_code_remove(Codes1, Cde, Codes2, Lisnot). str_code_replace( Str, Cde, Cde2, Str2):- string_codes(Str, Codes1), lis_code_replace(Codes1, Cde, Cde2, Codes2),!, string_codes(Str2, Codes2). -str_code_remove( Str, Cde, Str2):- - string_codes(Str, Codes1), - lis_code_remove(Codes1, Cde, _, Codes2),!, string_codes(Str2, Codes2). +%str_code_remove( Str, Cde, Str2):- +% string_codes(Str, Codes1), +% lis_code_remove(Codes1, Cde, _, Codes2),!, string_codes(Str2, Codes2). lis_concat( [], Res, _, Res):- !. @@ -464,70 +613,181 @@ % omz_fw_slash(_Pa4z, '/'):-!. - - %--- +assert_eval_tag_found( Type, Tag , _ , _ , _ ):- eval_tag_found( Type, Tag, _, _, _ , _), !. +assert_eval_tag_found( Type, Tag , Tg1, Tg2, Tg3 ):- !, assert( eval_tag_found( Type, Tag, Tg1, Tg2, Tg3, 0 ) ). +%-------------------- +assert_eval_tag_mult( Type_tag, Linum, Tag, F, Sline ):- string_lower( Tag, Taglow ), + assert( eval_tag( Type_tag, Linum, Taglow, F , Sline, 0 ) ), !. + +%----------- +assert_eval_tag( Type_tag, _Linum, Tag, _F, _, _Ari ):- string_lower( Tag, Taglow ) , eval_tag( Type_tag, _, Taglow, _ , _, _ ), !. +assert_eval_tag( Type_tag, Linum, Tag, F, Sline, Ari ):- string_lower( Tag, Taglow ), assert( eval_tag( Type_tag, Linum, Taglow, F , Sline , Ari) ), !. %----- -:- dynamic eval_tag/1. -:- dynamic eval_tag_found/1. -assert_eval_tag_found( Tag ):- eval_tag_found( Tag ), !. -assert_eval_tag_found( Tag ):- !, assert( eval_tag_found( Tag ) ). +trim_string(Str, Sc):- split_string(Str, "", " ", [Sc]),!. +trim_string(Sc, Sc):- !. % sub_str_between( Lx, "['", "'", Tag ), -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_leading ):- - sub_atom( F, _,_,_, 'metta_eval'), search_o_y( Lx, "eval_20&:-" ), - try_read_find_eval20_tag_in_string( Lx , Tag ), is_metta_function( Tag ), - not( eval_tag( Tag ) ), assert( eval_tag( Tag ) ), !, - asserta( found_search_result( Level, Linum, F, Lx, Tag ) ). +%is_debugging( 1 ):- !. +is_debugging( 0 ):- !. -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_not_leading ):- - sub_atom( F, _,_,_, 'metta_eval'), search_o_y( Lx, "eval_20&:-" ), - try_read_find_eval20_tag_in_string( Lx , Tag ), - eval_tag( Tag ), !, - assert_eval_tag_found( Tag ), - % sub_string( Lx, _, _, _ , Tag ), - % string_concat( Lx, " ** " , Cx ), string_concat( Cx, Tag, Cp ), string_concat( Cp, " " , C3 ), - assert( found_search_result( Level, Linum, F, Lx, Tag ) ). +debug_string( S1, S2 ):- is_debugging( Is ), Is == 1,!, + write( S1 ), write( " " ), write( S2 ), nl . +debug_string( _, _ ):-!. +% try_read_ontology("properties('&corelib','if', [flow_control, qhelp(\"Conditional execution.\"), conditional_execution]).", T1, T2, T3 ). +% try_read_ontology("properties('&corelib','let', [variable_assignment, qhelp(\"Variable assignment.\")])."). +try_read_ontology( Lx0, Tag1, Tag2, Tag3 ):- + string_lower( Lx0, Lx2 ), str_code_remove( Lx2, 34, Lx ), + sub_str_between_plus_rest( Lx, "[", ",", Tag1, Rest1 ), + sub_str_between_plus_rest( Rest1, "qhelp(", ")", Tag2, Rest2 ), + sub_str_between_plus_rest( Rest2, ",", "]", Tag3, _Rest3 ), !. -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , _Isleading):- - sub_atom( F, _,_,_, 'metta_interp'), search_o_y( Lx, "eval_h(&:-" ), eval_tag( Tag_s ), - metta_interp_tag( Tag_from, Tag_til ), - string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C2 ), sub_string( Lx, _, _, _ , C2 ), !, - assert_eval_tag_found( Tag_s ), - assert( found_search_result( Level, Linum, F, Lx, Tag_s ) ). +try_read_ontology( Lx0, Tag1, Tag2, "" ):- + string_lower( Lx0, Lx2 ), str_code_remove( Lx2, 34, Lx ), + sub_str_between_plus_rest( Lx, "[", ",", Tag1, Rest1 ), + sub_str_between_plus_rest( Rest1, "qhelp(", ")", Tag2, _Rest2 ), !. -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , _Isleading):- - sub_atom( F, _, _, _, 'metta_ontology.pfc' ), search_o_y( Lx, "properties(" ), eval_tag( Tag_s ), - metta_ontology_tag( Tag_from, Tag_til ), - string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C2 ), - sub_string( Lx, _, _, _ , C2 ), !, - assert_eval_tag_found( Tag_s ), - assert( found_search_result( Level, Linum, F, Lx, Tag_s ) ). +try_read_ontology( _Lx, "cantf1", "cantf2" , "cantf3" ):- !. + + +not_exclude_metta_file( F ):- downcase_atom( F, F2 ), sub_atom( F2,_,_,_, 'data_subset' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'edges' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'aunt-kg' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'miner' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'nars' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'flybase' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'node' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'royal92' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'bigram' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'gpt2-like' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, 'bio-atom' ), !, fail . +not_exclude_metta_file( F ):- downcase_atom( F, F2 ),sub_atom( F2,_,_,_, '.gz' ), !, fail . +not_exclude_metta_file( _F ):-!. + +max_file_size( F , 500000 ):- downcase_atom( F, F2 ), sub_atom( F2,_,_,_, 'stdlib' ), ! . +max_file_size( F , 10000 ):- downcase_atom( F, F2 ), sub_atom( F2,_,_,_, '.metta' ), ! . +max_file_size( _From , 500000):-!. +dont_accept_fail( Lx ):- sub_string( Lx, _,_,_, "fail" ), !, fail. +dont_accept_fail( _Lx ):-!. + + +eval_pl_tag_or_rs_tag( Tag_s ):- eval_tag( 'pl_tag', _, Tag_s, _ ,_,_). +eval_pl_tag_or_rs_tag( Tag_s ):- eval_tag( 'rust', _, Tag_s, _ ,_,_). + + + +%search_o_y_and_assert( 1, Sea, Linum, Lx, _Zk, F, Level, Linum , is_leading, Lines_read_extra ):- +% get_type(Arg,Type):- eval_H(['get-type',Arg],Type). +%:- discontiguous eval_40/6. +%:- discontiguous eval_70/6. + +% properties('&corelib','parse', [data_structures, qhelp("Parse a string to an expression."), parse ]). +% between +% properties('&corelib','parse', [data_structures, qhelp("Parse a string to an expression."), parse ]). + % between + %sub_str_between_plus_rest( Lx, "[", ",", Tag1, Rest1 ), + %sub_str_between_plus_rest( Rest1, "qhelp(", ")", Tag2, Rest2 ), + %sub_str_between_plus_rest( Rest2, ",", "]", Tag3, _Rest3 ), +% str_part_after_tag( Lx, "qhelp(", AfterStr2 ), str_part_before_tag( AfterStr2, ")" , Tag2 ), +% str_part_after_tag( AfterStr2 , ",", AfterStr4 ), +% str_part_before_tag( AfterStr4 , "]", Tag3 ), % search_o_y( Lx, "assertequaltoresult&" ), % (@doc intersection -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_not_leading ):- - sub_atom( F, _, _, _, '.metta' ), eval_tag( Tag_s ), - metta_file_tag( Tag_from, Tag_til ), + + + +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , is_not_leading, 0 ):- + sub_atom( F, _,_,_, 'metta_eval'), ( search_o_y( Lx, "eval_20&:-" ) ; search_o_y( Lx, "eval_40&:-" ) ; search_o_y( Lx, "eval_70&:-" ) ), + dont_accept_fail( Lx ), try_read_find_eval20_tag_in_string( Lx , Tag, Arities ), is_metta_function( Tag ), + write(" ASSERT PL TAG "), write( Tag ), nl, assert_eval_tag( 'pl_tag', Linum, Tag, F, Lx , Arities ), + asserta( found_search_result( 'pl_tag', Tag, Level, Linum, F, Lx ) ). + +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , is_not_leading, 0 ):- + sub_atom( F, _,_,_, 'metta_eval'), search_o_y( Lx, "eval_20&:-" ), + try_read_find_eval20_tag_in_string( Lx , Tag, _Arities ), eval_tag( _, _, Tag, _ , _,_), !, + assert_eval_tag_found( 'metta', Tag , "", "", "" ), assert( found_search_result( 'metta', Tag, Level, Linum, F, Lx ) ). + +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, _Level, Linum , is_not_leading, 0 ):- + sub_atom( F, _,_,_, 'metta_interp'), search_o_y( Lx, "eval_h(&:-" ), + metta_interp_tag( Tag_from, Tag_til ), sub_str_between( Lx, Tag_from, Tag_til, Subz ), + assert_eval_tag( 'pl_interp_tag', Linum, Subz, F, Lx, 0 ), !. + +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , _Isleading, 0 ):- + sub_atom( F, _,_,_, 'metta_interp'), search_o_y( Lx, "eval_h(&:-" ), eval_tag( _, _, Tag_s, _ ,_,_), + metta_interp_tag( Tag_from, Tag_til ), string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C2 ), + search_o_y( Lx, C2 ) , !, assert_eval_tag_found( 'metta_interp_pl', Tag_s , "", "", "" ), + assert( found_search_result( 'metta_interp_pl', Tag_s, Level, Linum, F, Lx ) ). + + +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , _Isleading, 0):- + sub_atom( F, _, _, _, 'metta_ontology.pfc' ), search_o_y( Lx, "properties(" ), eval_tag( _, _, Tag_s, _ ,_,_), + metta_ontology_tag( Tag_from, Tag_til ), + string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C2 ), + search_o_y( Lx, C2 ), !, try_read_ontology( Lx, Tag1, Tag2, Tag3 ), + write( "succeed-" ), write( Tag_s ), write("-"), write( Tag1 ), write( Tag2 ), write( Tag3 ), nl, + assert_eval_tag_found( 'metta_ontol_pl', Tag_s , Tag1, Tag2, Tag3 ), + assert( found_search_result( 'metta_ontol_pl', Tag_s, Level, Linum, F, Lx ) ). + + +search_o_y_and_assert( 1, Sea, Linum, Lx, _Zk, F, Level, Linum , metta_else_where , Lines_read_extra ):- + not_exclude_metta_file( F ), file_name_extension( _, Ext, F ), Ext == 'metta', + eval_pl_tag_or_rs_tag( Tag_s ), metta_file_tag_til_space( Tag_from, Tag_til ), string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), - sub_string( Lx, _, _, _ , C4 ), !, - assert_eval_tag_found( Tag_s ), - assert( found_search_result( Level, Linum, F, Lx, Tag_s ) ). + search_o_y( Lx, C4 ), !, + parenthesis_count( Lx, Count_is_open ), extra_lines_for_open_parenthesis( Count_is_open, Lines_read_extra ), + read_extra_lines( 'metta' , Lines_read_extra, Sea , Xtra_lines ), string_concat( Lx, Xtra_lines , Lx2 ), + assert_eval_tag_mult( 'metta_tag_extra', Linum, Tag_s , F, Lx2 ), + % metta_example + assert( found_search_result( 'metta_example', Tag_s, Level, Linum, F, Lx2 ) ). + + +search_o_y_and_assert( 1, Sea, Linum, Lx, _Zk, F, _Level, Linum , metta_std_lib , ResultCount ):- + not_exclude_metta_file( F ), file_name_extension( _, Ext, F ), Ext == 'metta', + eval_pl_tag_or_rs_tag( Tag_s ), metta_docfile_tag( Tag_from, Tag_til ), + string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), + search_o_y( Lx, C4 ), !, parenthesis_count( Lx, Count_is_open ), + read_extra_lines_max_until_full_metta_claus( Count_is_open, 0, 8, Sea , "", Xtra_lines, ResultCount ), + string_concat( Lx, Xtra_lines , Lx2 ), + assert_eval_tag_mult( 'metta_tag_std_lib', Linum, Tag_s , F, Lx2 ). + +% metta_docfile_tag( "(@doc ", "" ):- !. + +search_o_y_and_assert( 1, Sea, Linum, Lx, _Zk, F, _Level, Linum , metta_std_lib , ResultCount ):- + not_exclude_metta_file( F ), file_name_extension( _, Ext, F ), Ext == 'metta', + eval_pl_tag_or_rs_tag( Tag_s ), metta_function_declaration( Tag_from, Tag_til ), + string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), + search_o_y( Lx, C4 ), !, parenthesis_count( Lx, Count_is_open ), + read_extra_lines_max_until_full_metta_claus( Count_is_open, 0, 8, Sea , "", Xtra_lines, ResultCount ), + string_concat( Lx, Xtra_lines , Lx2 ), assert_eval_tag_mult( 'metta_tag_std_lib', Linum, Tag_s , F, Lx2 ). + +search_o_y_and_assert( 1, Sea, Linum, Lx, _Zk, F, Level, Linum , is_not_leading , Lines_read_extra):- + not_exclude_metta_file( F ), file_name_extension( _, Ext, F ), Ext == 'metta', + eval_pl_tag_or_rs_tag( Tag_s ), metta_docfile_tag( Tag_from, Tag_til ), + string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), search_o_y( Lx, C4 ),!, + parenthesis_count( Lx, Count_is_open ), extra_lines_for_open_parenthesis( Count_is_open, Lines_read_extra ), + assert_eval_tag_mult( 'metta_doc', Linum, Tag_s , F, Lx ), + read_extra_lines( 'metta' , Lines_read_extra, Sea , Xtra_lines ), string_concat( Lx, Xtra_lines , Lx2 ), + assert( found_search_result( 'metta', Tag_s , Level, Linum, F, Lx2 ) ). + +search_o_y_and_assert( 1, Sea, Linum, Lx, _Zk, F, Level, Linum , is_not_leading, ResultCount ):- + not_exclude_metta_file( F ), file_name_extension( _, Ext, F ), Ext == 'metta', + eval_pl_tag_or_rs_tag( Tag_s ), metta_file_tag( Tag_from, Tag_til ), + string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), search_o_y( Lx, C4 ), !, + parenthesis_count( Lx, Count_is_open ), + % eval_tag(pl_tag,2089,"py-eval",'../canary/metta_eval.pl',"eval_70(_Eq,_RetType,_Depth,_Self,['py-eval',Arg],Res):- !,",1) + % Type_tag, Linum, Tag, F, Sline + assert_eval_tag_mult( 'metta_example', Linum, Tag_s , F, Lx ), + read_extra_lines_max_until_full_metta_claus( Count_is_open, 0, 8, Sea , "", Xtra_lines, ResultCount ), + string_concat( Lx, Xtra_lines , Lx2 ), assert( found_search_result( 'metta_example', Tag_s , Level, Linum, F, Lx2 ) ). -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_not_leading ):- - sub_atom( F, _, _, _, '.metta' ), eval_tag( Tag_s ), - metta_docfile_tag( Tag_from, Tag_til ), - string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), - sub_string( Lx, _, _, _ , C4 ), !, - assert_eval_tag_found( Tag_s ), - assert( found_search_result( Level, Linum, F, Lx, Tag_s ) ). %search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum ):- @@ -538,73 +798,135 @@ % assert( found_search_result( Level, Linum, F, C2 ) ). -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_not_leading ):- - % sub_atom( F, _, _, _, '.rs' ), - % file_base_name( From2 , Fnx ), +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , Is_leading , 0):- + ( Is_leading == 'is_not_leading' ; Is_leading == 'is_leading' ), file_name_extension( _, Ext, F ), Ext == 'rs', - eval_tag( Tag_s ), - % string_concat( "new(\"!(", Tag_s, C1 ), - % assert_eq!(expr!("A" a {1}).iter().collect::>(), - rust_detect_tag( Tag_from, Tag_til ), + eval_tag( _, _, Tag_s, _ , _ , _ ), + rust_metta_tag( Tag_from, Tag_til ), string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), - sub_string( Lx, _, _, _ , C4 ), !, - assert_eval_tag_found( Tag_s ), - % string_concat( Lx, " ** " , Cx ), string_concat( Cx, C1, Cp ), string_concat( Cp, " " , C2 ), !, - assert( found_search_result( Level, Linum, F, Lx, Tag_s ) ). + search_o_y( Lx, C4 ), !, + assert_eval_tag_found( 'rust_metta', Tag_s , "", "", "" ), + assert( found_search_result( 'rust_metta', Tag_s , Level, Linum, F, Lx ) ). -% kopie -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_leading ):- + + +search_o_y_and_assert( 1, Sea, Linum, Lx, _Zk, F, Level, Linum , Is_leading, Lines_read_extra ):- + ( Is_leading == 'is_not_leading' ; Is_leading == 'is_leading' ), file_name_extension( _, Ext, F ), Ext == 'rs', - % sub_str_between( Lx, "new(\"!(", " ", Subz ), - rust_detect_tag( Tag_from, Tag_til ), - sub_str_between( Lx, Tag_from, Tag_til, Subz ), - is_metta_function( Subz ), - not( eval_tag( Subz ) ), !, assert( eval_tag( Subz ) ), - asserta( found_search_result( Level, Linum, F, Lx, Subz ) ). + eval_tag_secondary( Tag_org, Tag_s ), + search_o_y( Lx, Tag_s ), !, + assert_eval_tag_found( 'rust', Tag_org , "", "", "" ), Lines_read_extra = 4, + read_extra_lines( 'rust' , Lines_read_extra, Sea , Xtra_lines ), string_concat( Lx, Xtra_lines , Lx2 ), + assert( found_search_result( 'rust', Tag_org , Level, Linum, F, Lx2 ) ). + + +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , Is_leading , 0):- + ( Is_leading == 'is_not_leading' ; Is_leading == 'is_leading' ), + file_name_extension( _, Ext, F ), Ext == 'rs', + eval_tag( _, _, Tag_s, _ ,_,_), + rust_detect_tag( Tag_from, Tag_til , _, _), + string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), + search_o_y( Lx, C4 ), !, + assert_eval_tag_found( 'rust', Tag_s , "", "", "" ), + assert( found_search_result( 'rust', Tag_s , Level, Linum, F, Lx ) ). -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_not_leading ):- + +% IS FREE TAG SEARCH +%search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, _Level, Linum , is_not_leading, 0 ):- +% not_exclude_metta_file( F ), file_name_extension( _, Ext, F ), Ext == 'metta', +% metta_file_tag_find( Tag_from, Tag_til ), sub_str_between_plus_rest( Lx, Tag_from, Tag_til, Subz, Rest ), +% assert_eval_tag( 'metta_tag', Linum, Subz, F, Lx , 0 ), sub_str_between_plus_rest( Rest, Tag_from, Tag_til, Subz2, Rest2 ), +% assert_eval_tag( 'metta_tag', Linum, Subz2, F, Lx , 0), sub_str_between_plus_rest( Rest2, Tag_from, Tag_til, Subz3, _Rest3 ), +% assert_eval_tag( 'metta_tag', Linum, Subz3, F, Lx , 0 ), !. +%search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, _Level, Linum , is_not_leading, 0 ):- +% not_exclude_metta_file( F ), file_name_extension( _, Ext, F ), Ext == 'metta', +% metta_file_tag_find( Tag_from, Tag_til ), sub_str_between_plus_rest( Lx, Tag_from, Tag_til, Subz, Rest ), +% assert_eval_tag( 'metta_tag', Linum, Subz, F, Lx , 0), sub_str_between_plus_rest( Rest, Tag_from, Tag_til, Subz2, _Rest2 ), +% assert_eval_tag( 'metta_tag', Linum, Subz2, F, Lx , 0), !. +%search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, _Level, Linum , is_not_leading, 0 ):- not_exclude_metta_file( F ), +% file_name_extension( _, Ext, F ), Ext == 'metta', metta_file_tag_find( Tag_from, Tag_til ), +% sub_str_between_plus_rest( Lx, Tag_from, Tag_til, Subz, _Rest ), assert_eval_tag( 'metta_tag', Linum, Subz, F, Lx , 0), !. + + +%search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , is_leading ):- +% file_name_extension( _, Ext, F ), Ext == 'rs', +% rust_detect_tag( Tag_from, Tag_til , Second_tag_begin, Second_tag_end ), +% debug_string( "TRY rust between ", Lx ), +% sub_string( Lx, _, _, _, "er_tok"), + % debug_string( "TRY rust in file ", F ), +% adhoc_parse_rust_regx( Lx, Tag_from, Tag_til, Subz ), +% debug_string( "succeed rust between ", Lx ), +% is_metta_function( Subz ), + % not( eval_tag( _, Subz, _ ) ), assert( eval_tag( Linum, Subz, F ) ), + % asserta( found_search_result( Level, Linum, F, Lx, Subz ) ), !. +% temp +% sub_str_between( Lx, Second_tag_begin, Second_tag_end, Subz2 ), +% trim_string( Subz2 , Subz3 ) , +% not( eval_tag_secondary( Subz, Subz3 ) ), !, assert( eval_tag_secondary( Subz, Subz3 ) ) . + +% { assert_equal_to_result_op.clone() }); + +search_o_y_and_assert( 1, _Sea, Linum, Lx, _Zk, F, Level, Linum , is_not_leading, 0 ):- sub_atom( F, _, _, _, '.py' ), - eval_tag( Tag_s ), string_length( Tag_s, Lex ), Lex > 3, - % assert_eq + eval_tag( _, _, Tag_s, _ ,_,_), string_length( Tag_s, Lex ), Lex > 3, python_detect_tag( Tag_from, Tag_til ), string_concat( Tag_from, Tag_s, C1 ), string_concat( C1, Tag_til, C4 ), - sub_string( Lx, _, _, _ , C4 ), !, - assert_eval_tag_found( Tag_s ), - assert( found_search_result( Level, Linum, F, Lx, Tag_s ) ). + search_o_y( Lx, C4 ), !, + assert_eval_tag_found( 'python', Tag_s , "", "", "" ), + assert( found_search_result( 'python', Tag_s , Level, Linum, F, Lx ) ). % kopie -search_o_y_and_assert( 1, Lx, _Zk, F, Level, Linum , is_leading ):- +search_o_y_and_assert( 1, _Sea, Lx, Linum, _Zk, F, Level, Linum , is_leading, 0 ):- sub_atom( F, _, _, _, '.py' ), python_detect_tag( Tag_from, Tag_til ), sub_str_between( Lx, Tag_from, Tag_til, Subz ), - is_metta_function( Subz ), - not( eval_tag( Subz ) ), !, assert( eval_tag( Subz ) ), - asserta( found_search_result( Level, Linum, F, Lx, Subz ) ). + is_metta_function( Subz ), + assert_eval_tag_found( 'python', Subz , "", "", "" ), + assert_eval_tag( 'python', Linum, Subz, F, Lx , 0), +% not( eval_tag( _, _, Subz, _ ) ), !, assert( eval_tag( Linum, Subz, F ) ), + asserta( found_search_result( 'python', Subz , Level, Linum, F, Lx ) ). -:- dynamic extra_string_to_search/1. +% :- dynamic extra_string_to_search/1. -if_extra_string_demand_search( Lx ):- - extra_string_to_search( Str ), !, search_o_y( Lx, Str ). -if_extra_string_demand_search( _Lx ):- !. +%if_extra_string_demand_search( Lx ):- +% extra_string_to_search( Str ), !, search_o_y( Lx, Str ). +%if_extra_string_demand_search( _Lx ):- !. %search_o_y_and_assert( 1, Lx, Zk, F, Level, Linum ):- % search_o_y( Lx, Zk ),!, % assert( found_search_result( Level, Linum, F, Lx ) ). +read_number_of_lines( Sea, Number_of_lines, Hs , Xtra_lines ):- Number_of_lines > 0, + read_line_to_string( Sea, Lx ), Lx \= end_of_file, !, + Number_of_lines2 is Number_of_lines - 1, + string_concat( Hs , " \n
\n ", Hs2 ), string_concat( Hs2, Lx, Hs3 ), + read_number_of_lines( Sea, Number_of_lines2, Hs3 , Xtra_lines ). +read_number_of_lines( _Sea, _Number_of_lines, Hs , Hs ):- !. + + +%-- +% read_extra_lines_max_until_full_metta_claus( Count_is_open, 0, 8, Sea , Xtra_lines ), +read_extra_lines( _X , Number_of_lines, Sea , Xtra_lines ):- !, + read_number_of_lines( Sea, Number_of_lines, "" , Xtra_lines ). +read_extra_lines( _ , _Number_of_lines, _Sea , " " ):- !. + + + %---- read_has_search_stream( Sea, Zk, F, Level, Linum, Is_include, Isleading):- not( at_end_of_stream( Sea ) ), - read_line_to_string( Sea, Lx ), Lx \= end_of_file, not_is_comment(Lx), - zet_comment_started(Lx), zet_comment_ended(Lx), is_not_inside_comment(), - if_extra_string_demand_search( Lx ), - search_o_y_and_assert( Is_include, Lx, Zk, F, Level, Linum , Isleading ), + read_line_to_string( Sea, Lx ), Lx \= end_of_file, + % not_is_comment(Lx), + % zet_comment_started(Lx), zet_comment_ended(Lx), is_not_inside_comment(), + % if_extra_string_demand_search( Lx ), + search_o_y_and_assert( Is_include, Sea, Linum, Lx, Zk, F, Level, Linum , Isleading, Result_lines_red ), !, - Linum2 is Linum + 1, + Linum2 is Linum + Result_lines_red + 1, read_has_search_stream( Sea, Zk, F, Level, Linum2, Is_include , Isleading). read_has_search_stream( Sea, Zk, F, Level, Linum, Is_include, Isleading):- not( at_end_of_stream(Sea) ),!, @@ -750,34 +1072,330 @@ %----- -nondeterm_found_search_result( 'display_per_file', Filewithpath, TxLine1, Txtline, Filewithpath ):- - retract( found_search_result( _Level, _Lnum, Filewithpath, TxLine1, Txtline ) ). -nondeterm_found_search_result( 'display_per_tag', Filetag, TxLine1, Filetag, Filewithpath ):- - retract( found_search_result( _Level, _Lnum, Filewithpath, TxLine1, Filetag ) ). +nondeterm_found_search_result( 'display_per_file', Filewithpath, TxLine1, Txtline, Filewithpath, Lnum ):- + retract( found_search_result( _, Txtline, _Level, Lnum, Filewithpath, TxLine1 ) ). + + +%nondeterm_found_search_result( 'display_per_tag', Filetag, TxLine1, Filetag, Filewithpath ):- +% eval_tag_secondary( Filetag, Filetag2 ), +% retract( found_search_result( _Level, _Lnum, Filewithpath, TxLine1, Filetag2 ) ). + +nondeterm_found_search_result( 'display_per_tag', Filetag, TxLine1, Filetag, Filewithpath , Lnum ):- + retract( found_search_result( _, Filetag, _Level, Lnum, Filewithpath, TxLine1 ) ). + + + %--- -show_file_also( 'display_per_tag', Filewithpath ):- !, - write( " " ), write( Filewithpath ), write( " " ), write( "
\n" ), !. -show_file_also( _ , _Filewithpath ):- !. +show_file_also( 'display_per_tag', Filewithpath , Lnum ):- !, + write( "
\n" ), + write( "     " ), write( Filewithpath ), write( " - line: " ), write( Lnum ), write( "
\n" ), !. +show_file_also( _ , _Filewithpath ,_ ):- !. + +%---- + +doesnt_have_metta_tag( Tag ):- eval_tag( 'metta_tag' , _Linum, Tag, _F, _ ,_), !, fail. +doesnt_have_metta_tag( _Tag ):- !. + + +try_find_types( Tag_s , Tag1, Tag2, Tag3 ):- + eval_tag_found( 'metta_ontol_pl' , Tag_s , Tag1, Tag2, Tag3 , _), !. + +try_find_types( _Tag , "" , "" , "" ):- !. + + +eval_tag_or_similar_category( Ontol_1, Linum, Tag, Fn, Lx , From_similar , is_self ):- + eval_tag( 'metta_tag_std_lib' , Linum, Tag, Fn, Lx, _ ) , From_similar = Ontol_1. + +eval_tag_or_similar_category( Ontol_1, Linum, Tag, Fn, Lx , From_similar , is_self ):- + eval_tag( 'metta_tag_extra' , Linum, Tag, Fn, Lx, _ ) , From_similar = Ontol_1. + +% this one exists too + % assert_eval_tag_mult( 'metta_example', Linum, Tag_s , F, Lx2 ), + % metta_example + +eval_tag_or_similar_category( Ontol_1, Linum, Tag, Fn, Lx , Tag_other , similar_to ):- + eval_tag_found( 'metta_ontol_pl' , Tag , Ontol_1, _, _ ,_), + eval_tag_found( 'metta_ontol_pl' , Tag_other , Ontol_1, _, _ ,_), + Tag_other \= Tag, + eval_tag( 'metta_tag_std_lib' , Linum, Tag_other, Fn, Lx,_ ). + +eval_tag_or_similar_category( Ontol_1, Linum, Tag, Fn, Lx , Tag_other , similar_to ):- + eval_tag_found( 'metta_ontol_pl' , Tag , Ontol_1, _, _ ,_), + eval_tag_found( 'metta_ontol_pl' , Tag_other , Ontol_1, _, _ ,_), + Tag_other \= Tag, + eval_tag( 'metta_tag_extra' , Linum, Tag_other, Fn, Lx,_ ). + +eval_tag_or_similar_category( Ontol_1, Linum, Tag, Fn, Lx , Tag_other , similar_to ):- + eval_tag_found( 'metta_ontol_pl' , Tag , Ontol_1, _, _ ,_), + eval_tag_found( 'metta_ontol_pl' , Tag_other , Ontol_1, _, _ ,_), + Tag_other \= Tag, + eval_tag( 'metta_tag' , Linum, Tag_other, Fn, Lx,_ ). + %string_concat( " similar to : ", Tag_other , C4 ) . + + + + + + %string_concat( " similar to: ", Tag_other , C4 ) . +%--- + +enlarge_tag( similar_to, _Tag, From_similar, Lx, Lx2 ):- !, + string_concat( "
" , From_similar, C1 ), string_concat( C1 , "
", C2 ), + str_replace_tag( Lx , From_similar, C2, Lx2). + +enlarge_tag( _, Tag, _From_similar, Lx, Lx2 ):- !, + string_concat( "
" , Tag, C1 ), string_concat( C1 , "
", C2 ), + str_replace_tag( Lx , Tag, C2, Lx2). + + +%--- +write_similar_to( similar_to, Tag, From_similar ):- !, + write_big_tag( Tag ), write( " is similar to: "), write_big_tag( From_similar ). +%is_self +write_similar_to( _, Tag, _From_similar ):- write( " function: "), write_big_tag( Tag ), !. + + + + +%--- +write_metta_args( 1 ):- !, write( "aq" ). +write_metta_args( 2 ):- !, write( "aq au" ). +write_metta_args( 3 ):- !, write( "aq au as" ). +write_metta_args( 4 ):- !, write( "aq au as at" ). +write_metta_args( _ ):- !. + +write_metta_list_args( 1 ):- !, write( "(superpose (a b c))" ). +write_metta_list_args( 2 ):- !, write( "(superpose (a b c)) (superpose (c d e))" ). +write_metta_list_args( 3 ):- !, write( "(superpose (a b c)) (superpose (c d e)) (superpose (e f g))" ). +write_metta_list_args( 4 ):- !, write( "(superpose (a b c)) (superpose (c d e)) (superpose (e f g)) (superpose (g h i))" ). +write_metta_list_args( _ ):- !. + + + + +%-- +make_test_arity( 'type1' , N, Tag ):- + write( "!(" ), write( Tag ), write( " " ), write_metta_args( N ), write( " )" ), write( "
\n" ), + write( "!(assertEqual (" ), write( Tag ), write( " " ), write_metta_args( N ), write( " ) ( result_with_type )) " ), write( "
\n" ), + write( "!(assertEqualToResult (" ), write( Tag ), write( " " ), write_metta_args( N ), write( " ) ( result_with_type )) " ), write( "
\n" ), + % !(assertEqual (call! aq ) ( result_with_type )) + % !(assertEqualToResult (parse "(foo 1 2 3)" ) ((foo 1 2 3)) ) + !. + +make_test_arity( 'type2' , N, Tag ):- + write( "eval( \"!(" ), write( Tag ), write( " " ), write_metta_args( N ), write( " )\")." ), write( "
\n" ), + write( "eval( \""), write( "!(assertEqual (" ), write( Tag ), write( " " ), write_metta_args( N ), write( " ) ( result_with_type ))" ), write( "\" ).
\n" ), + write( "eval( \""), write( "!(assertEqualToResult (" ), write( Tag ), write( " " ), write_metta_args( N ), write( " ) ( result_with_type ))" ), write( "\" ).
\n" ), + % !(assertEqual (call! aq ) ( result_with_type )) + % !(assertEqualToResult (parse "(foo 1 2 3)" ) ((foo 1 2 3)) ) + !. + +make_test_arity( 'type3' , N, Tag ):- + write( "eval( \"!(" ), write( Tag ), write( " " ), write_metta_list_args( N ), write( " )\")." ), write( "
\n" ), + write( "eval( \""), write( "!(assertEqual (" ), write( Tag ), write( " " ), write_metta_list_args( N ), write( " ) ( superpose (e f g) ))" ), write( "\" ).
\n" ), + write( "eval( \""), write( "!(assertEqualToResult (" ), write( Tag ), write( " " ), write_metta_list_args( N ), write( " ) ( superpose (e f g) ))" ), write( "\" ).
\n" ), + % !(assertEqual (call! aq ) ( result_with_type )) + % !(assertEqualToResult (parse "(foo 1 2 3)" ) ((foo 1 2 3)) ) + !. + + +make_test_arity( _, _, _ ):-!. +%---- +%(@doc = +% (@desc "A symbol used to define reduction rules for expressions.") +% (@params ( +% (@param "Pattern to be matched against expression to be reduced") +% (@param "Result of reduction or transformation of the first pattern"))) +% (@return "Not reduced itself unless custom equalities over equalities are added") ) + + +%--- +write_doc_args( 1 ):- !, + write( "
(@params ( (@param \"\") ) )"). + + +write_doc_args( 2 ):- !, + write( "
(@params ( (@param \"\") "), + write( " (@param \"\")))" ). +write_doc_args( _ ):- !. +%---- + +%(@doc cons-atom +% (@desc "Constructs an expression using two arguments") +% (@params ( +% (@param "Head of an expression") +% (@param "Tail of an expression"))) +% ) +% (: cons-atom (-> Atom Expression Expression)) + + +make_doc_arity( 'type1' , Arit, Tag ):- + write("(@doc "), write( Tag ), write( "
" ), + write("(@desc \""), write( "\" )"), + write_doc_args( Arit ), +% write( "
)
" ), + write( "
" ), + write("(@return \""), write( "\") ) "), +!. + + +make_doc_arity( _, _, _ ):- ! . + +%---- +make_tests_and_doc( Tag, Arit ):- + write( "\n
" ), + make_test_arity( 'type1' , Arit , Tag ), + make_test_arity( 'type2' , Arit , Tag ), + make_test_arity( 'type3' , Arit , Tag ), + write( "\n
\n " ), + make_doc_arity( 'type1' , Arit, Tag ), + fail , ! . +make_tests_and_doc( _Tag, _Arit ):- write( "\n
\n" ), !. + +%--- + +% try_find_types( Tag , Tag1, Tag2, Tag3 ), +% eval_tag( 'pl_tag' , _Linum, Tag2, _F ), + +try_find_metta_elsewhere( Tag, Ontol_1 ):- retractall( tel(_)) , assert( tel( 0 ) ), + + write( "\n
" ), + % eval_tag( 'metta_tag_extra' , Linum, Tag, Fn, Lx ), + eval_tag_or_similar_category( Ontol_1, Linum, Tag, Fn, Lx , From_similar , Is_similar ), + incr( N2 ), N2 < 10 , + number_string( N2, S2 ), + write( "\n
"), write( S2 ), write( " " ), write_similar_to( Is_similar, Tag, From_similar ), + write( " Metta file: " ), write( Fn ), write( " " ), write( Linum ), write( "
\n" ), + enlarge_tag( Is_similar, Tag, From_similar, Lx, Lx2 ), + % str_replace_tag(At, Repwhat, RepWith, Resu) + write_metta_clause( Lx2 ), + fail, !. +try_find_metta_elsewhere( _Tag , _ ):- write( "\n
\n" ), !. + + + + +show_tags_which_dont_have_tests():- retractall( tel_item(_)), assert( tel_item( 0 )), + write( "TAGS ONTOLOGY
\n" ), + eval_tag_found( 'metta_ontol_pl', Tag , Tag1, Tag2, Tag3 ,_), + incr_item( N2 ), number_string( N2, S2 ), + write( S2 ), write( " " ), write( Tag ), write( " " ), write( Tag1 ), write( " " ), write( Tag2 ), + write( " " ), write( Tag3 ), + write( "
\n" ), fail, !. + + + +show_tags_which_dont_have_tests():- retractall( tel_item(_)), assert( tel_item( 0 )), + write( " THESE TAGS have Tests here
\n" ), + + findall( Tag2, eval_tag( 'pl_tag' , _Linum, Tag2, _F, _ , _ ), Taglis ), sort( Taglis, Taglis2 ), + % write_term( Taglis2, [] ), nl, + member( Tag, Taglis2 ), + % doesnt_have_metta_tag( Tag ), + eval_tag( 'metta_tag' , Linum, Tag, F, Lx, Arit ), number_string( Arit, Arit_s ), + + incr_item( N2 ), number_string( N2, S2 ), + write( S2 ), write( " " ), write( Tag ), write( " " ), write( Arit_s ), write( " " ), + write( F ), write( " line : " ), write( Linum ), write( "
\n" ), + write( Lx ), write( "
\n" ), + + try_find_types( Tag , Ontol1, Ontol2, Ontol3 ), + write( Ontol1 ), write( " " ), write( Ontol2 ), write( " " ), write( Ontol3 ), + fail, !. + + +show_tags_which_dont_have_tests():- retractall( tel_item(_)), assert( tel_item( 0 )), +% write( "

TAGS Which dont have Tests in sanity directory


\n" ), + write( "

TAGS identified in current mettalog prolog-implementation interpreter


\n" ), + findall( Tag2, eval_tag( 'pl_tag' , _Linum, Tag2, _F, _ , _), Taglis ), + + sort( Taglis, Taglis2 ), + % write_term( Taglis2, [] ), nl, + member( Tag, Taglis2 ), + eval_tag( 'pl_tag' , _, Tag, _, Lx , Arit ), number_string( Arit, Arit_s ), + % doesnt_have_metta_tag( Tag ), + write( "
\n" ), + incr_item( N2 ), number_string( N2, S2 ), + write( S2 ), write( " " ), write( Tag ), write( " Arity: " ), write( Arit_s ), write( " " ), + write( "
\n " ) , write( Lx ), write( "
\n " ), + make_tests_and_doc( Tag, Arit ), + try_find_types( Tag , Ontol1, Ontol2, Ontol3 ), + % eval_tag_found( 'metta_ontol_pl', Tag_s , Tag1, Tag2, Tag3 ) + write( Ontol1 ), write( " " ), write( Ontol2 ), + write( " " ), write( Ontol3 ), + try_find_metta_elsewhere( Tag , Ontol1 ), + % , Fn, Linum , Line_s + % write( "\n
Metta elsewhere: " ), write( Fn ), write( " " ), write( Linum ), write( " " ), write( Line_s ), + + fail, !. + + +show_tags_which_dont_have_tests():- !. + + + +%--- +:- dynamic tel_item/1. + +incr_item( N2 ):- retract( tel_item( N ) ),!, N2 is N + 1, assert( tel_item( N2 ) ). + +:- dynamic tel/1. + +incr( N2 ):- retract( tel( N ) ),!, N2 is N + 1, assert( tel( N2 ) ). + + +show_identified_eval_secondary_tags():- + write( "

Secondary Tags identified


" ), nl, + write( "\n
" ), + eval_tag_secondary( _, Tag ), + write( " -" ), write( Tag ), write( "- " ), write( "
\n" ), fail,!. +show_identified_eval_secondary_tags():- write( "\n
\n" ), !. +%--- + +show_identified_eval_tags( Type ):- retractall( tel_item(_)), assert( tel_item( 0 )), + findall( Tagx, eval_tag( Type , _, Tagx, _ ,_ , _), Tagx_list ), sort( Tagx_list, Tagx_list2 ), + write( "

Tags identified

"), write( Type ), + write("
" ), nl, + write( "\n
" ), + member( El, Tagx_list2 ), + eval_tag( Type , Linum, El, F ,_ , _ ), + incr_item( N2 ), number_string( N2, S2 ), + write( " " ), write( S2 ), write( " " ), write( El ), write( " " ), write( Linum ), write( " " ), + write( F ), + write( "
\n" ), fail,!. + +show_identified_eval_tags( _ ):- write( "\n
\n" ), !. + %---- fresults_par_file( Display_per_file_or_per_tag, Lp2, Lp, Fnx, Filepath , _Zk ):- + write_copy_link( Filepath, Fnx ), write( "\n
Open " ), nl, write( "\n Close " ), nl, write( "\n
" ), nl, - nondeterm_found_search_result( Display_per_file_or_per_tag, Filepath, TxLine1, Txtline, Filewithpath ), - + nondeterm_found_search_result( Display_per_file_or_per_tag, Filepath, TxLine1, Txtline, Filewithpath , Lnum ), + file_name_extension( _, Ext, Filewithpath ), color_for_file_type( Filewithpath, Htm_color_string ), write( "
" ), - show_file_also( Display_per_file_or_per_tag, Filewithpath ), - - write_line_with_tag_colors( TxLine1, Txtline ), + show_file_also( Display_per_file_or_per_tag, Filewithpath , Lnum ), + make_used_tag_bold( TxLine1, Txtline , TxLine2 ), + %concat( Zk, "", Zk2 ), concat( "", Zk2, C1 ), concat( C1, "", C2 ), + %str_replace_tag( Head2, Zk2, C2, Resu ), + % write_line_with_tag_colors( '', " ajjahsgdfgfgf ffhhfh fhfhfhh ffhhf", "ffhh" ). + % % string_length( Zk, Lx ), Lx > 0, + % write( "
" ) , + + write_line_with_tag_colors( Ext, TxLine2 ), + % , Txtline -% write( " " ), write( Txtline ), write( " " ), write( "
\n" ), - write( " " ), write( Txtline ), write( " " ), write( "
\n" ), - string_length( Txtline, Lex ), if_small_no_newline( Lex ) , + % write( " " ), write( Txtline ), write( " " ), write( "
\n" ), + % write( " " ), write( Txtline ), write( " " ), + % write( "
\n" ), + % string_length( Txtline, Lex ), + % if_small_no_newline( Lex ) , write( "
" ), fail, ! . @@ -798,23 +1416,28 @@ display_metta_sresults( 'display_per_file', _Zk, _Dirx ):- retractall( per_file( _ ) ) , - found_search_result( _, _, Fpz, _, _ ), not( per_file( Fpz ) ), assert( per_file( Fpz ) ), fail. + found_search_result( _,_,_, _, Fpz, _ ), not( per_file( Fpz ) ), assert( per_file( Fpz ) ), fail. display_metta_sresults( 'display_per_file', Zk, _Dirx ):- findall( Fpz, per_file( Fpz ), Fpzl ), member( File_with_path, Fpzl ), file_characteristics( File_with_path , Fnx , Lp, Lpx2 , Dir ), write( "\n
 
\n" ), write( "\n
 
\n" ), nl,nl,nl, write( "***" ), write( " " ), write( Fnx ), write( "       " ), write( Lp ), write( "       " ), write( Lpx2 ), nl, write( Dir ), nl, - fresults_par_file( 'display_per_file', Lpx2, Lp, Fnx, File_with_path, Zk ), fail, !. + fresults_par_file( 'display_per_file', Lpx2, Lp, Fnx, File_with_path, Zk ), + fail, !. display_metta_sresults( 'display_per_tag', _Zk, _Dirx ):- retractall( per_file( _ ) ) , - found_search_result( _, _, _Fpz, _, Tag ), not( per_file( Tag ) ), assert( per_file( Tag ) ), fail. + found_search_result( _,Tag, _, _, _Fpz, _ ), not( per_file( Tag ) ), assert( per_file( Tag ) ), fail. display_metta_sresults( 'display_per_tag', Zk, _Dirx ):- findall( Fpz, per_file( Fpz ), Tags0 ), sort( Tags0, Tags ), member( Tag, Tags ), write( "\n
 
\n" ), write( "\n
 
\n" ), nl,nl,nl, write( "***" ), write( " " ), write( Tag ), write( " " ), fresults_par_file( 'display_per_tag', '', '', '', Tag, Zk ), fail, !. +% display_metta_sresults( _, _, _ ):- +% show_identified_eval_tags(), +% show_identified_eval_secondary_tags(), fail, !. + % display_metta_sresults( _, _ ):- write(""), !. display_metta_sresults( _, _, _ ):- write(" "), !. @@ -843,24 +1466,109 @@ numspace(Tel):- Tel > 0, !, write(" "), Tel2 is Tel - 1, numspace(Tel2). numspace(_):- !. + %concat( Zk, "", Zk2 ), concat( "", Zk2, C1 ), concat( C1, "", C2 ), + %str_replace_tag( Head2, Zk2, C2, Resu ), + % write_line_with_tag_colors( '', " ajjahsgdfgfgf ffhhfh fhfhfhh ffhhf", "ffhh" ). +% % string_length( Zk, Lx ), Lx > 0, +% write( "
" ) , + +write_codes_metta_clause_htm( [] , _Parenthesis_level ):- !. + +write_codes_metta_clause_htm( [ 45, 62 | Codes ] , Parenthesis_level ):- !, + write( "
" ) , write( "->" ), write( "
" ) , + write_codes_metta_clause_htm( Codes , Parenthesis_level ). + +%write_codes_metta_clause_htm( [ 61 | Codes ] , Parenthesis_level ):- !, +% write( "
"), write( "=" ), write( "
" ) , +% write_codes_metta_clause_htm( Codes , Parenthesis_level ). + +%write_codes_metta_clause_htm( [ 58 | Codes ] , Parenthesis_level ):- !, +% write( "
"), write( ":" ), write( "
" ) , +% write_codes_metta_clause_htm( Codes , Parenthesis_level ). + +write_codes_metta_clause_htm( [ Co , Co2 | Codes ] , Parenthesis_level ):- Co == 40, Parenthesis_level == 0 , + ( Co2 == 61; Co2 == 58 ), !, + write( "
" ) , write( "(" ), + write( "
" ) , + string_codes( Zx, [ Co2 ] ), + write( "
" ) , write( Zx ), + write( "
" ) , + + Parenthesis_level2 is Parenthesis_level + 1, + write_codes_metta_clause_htm( Codes , Parenthesis_level2 ). + + +write_codes_metta_clause_htm( [ Co | Codes ] , Parenthesis_level ):- Co == 40, !, + write( "
" ) , numspace( Parenthesis_level ), write( "(" ), + write( "
" ) , Parenthesis_level2 is Parenthesis_level + 1, + write_codes_metta_clause_htm( Codes , Parenthesis_level2 ). + +write_codes_metta_clause_htm( [ Co | Codes ] , Parenthesis_level ):- Co == 41, !, + Parenthesis_level2 is Parenthesis_level - 1, + write( "
" ) , write( ")   " ), write( "
" ) , + write_codes_metta_clause_htm( Codes , Parenthesis_level2 ). +write_codes_metta_clause_htm( [ Co | Codes ] , Parenthesis_level ):- Co == 10, !, + write( "
"), write_codes_metta_clause_htm( Codes , Parenthesis_level ). -write_line_with_tag_colors( Head2, Zk ):- - concat( Zk, "", Zk2 ), concat( "", Zk2, C1 ), concat( C1, "", C2 ), - str_replace_tag(Head2, Zk2, C2, Resu), - write(Resu ), !. +write_codes_metta_clause_htm( [ H | Codes ], Plevel ):- !, string_codes( Zx, [ H ] ), write( Zx ), write_codes_metta_clause_htm( Codes , Plevel ). -write_line_with_tag_colors( Head2, _Zk ):- write( Head2 ). +%---- +write_codes_with_tag_colors( _Ext, [] ):-!. +write_codes_with_tag_colors( Ext, [ H | Codes ] ):- H == 40, !, string_codes( Zx, [ H ] ), + write( "
" ) , write( Zx ), + write( "
" ) , write_codes_with_tag_colors( Ext, Codes ). + +write_codes_with_tag_colors( Ext, [ H | Codes ] ):- H == 41, !, string_codes( Zx, [ H ] ), + write( "
" ) , write( Zx ), + write( "
" ) , write_codes_with_tag_colors( Ext, Codes ). + +write_codes_with_tag_colors( Ext, [ H | Codes ] ):- !, string_codes( Zx, [ H ] ), write( Zx ), + write_codes_with_tag_colors( Ext, Codes ). + + +% sub_string( Txt, Pos, Len, Aft, "(" ) , +% sub_string( Txt, 0, Pos, _, Begin ), Y is Pos + Len, +% sub_string( Txt, Y, Aft, 0, Rest_string ), !, +% write( Begin ) , + % write( "
" ) , write( "(" ), write( "
" ) , + % write( "
" ) , write( "(" ), write( "
" ) , +% write_line_with_tag_colors( Ext, Rest_string ). + +make_used_tag_bold( TxLine1, Zk , Cat2 ):- + string_lower( TxLine1, Txlow ) , string_lower( Zk, Zk_low ) , + sub_string( Txlow , Sta, Le, Aft , Zk_low ), + concat( Zk, "", Zk2 ), concat( "
" , Zk2, C1 ), concat( C1, "
" , C2 ), + sub_string( TxLine1 , 0, Sta, _ , Begin ), + Y is Sta + Le, + sub_string( TxLine1 , Y, Aft, _ , Rest ), + string_concat( Begin, C2, Cat1 ), + string_concat( Cat1, Rest, Cat2 ), !. + + % str_replace_tag( TxLine1 , Zk, C2, Txtline2 ), !. +make_used_tag_bold( Tx, _Zk , Tx ):- !. + % write_line_with_tag_colors( '', " ajjahsgdfgfgf ffhhfh fhfhfhh ffhhf", "ffhh" ). + % % string_length( Zk, Lx ), Lx > 0, + % write( "
" ) , +write_line_with_tag_colors( Ext, Txt ):- !, + string_codes( Txt, Codes ), + write_codes_with_tag_colors( Ext, Codes ). +% write_line_with_tag_colors( _Ext, Txt ):- write( Txt ). %---- -search_prolog_files( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Isleading ):- !, +search_prolog_files( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Isleading ):- + read_files_dir( 'prolog_source_dir', Sdir ), !, retractall( chercher_a( _ ) ), assert( chercher_a( "eval_20&:-" ) ), + retractall( current_file_extension( _ ) ), assert( current_file_extension( '.pl' ) ), - retractall( singularity_src_dir_perform( _ ) ), assert( singularity_src_dir_perform( '../canary/' ) ), + retractall( singularity_src_dir_perform( _ ) ), + + % assert( singularity_src_dir_perform( '../canary/' ) ), + assert( singularity_src_dir_perform( Sdir ) ), singularity_src_dir_perform( Dirx_zz_00 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_00 ), sleep(2), write(" start read files \n"), write("\n
 
\n"), @@ -869,42 +1577,120 @@ retractall( found_include_file( _, _, _, _, _, _, _, _, _, _, _ )), consult( Xfi ), write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), - read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, 'dummy_001', 0 , Isleading ), - read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, 'dummy_001', 1, Isleading ). - + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, 'dummy_001', 0 , Isleading ), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, 'dummy_001', 1, Isleading ). +search_prolog_files( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi , _Isleading ):- !. %-- + % assert( singularity_src_dir_perform( '../../tests/baseline_compat/' ) ), + % assert( singularity_src_dir_perform( '../../tests/' ) ), search_metta_files( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, Isleading ):- + read_files_dir( 'search_metta_files_dir', Sdir ), !, retractall( chercher_a( _ ) ), assert( chercher_a( "assertEqual" ) ), retractall( current_file_extension( _ ) ), assert( current_file_extension( '.metta' ) ), retractall( singularity_src_dir_perform( _ ) ), - assert( singularity_src_dir_perform( '../../tests/baseline_compat/hyperon-mettalog_sanity/' ) ), + assert( singularity_src_dir_perform( Sdir ) ), singularity_src_dir_perform( Dirx_zz_2 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_2 ), sleep(2), write(" start read files \n"), write("\n
 
\n"), retractall( dir_level( _, _, _, _, _, _, _, _, _, _) ), retractall( file_level(_, _, _, _, _, _, _, _, _, _, _) ), consult( Xfi ), write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), - read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 0 , Isleading), - read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 1 , Isleading). + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 0 , Isleading), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 1 , Isleading). +search_metta_files( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi, _Isleading ):- !. + +search_metta_files_else_where( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, _Isleading ):- + read_files_dir( 'search_metta_files_else_where_dir', Sdir ), !, + retractall( chercher_a( _ ) ), assert( chercher_a( "assertEqual" ) ), + retractall( current_file_extension( _ ) ), assert( current_file_extension( '.metta' ) ), + retractall( singularity_src_dir_perform( _ ) ), + assert( singularity_src_dir_perform( Sdir ) ), + singularity_src_dir_perform( Dirx_zz_2 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_2 ), sleep(2), + write(" start read files \n"), write("\n
 
\n"), + retractall( dir_level( _, _, _, _, _, _, _, _, _, _) ), retractall( file_level(_, _, _, _, _, _, _, _, _, _, _) ), + consult( Xfi ), + write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 0 , metta_else_where ), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 1 , metta_else_where ). +search_metta_files_else_where( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi, _Isleading ):- !. + + + +search_metta_files_std_lib( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, _Isleading ):- + read_files_dir( 'metta_std_lib_dir', Sdir ), !, + retractall( chercher_a( _ ) ), assert( chercher_a( "assertEqual" ) ), + retractall( current_file_extension( _ ) ), assert( current_file_extension( '.metta' ) ), + retractall( singularity_src_dir_perform( _ ) ), + % canary +% assert( singularity_src_dir_perform( '../../tests/extended_compat/metta-examples/' ) ), + + % assert( singularity_src_dir_perform( '../canary/' ) ), + assert( singularity_src_dir_perform( Sdir ) ), + singularity_src_dir_perform( Dirx_zz_2 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_2 ), sleep(2), + write(" start read files search_metta_files_std_lib \n"), write("\n
 
\n"), + retractall( dir_level( _, _, _, _, _, _, _, _, _, _) ), retractall( file_level(_, _, _, _, _, _, _, _, _, _, _) ), + consult( Xfi ), + write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 0 , metta_std_lib ), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 1 , metta_std_lib ). +search_metta_files_std_lib( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi, _Isleading ):- !. + + + + + % assert( singularity_src_dir_perform( '../../tests/extended_compat/' ) ), + % assert( singularity_src_dir_perform( '../../tests/features/' ) ), + % \\wsl.localhost\Ubuntu\home\drspro\metta-wam\tests\extended_compat\metta-examples + % assert( singularity_src_dir_perform( '../../tests/baseline_compat/hyperon-mettalog_sanity/' ) ), + % assert( singularity_src_dir_perform( '../../tests/baseline_compat/' ) ), + + +search_metta_files2( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, Isleading ):- + read_files_dir( 'examples_source_dir', Sdir ), !, + retractall( chercher_a( _ ) ), assert( chercher_a( "assertEqual" ) ), + retractall( current_file_extension( _ ) ), assert( current_file_extension( '.metta' ) ), + retractall( singularity_src_dir_perform( _ ) ), + + % assert( singularity_src_dir_perform( '../../../metta-examples-main/' ) ), + assert( singularity_src_dir_perform( Sdir ) ), + singularity_src_dir_perform( Dirx_zz_2 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_2 ), sleep(2), + write(" start read files \n"), write("\n
 
\n"), + retractall( dir_level( _, _, _, _, _, _, _, _, _, _) ), retractall( file_level(_, _, _, _, _, _, _, _, _, _, _) ), + consult( Xfi ), + write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 0 , Isleading), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_2, 1 , Isleading). +search_metta_files2( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi, _Isleading ):- !. + + search_metta_files_hyperon( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, Isleading ):- + read_files_dir( 'metta_python_source_dir', Sdir ), !, retractall( chercher_a( _ ) ), assert( chercher_a( "assertEqual" ) ), retractall( current_file_extension( _ ) ), assert( current_file_extension( '.metta' ) ), - retractall( singularity_src_dir_perform( _ ) ), assert( singularity_src_dir_perform( '../../../hyperon-experimental/python/' ) ), + retractall( singularity_src_dir_perform( _ ) ), + + % assert( singularity_src_dir_perform( '../../../hyperon-experimental/python/' ) ), + assert( singularity_src_dir_perform( Sdir ) ), singularity_src_dir_perform( Dirx_zz_3 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_3 ), sleep(2), write(" start read files \n"), write("\n
 
\n"), retractall( dir_level( _, _, _, _, _, _, _, _, _, _) ), retractall( file_level(_, _, _, _, _, _, _, _, _, _, _) ), consult( Xfi ), write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), - read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_3, 0 , Isleading), - read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_3, 1 , Isleading). + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_3, 0 , Isleading), + read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_3, 1 , Isleading). +search_metta_files_hyperon( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi, _Isleading ):- !. search_python_files_hyperon( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, Isleading ):- + read_files_dir( 'python_source_dir', Sdir ), !, retractall( chercher_a( _ ) ), assert( chercher_a( "assertEqual" ) ), retractall( current_file_extension( _ ) ), assert( current_file_extension( '.py' ) ), - retractall( singularity_src_dir_perform( _ ) ), assert( singularity_src_dir_perform( '../../../hyperon-experimental/python/' ) ), + retractall( singularity_src_dir_perform( _ ) ), + +% assert( singularity_src_dir_perform( '../../../hyperon-experimental/python/' ) ), + assert( singularity_src_dir_perform( Sdir ) ), singularity_src_dir_perform( Dirx_zz_4 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_4 ), sleep(2), write(" start read files \n"), write("\n
 
\n"), retractall( dir_level( _, _, _, _, _, _, _, _, _, _) ), retractall( file_level(_, _, _, _, _, _, _, _, _, _, _) ), @@ -912,33 +1698,78 @@ write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_4, 0 , Isleading), read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_4, 1 , Isleading). - +search_python_files_hyperon( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi, _Isleading ):- !. search_rust_files_hyperon( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, Isleading ):- + read_files_dir( 'hyperon_source_dir', Sdir ), !, retractall( chercher_a( _ ) ), assert( chercher_a( "assertEqual" ) ), retractall( current_file_extension( _ ) ), assert( current_file_extension( '.rs' ) ), - retractall( singularity_src_dir_perform( _ ) ), assert( singularity_src_dir_perform( '../../../hyperon-experimental/' ) ), + retractall( singularity_src_dir_perform( _ ) ), + % assert( singularity_src_dir_perform( '../../../hyperon-experimental/lib/src/' ) ), + assert( singularity_src_dir_perform( Sdir ) ), singularity_src_dir_perform( Dirx_zz_5 ), get_all_singularity_files( Tp, MdfKeyaft, Dirx_zz_5 ), sleep(2), write(" start read files \n"), write("\n
 
\n"), retractall( dir_level( _, _, _, _, _, _, _, _, _, _) ), retractall( file_level(_, _, _, _, _, _, _, _, _, _, _) ), consult( Xfi ), write( "Consulted\n" ), write( Xfi ), nl, write( "\n
 
\n" ), +% read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_5, 0 , Isleading), +% read_all_singularity_files( is_octet, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_5, 1 , Isleading). read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_5, 0 , Isleading), read_all_singularity_files( is_utf8, Tp, Zk, only_copy_files, Is_mk_update, Dirx_zz_5, 1 , Isleading). +search_rust_files_hyperon( _Tp, _Dk, _Zk, _MdfKeyaft, _Is_mk_update, _Xfi, _Isleading ):- !. + %--- short_code_metta( include_metta_files, 'inc' ):-!. short_code_metta( _Inc_Metta, 'notinc' ):-!. +%---- +% CENTRAL ALL DIRS + read_files_dir( 'hyperon_source_dir', '../../../hyperon-experimental/lib/src/' ). + + read_files_dir( 'prolog_source_dir', '../canary/' ). + read_files_dir( 'metta_std_lib_dir', '../canary/' ). + +% the se 2 should not be the same or contain eachother + + read_files_dir( 'search_metta_files_dir', '../../tests/' ). + + + read_files_dir( 'search_metta_files_else_where_dir', '../../tests/extended_compat/metta-examples/' ). + read_files_dir( 'examples_source_dir', '../../../metta-examples-main/' ). + + read_files_dir( 'python_source_dir', '../../../hyperon-experimental/python/' ). + read_files_dir( 'metta_python_source_dir', '../../../hyperon-experimental/python/' ). + + %--- -also_search_metta_files( include_metta_files , Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi ):- + +also_search_metta_files( include_metta_files , Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi ):- !, + + % TEMP + write( "Phase- metta STDLIB files" ), nl, + search_metta_files_std_lib( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), + +% If these directorys are equal then only one of them should be performed search_metta_files( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), - search_metta_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), !. + search_metta_files_else_where( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), + + % TEMP + search_metta_files2( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), + + + !. +% search_metta_files_else_where( Tp, _Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, _Isleading ), + +% TEMP +% search_metta_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), !. + + also_search_metta_files( _, _,_,_, _,_,_ ):- !. %-- % ( i -search_all_files_with_leading( 'prolog_leading', Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Inc_Metta ):- +search_all_files_with_leading( 'prolog_leading', Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Inc_Metta ):- !, search_prolog_files( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_leading ), search_python_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), search_rust_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), @@ -950,7 +1781,7 @@ !. -search_all_files_with_leading( 'python_leading', Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Inc_Metta ):- +search_all_files_with_leading( 'python_leading', Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Inc_Metta ):- !, search_python_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_leading ), search_prolog_files( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), search_rust_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), @@ -959,13 +1790,25 @@ %search_metta_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), !. -search_all_files_with_leading( 'rust_leading' , Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Inc_Metta ):- - search_rust_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_leading ), +search_all_files_with_leading( 'rust_leading' , Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Inc_Metta ):- !, + % + + write("Phase- python"), nl, + search_python_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_leading ), + + + +% write("Phase-1"), nl, + read_rustfile_tags( '../../../hyperon-experimental/lib/src/metta/runner/stdlib.rs' ), + search_rust_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), + write("Phase-PROLOG"), nl, search_prolog_files( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), - search_python_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), + + write("Phase-metta files"), nl, also_search_metta_files( Inc_Metta, Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi ), - %search_metta_files( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), - %search_metta_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), + + %*search_metta_files( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), + %*search_metta_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), !. @@ -974,58 +1817,359 @@ % search_metta_files_hyperon( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi, is_not_leading ), -reset_htm( Display_per_file_or_per_tag, LeadingTag, Inc_Metta, Htmfile ):- +reset_htm( _Display_per_file_or_per_tag, _LeadingTag, _Inc_Metta, Htmfile ):- tell( Htmfile ), + get_time( TimeStamp ), write("\n \n"), write("\n \n"), write("\n \n"), + write("\n \n"), write("\n \n"), - - write("

\n"), write( Inc_Metta ), write("

\n"), - write("

\n"), write( Display_per_file_or_per_tag ), write("

\n"), - write("

\n"), write( LeadingTag ), write("

\n"), + write("

\n Time "), write( TimeStamp ), write("

\n"), + %write("

\n"), write( Inc_Metta ), write("

\n"), + %write("

\n"), write( Display_per_file_or_per_tag ), write("

\n"), + %write("

\n"), write( LeadingTag ), write("

\n"), told(). %--- +find_tags( Tag , Tg1 , Tg2 , Tg3 ):- + eval_tag_found( 'metta', Tag , Tg1 , Tg2 , Tg3 ,_) , !. -display_tags_not_found():- - eval_tag_found( Tag ), retract( eval_tag( Tag ) ), fail , !. +find_tags( _Tag , "cantf1", "cantf2", "cantf3" ):-!. +% eval_tag_found( 'metta', Tag , Tg1 , Tg2 , Tg3 ) , + + +%display_tags_not_found():- +% eval_tag_found( Tag ), retract( eval_tag( Tag ) ), fail , !. +%display_tags_not_found():- +% write( "@DOC-tag not found - uncovered / created default
" ), nl, +% eval_tag( _, Tag, _ ), +% not( eval_tag_found( 'metta_doc', Tag, _ , _ , _ ) ), +% write( " Default @doc code : " ) , write( Tag ), write( "
" ), nl, fail, !. + + +tag_types( 'rust' ). +tag_types( 'python' ). +tag_types( 'metta_ontol_pl' ). +tag_types( 'metta_example' ). +tag_types( 'metta' ). +tag_types( '' ). + + display_tags_not_found():- - write( "Tags not found - uncovered
" ), nl, - eval_tag( Tag ), - write( " " ) , write( Tag ), write( "
" ), nl, fail, !. + write( "@METTA-example TAGS
" ), nl, + tag_types( Type ), + nl, write("
"), write( Type ) , nl, +% eval_tag( _, Tag, _ ), +% write( "
" ), nl, +% write( " Default metta example : -" ) , write( Tag ), write( "- "), + eval_tag_found( Type , Tag , _ , _ , _ ,_) , +% write(" not FOUND "), + nl, write("
"), write( Type ) , write( " " ), write( Tag ), nl, + fail, !. + + % write( Tg1 ), write( " " ), write( Tg2 ), write( " " ), write( Tg3 ), + +% find_tags( Tag , Tg1 , Tg2 , Tg3 ), +% eval_tag_found( 'metta', Tag , Tg1 , Tg2 , Tg3 ) , + + +%display_tags_not_found():- +% write( "Tags not found - uncovered
" ), nl, +% eval_tag( _, Tag, _ ), + +% not( eval_tag_found( _, Tag ) ), +% write( " " ) , write( Tag ), write( "
" ), nl, fail, !. + display_tags_not_found():- !. +%--- +% i,o,o +get_tag_properties( Tag, "yes", "yes" ):- eval_tag( 'rust', _, Tag, _ , _ , _), eval_tag( 'pl_tag', _, Tag, _ , _ , _), !. +get_tag_properties( Tag, "yes", "" ):- eval_tag( 'rust', _, Tag, _ , _ , _), !. +get_tag_properties( Tag, "", "yes" ):- eval_tag( 'pl_tag', _, Tag, _ , _ , _), !. +get_tag_properties( _El, "", "" ):-!. + +write_cell( Tag ):- write( "" ), write( Tag ), write( "" ), !. + +write_cell_pre( Tag ):- write( "
" ),      write( Tag ),     write( "
" ), !. + +write_head( Tag ):- write( "" ), write( Tag ), write( "" ), !. + + + + +%--- +sequence_of_tags( Prolog_and_rust, Rustonly, Prologonly ):- + findall( Tag, eval_tag( 'rust', _, Tag, _ , _ , _), Taglis1 ), + findall( Tag2, eval_tag( 'pl_tag', _, Tag2, _ , _ , _), Taglis2 ), + intersection( Taglis1, Taglis2, Prolog_and_rust0 ), sort( Prolog_and_rust0, Prolog_and_rust ), + subtract( Taglis1, Taglis2, Rustonly0 ), sort( Rustonly0, Rustonly ), + subtract( Taglis2, Taglis1, Prologonly0 ), sort( Prologonly0, Prologonly ). + + + + +% append( Taglis1, Taglis2, Taglis3 ), sort( Taglis3, Taglis4 ), +% member( El, Taglis4 ), + +% found_search_result(metta_example, +% "match",1,3,'../ +% eval_tag(metta_tag_std_lib,1348,"format-args",'../canary/stdlib_me +% eval_tag(metta_example,58,"let*",'../../tests/baseline_compat/hyp +:- dynamic tag_for_table/1. + +set_tags_for_table():- retractall( tag_for_table( _ ) ), + sequence_of_tags( Prolog_and_rust, Rustonly, Prologonly ), + append( Prolog_and_rust, Rustonly, C1 ), append( C1, Prologonly, Taglis4 ), + member( El_tag, Taglis4 ), assert( tag_for_table( El_tag ) ), fail, !. +set_tags_for_table():- !. + + +find_has_metta_doc( El_tag , "has @doc" ):- eval_tag( metta_tag_std_lib, _, El_tag , _F, _Str, _ ),!. +find_has_metta_doc( _El_tag , " NO @doc" ):- !. + +find_has_metta_type_doc( El_tag , "has type @doc" , Str ):- eval_tag( metta_tag_std_lib, _, El_tag , _F, Str, _ ), + sub_string( Str, _ , _ , _ , "(: "), ! . + +find_has_metta_type_doc( _El_tag , " No type @doc" , " No type @doc" ):- !. + +% metta_function_declaration + +% is_metta +%--- +% 'rust' +show_read_files_dir():- + read_files_dir( Tp, Dir ), write( Tp ), write(" "), write( Dir ), write("
"), nl, fail, !. +show_read_files_dir():- write("
 
"), !. + + +% eval_tag( 'rust', Linum, Taglow, F , Sline , Ari) +% eval_tag( 'rust', Linum, Taglow, F , Sline , Ari) + %only_small_number_of_occurences_display( Num_oc, Files_list_s0, Files_list_s ), + %only_small_number_of_occurences_display( Num_oc2, Files_list_s02, Files_list_s2 ), +% find_metta_test_occurences( El_tag, Numberof_s, _Files_list ), + +write_csv_val( Sx ) :- str_code_remove( Sx, 39, Sx2 ), + str_code_remove( Sx2, 91, Sx3 ), str_code_remove( Sx3, 93, Sx4 ), + str_code_remove( Sx4, 60, Sx5 ), str_code_remove( Sx5, 62, Sx6 ), + str_code_remove( Sx6, 47, Sx7 ), + str_code_remove( Sx7, 40, Sx8 ), str_code_remove( Sx8, 41, Sx9 ), str_code_remove( Sx9, 58, Sx10 ), + str_code_remove( Sx10, 59, Sx11 ), + write( Sx11 ). + +write_csv_cols( [] ):- !. +write_csv_cols( [ H ] ):- !, write_csv_val( H ) . +write_csv_cols( [ H | Rest ] ):- !, write_csv_val( H ), write( ";" ), write_csv_cols( Rest ). + + +make_rust_prolog_table():- show_read_files_dir(), + write( "" ), + retractall( tel(_)) , assert( tel( 0 ) ), write( "" ), + write_head( " " ), write_head( "function" ), write_head( "Rust" ), write_head( "Prolog" ), + write_head( "Occurs in metta-files" ), write_head( "Has metta-files" ), + write_head( "Has @doc" ), write_head( "@doc TYPE decl" ), + write_head( "Num of metta-test" ), write_head( "Has metta-testf" ), + write( "" ), tag_for_table( El_tag ), is_metta_function( El_tag ), + incr( Count ), number_string( Count, Sx ), + get_tag_properties( El_tag, Hasrust, Hasprolog ), + get_tag_occurences( El_tag , _Num_oc, Occurences_string , Files_list_s ), + get_tag_occurences_test( El_tag , _Num_oc2, Occurences_string2 , Files_list_s2 ), + find_has_metta_doc( El_tag , Has_doc_s ), + find_has_metta_type_doc( El_tag , _Has_tdoc_s , Type_descr ), + write( "" ), write_cell( Sx ), + write_cell( El_tag ), write_cell( Hasrust ), write_cell( Hasprolog ), + write_cell( Occurences_string ), write_cell( Files_list_s ), + write_cell( Has_doc_s ), write_cell_pre( Type_descr ), write_cell( Occurences_string2 ), write_cell( Files_list_s2 ), + write( "" ), fail, !. +make_rust_prolog_table():- write( "
" ), !. + + +make_rust_prolog_csv():- + retractall( tel(_)) , assert( tel( 0 ) ), + write_csv_cols( [ "num" , "function" , "Rust" , "Prolog" , "Occurs in metta-files" , "Has metta-files" , + "Has @doc" , "@doc TYPE decl" , "Num of metta-test" , "Has metta-testf" ]), write("\r"), nl, + + + tag_for_table( El_tag ), is_metta_function( El_tag ), + incr( Count ), number_string( Count, Sx ), + get_tag_properties( El_tag, Hasrust, Hasprolog ), + get_tag_occurences( El_tag , _Num_oc, Occurences_string , Files_list_s ), + get_tag_occurences_test( El_tag , _Num_oc2, Occurences_string2 , Files_list_s2 ), + find_has_metta_doc( El_tag , Has_doc_s ), + find_has_metta_type_doc( El_tag , _Has_tdoc_s , Type_descr ), + write_csv_cols( [ Sx , El_tag , Hasrust , Hasprolog , Occurences_string , Files_list_s , + Has_doc_s , Type_descr , Occurences_string2 , Files_list_s2 ] ), write("\r"), nl, + fail, !. +make_rust_prolog_csv():- write( "" ), !. + + + +memory_data_to_file( Fn ):- tell( Fn ), + eval_tag( A , B , C , D , E, F ), write_term( eval_tag( A , B , C , D , E, F ), [quoted(true)] ), nl, fail. +memory_data_to_file( _Fn ):- + eval_tag_found( A , B , C , D , E, F ), write_term( eval_tag_found( A , B , C , D , E, F ), [quoted(true)] ), nl, fail. +memory_data_to_file( _Fn ):- + found_search_result( A , B , C , D , E, F ), write_term( found_search_result( A , B , C , D , E, F ), [quoted(true)] ), nl, fail. +% eval_tag_secondary/2. +memory_data_to_file( _ ):- told(), ! . + + +%--- +:- dynamic tag_occurences/3. +:- dynamic tag_occurences_test/3. + +% max_length_list( [ A,B,C|_], [A,B,C]):- !. +% max_length_list( [ A,B|_], [A,B]):- !. +max_length_list( [ A|_], [A]):- !. +max_length_list(_Files0, []):-!. + + +get_tag_occurences( Tag , Count, Sx , Files_s ):- + tag_occurences( Tag , Count, Files0 ), max_length_list(Files0, Files), number_string( Count, Sx ), term_string( Files, Files_s, [] ), !. +get_tag_occurences( _Tag , 0, "", "has no metta" ):- !. +%---- +get_tag_occurences_test( Tag , Count, Sx , Files_s ):- + tag_occurences_test( Tag , Count, Files0 ), max_length_list(Files0, Files), number_string( Count, Sx ), term_string( Files, Files_s, [] ), !. +get_tag_occurences_test( _Tag , 0, "", "has no metta test" ):- !. + +%--- +only_small_number_of_occurences_display( Num_oc, Files_list_s, Files_list_s ):- Num_oc < 6, !. +only_small_number_of_occurences_display( _Num_oc, _Files_list_s0, "" ):- !. +% only_small_number_of_occurences_display( _Num_oc, Files_list_s, Files_list_s ):-!. + +%---- + +update_tag_occurences( Tag , Count, Base ):- retract( tag_occurences( Tag , _ , Files0 ) ), !, + sort( [ Base | Files0 ], Files ), assert( tag_occurences( Tag , Count, Files ) ). +update_tag_occurences( Tag , Count, Base ):- assert( tag_occurences( Tag , Count, [Base] ) ). +%-- +update_tag_occurences_test( Tag , Count, Base ):- retract( tag_occurences_test( Tag , _ , Files0 ) ), !, + sort( [ Base | Files0 ], Files ), assert( tag_occurences_test( Tag , Count, Files ) ). +update_tag_occurences_test( Tag , Count, Base ):- assert( tag_occurences_test( Tag , Count, [Base] ) ). + +%---- + +count_tags_files_occurences():- retractall( tag_occurences( _ , _ , _ ) ) , + tag_for_table( Tag ), retractall( tel( _ ) ), assert( tel( 0 ) ), + found_search_result( metta_example , Tag, _Lev , _Line , Fn , _Str_part ), + file_base_name( Fn, Base ), file_name_extension( Base2, _Ext, Base ), + incr( Count ), update_tag_occurences( Tag , Count, Base2 ), fail, ! . +count_tags_files_occurences():- !. +%--- +count_tags_files_occurences_test():- retractall( tag_occurences_test( _ , _ , _ ) ) , + tag_for_table( Tag ), retractall( tel( _ ) ), assert( tel( 0 ) ), + found_search_result( metta_example , Tag, _Lev , _Line , Fn , Str_part ), + sub_string( Str_part, _,_,_, "assert" ), + file_base_name( Fn, Base ), file_name_extension( Base2, _Ext, Base ), + incr( Count ), update_tag_occurences_test( Tag , Count, Base2 ), fail, ! . +count_tags_files_occurences_test():- !. + + +% found_search_result(metta_example,"match",1,3,'../../tests/baseline_compat/metta-morph_tests/match_feval.metta',"!(match &self (= (f $x) $y) $y)") +% eval_tag(metta_tag_std_lib,1225,"print",'../canary/stdlib_mettalog.metta',"(@doc print-mods!\n (@desc \"Prints all modules with their correspondent spaces\")\n (@params ())\n (@return \"Unit atom\"))",0) + + +% found_search_result(metta_example, +% "match",1,3,'../ +% eval_tag(metta_tag_std_lib,1348,"format-args",'../canary/stdlib_me +% eval_tag(metta_example,58,"let*",'../../tests/baseline_compat/hyp + +% create_view_table(). +create_view_table():- !, + start_analyse( 'display_per_tag', 'rust_leading', 0, '', is_dummy_tag, include_metta_files ). + + %--- start_analyse_metta( Display_per_file_or_per_tag, LeadingTag, Tp, MdfKeyaft, Is_mk_update, _X , Inc_Metta ):- !, - retractall( eval_tag( _ ) ), - retractall( eval_tag_found( _ ) ), + retractall( eval_tag( _, _, _ , _,_ , _ ) ), + retractall( eval_tag_secondary( _ , _ ) ), + retractall( eval_tag_found( _ , _ , _ , _, _ ,_ ) ), - retractall( found_search_result( _, _, _, _, _ ) ), + retractall( found_search_result( _,_, _, _, _, _ ) ), retractall( per_file( _ ) ), % retractall( extra_string_to_search( _ ) ), % assert( extra_string_to_search( "count" ) ), - chercher_a( Zk ), today_key( Dk ), write( "today key " ), write( Dk ), Xfi = 'data/htm_file_list.pl', + % chercher_a( Zk ), + Zk = "", + today_key( Dk ), write( "today key " ), write( Dk ), Xfi = 'data/htm_file_list.pl', short_code_metta( Inc_Metta, Short_code ), atomic_list_concat([ 'result/analyse_result_', LeadingTag, '_', Display_per_file_or_per_tag, '_', Short_code, '.htm' ], Htmfile ), reset_htm( Display_per_file_or_per_tag, LeadingTag, Inc_Metta, Htmfile ), % search_all_files_with_prolog_leading( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi ), search_all_files_with_leading( LeadingTag, Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi , Inc_Metta ), % search_all_files_with_rust_leading( Tp, Dk, Zk, MdfKeyaft, Is_mk_update, Xfi ), - + memory_data_to_file( 'data/tags_data.pl' ), + set_tags_for_table(), + count_tags_files_occurences(), + count_tags_files_occurences_test(), append( Htmfile ), - display_metta_sresults( Display_per_file_or_per_tag , Zk, 'dummyxxaaq' ), - display_tags_not_found(), -% retractall( eval_tag_found( _ ) ), + +% TEMP turn off +% display_metta_sresults( Display_per_file_or_per_tag , Zk, 'dummyxxaaq' ), + + + % show_identified_eval_tags( 'rust' ), + % show_identified_eval_tags( 'pl_tag' ), + % show_identified_eval_tags( 'python' ), + % show_identified_eval_tags( 'pl_interp_tag' ), + % show_identified_eval_tags( 'metta_tag' ), + % show_identified_eval_tags( 'metta_tag_extra' ), + % show_tags_which_dont_have_tests(), + % show_identified_eval_secondary_tags(), + % display_tags_not_found(), + make_rust_prolog_table(), told(), + tell( 'result/prolog_rust.csv' ), make_rust_prolog_csv(), told(), + + retractall( eval_tag_found( _ , _ , _, _, _ ,_) ), write( "analyses result written to file: \n" ), write( Htmfile ), nl. +make_csv():- !, + tell( 'result/prolog_rust.csv' ), make_rust_prolog_csv(), told(). + test11():- atom_codes( '42 times' , Codes ), phrase( integer( X ), Codes, _Res ), @@ -1041,6 +2185,7 @@ komma --> [C], { C == 44 }. leftparenthese --> [C], { C == 40 }. leftbracket --> [C], { C == 91 }. +rightbracket --> [C], { C == 93 }. singlequote --> [C], { C == 39 }. % tag_x( foo ) --> "foo" . @@ -1049,15 +2194,46 @@ % tag_x( bar( A, B ) ) --> "bar(", whites , digits( ACodes ), whites, komma , whites, digits( BCodes ), { number_codes( A, ACodes), number_codes( B, BCodes ) }. %tag_x( bar( Vn , B ) ) --> "bar(", whites , prolog_var_name( Vn ), whites, komma , whites, digits( BCodes ), { number_codes( B, BCodes ) }. % tag_x( eval20( A , A2, A3, A4, B , X5 ) ) --> "eval_20(", whites , string( Vn ), whites, komma , whites, -tag_x( eval20( B ) ) --> "eval_20(", whites , string( Vn ), whites, komma , whites, + +%tag_x( eval20( B ) ) --> "eval_20(", whites , string( Vn ), whites, komma , whites, +% string( Vn2 ), whites, komma , whites , +% string( Vn3 ), whites, komma , whites , +% string( Vn4 ), whites, komma , whites , +% leftbracket , whites, singlequote , string( BCodes ), singlequote, whites, komma , +% string( Rest5 ), +% { string_codes( _A, Vn ), string_codes( _A2, Vn2 ), string_codes( _A3, Vn3 ), string_codes( _A4, Vn4 ), string_codes( B, BCodes ), string_codes( _X5, Rest5 ) }. + +tag_x( eval20( B , X5q ) ) --> "eval_20(", whites , string( Vn ), whites, komma , whites, + string( Vn2 ), whites, komma , whites , + string( Vn3 ), whites, komma , whites , + string( Vn4 ), whites, komma , whites , + leftbracket , whites, singlequote , string( BCodes ), singlequote, whites, komma , + string( Rest5 ), rightbracket, + string( _Rest6 ), + { string_codes( _A, Vn ), string_codes( _A2, Vn2 ), string_codes( _A3, Vn3 ), string_codes( _A4, Vn4 ), string_codes( B, BCodes ), string_codes( X5q, Rest5 ) }. + +%--- + +tag_x40( eval40( B , X5q ) ) --> "eval_40(", whites , string( Vn ), whites, komma , whites, string( Vn2 ), whites, komma , whites , string( Vn3 ), whites, komma , whites , string( Vn4 ), whites, komma , whites , leftbracket , whites, singlequote , string( BCodes ), singlequote, whites, komma , - string( Rest5 ), + string( Rest5 ), rightbracket, + string( _Rest6 ), + { string_codes( _A, Vn ), string_codes( _A2, Vn2 ), string_codes( _A3, Vn3 ), string_codes( _A4, Vn4 ), string_codes( B, BCodes ), string_codes( X5q, Rest5 ) }. - { string_codes( _A, Vn ), string_codes( _A2, Vn2 ), string_codes( _A3, Vn3 ), string_codes( _A4, Vn4 ), string_codes( B, BCodes ), string_codes( _X5, Rest5 ) }. +tag_x70( eval70( B , X5q ) ) --> "eval_70(", whites , string( Vn ), whites, komma , whites, + string( Vn2 ), whites, komma , whites , + string( Vn3 ), whites, komma , whites , + string( Vn4 ), whites, komma , whites , + leftbracket , whites, singlequote , string( BCodes ), singlequote, whites, komma , + string( Rest5 ), rightbracket, + string( _Rest6 ), + { string_codes( _A, Vn ), string_codes( _A2, Vn2 ), string_codes( _A3, Vn3 ), string_codes( _A4, Vn4 ), string_codes( B, BCodes ), string_codes( X5q, Rest5 ) }. +%:- discontiguous eval_40/6. +%:- discontiguous eval_70/6. % tag_x( quux( S ) ) --> "quux", whites, nonblanks( Codes ), { string_codes( S, Codes ) }. @@ -1065,10 +2241,27 @@ tag_list( [ Tag_token | Tags_tokens ]) --> tag_x( Tag_token ), whites, tag_list( Tags_tokens ). tag_list( [] ) --> []. -try_read_find_eval20_tag_in_string( Str , Result_tag ):- +tag_list40( [ Tag_token | Tags_tokens ]) --> tag_x40( Tag_token ), whites, tag_list40( Tags_tokens ). +tag_list40( [] ) --> []. + +tag_list70( [ Tag_token | Tags_tokens ]) --> tag_x70( Tag_token ), whites, tag_list70( Tags_tokens ). +tag_list70( [] ) --> []. + + +try_read_find_eval20_tag_in_string( Str , Result_tag, Len ):- % string_codes( "eval_20( _Zxs , Pq , _Za , Qe, ['jajaj',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Eq,RetType,CDR,CDR_Y).", Codes_x ), - string_codes( Str , Codes_x ), phrase( tag_list( Tags_tokens ), Codes_x ), Tags_tokens = [ Xres ], Xres = eval20( Result_tag ) , !. + string_codes( Str , Codes_x ), phrase( tag_list( Tags_tokens ), Codes_x ), Tags_tokens = [ Xres ], Xres = eval20( Result_tag, Rest_Args ) , + split_string( Rest_Args , ",", "" , Lis ), length( Lis, Len ), !. +try_read_find_eval20_tag_in_string( Str , Result_tag, Len ):- +% string_codes( "eval_20( _Zxs , Pq , _Za , Qe, ['jajaj',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Eq,RetType,CDR,CDR_Y).", Codes_x ), + string_codes( Str , Codes_x ), phrase( tag_list40( Tags_tokens ), Codes_x ), Tags_tokens = [ Xres ], Xres = eval40( Result_tag, Rest_Args ) , + split_string( Rest_Args , ",", "" , Lis ), length( Lis, Len ), !. + +try_read_find_eval20_tag_in_string( Str , Result_tag, Len ):- +% string_codes( "eval_20( _Zxs , Pq , _Za , Qe, ['jajaj',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Eq,RetType,CDR,CDR_Y).", Codes_x ), + string_codes( Str , Codes_x ), phrase( tag_list70( Tags_tokens ), Codes_x ), Tags_tokens = [ Xres ], Xres = eval70( Result_tag, Rest_Args ) , + split_string( Rest_Args , ",", "" , Lis ), length( Lis, Len ), !. % eval_20(Eq,RetType,_Dpth,_Slf,['cdr-atom',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Eq,RetType,CDR,CDR_Y). @@ -1078,41 +2271,60 @@ % string_codes( "eval_20( _Zxs , Pq , _Za , Qe, ['jajaj',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Eq,RetType,CDR,CDR_Y).", Codes_x ), % phrase( tag_list( Tags_tokens ), Codes_x ), % Tags_tokens = [ Xres ], Xres = eval20( Result_tag ) , !, - try_read_find_eval20_tag_in_string( "eval_20( _Zxs , Pq , _Za , Qe, ['jajaj',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Eq,RetType,CDR,CDR_Y)." , Result_tagx ), + try_read_find_eval20_tag_in_string( "eval_70( _Zxs , Pq , _Za , Qe, ['j2ajaj',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Eq,RetType,CDR,CDR_Y)." , Result_tagx, _ ), % maplist( writeln, Tags_tokens ). write_term( Result_tagx , [] ). %---- -% README HERE: USAGE: -% first consult the prolog file with this : -% [metta_analyse]. -% THEN call as below : -% Calling examples : -% start_analyse( 'display_per_file', 'python_leading', 0, '', is_dummy_tag, not_include_metta_files ). -% start_analyse( 'display_per_file', 'rust_leading', 0, '', is_dummy_tag , not_include_metta_files). -% start_analyse( 'display_per_file', 'python_leading', 0, '', is_dummy_tag , not_include_metta_files ). % HERE ALL the config color_for_file_type( Fn , "#ECED99" ):- sub_atom( Fn, _, _, _, '.metta' ), !. color_for_file_type( Fn , "#A7E3A7" ):- sub_atom( Fn, _, _, _, '.py' ), !. color_for_file_type( Fn , "#D3D4FF" ):- sub_atom( Fn, _, _, _, '.pl' ), !. -color_for_file_type( Fn , "#D89800" ):- sub_atom( Fn, _, _, _, '.rs' ), !. +color_for_file_type( Fn , "#FFD6BB" ):- sub_atom( Fn, _, _, _, '.rs' ), !. color_for_file_type( _Filewithpath, "#E7E7E7" ):- !. % we dont want all the assertEqual etc here is_metta_function( Tag ):- string_lower( Tag, Tag_lower ), sub_string( Tag_lower, _,_,_, "assert" ), !, fail. is_metta_function( "superpose" ):- !, fail. +is_metta_function( "&self" ):- !, fail. is_metta_function( Tag ):- string_length( Tag, Lex ), Lex > 3, Tag \= "eval", !. +% % { assert_equal_to_result_op.clone() }); +rust_detect_tag( "regex(r\"", "\"" , "{", ".clone(" ):- !. + +rust_metta_tag( "assert_eq!(", "" ):- !. + +python_detect_tag( "metta.run('!(", " " ):- !. + +python_metta_tag( "assertequalmettarunnerresults", "" ):- !. + +metta_interp_tag( "'", "'" ):- !. +metta_ontology_tag( "'", "'" ):- !. +metta_file_tag_find( "(", " " ):- !. +metta_file_tag( "(", "" ):- !. +metta_file_tag_til_space( "(", " " ):- !. + +metta_function_declaration( "(: ", " " ):- !. + +metta_docfile_tag( "(@doc ", "" ):- !. + + + -rust_detect_tag( "regex(r\"", "\"" ):- !. -python_detect_tag( "metta.run('!(", " " ):-!. -metta_interp_tag( "'", "'" ):-!. -metta_ontology_tag( "'", "'" ):-!. -metta_file_tag( "(", "" ):-!. -metta_docfile_tag( "(@doc ", "" ):-!. + + +% README HERE: USAGE: +% first consult the prolog file with this : +% [metta_analyse]. +% THEN call as below : +% Calling examples : +% start_analyse( 'display_per_tag', 'rust_leading', 0, '', is_dummy_tag, include_metta_files ). +% start_analyse( 'display_per_tag', 'prolog_leading', 0, '', is_dummy_tag, not_include_metta_files ). +% start_analyse( 'display_per_file', 'rust_leading', 0, '', is_dummy_tag , not_include_metta_files). +% start_analyse( 'display_per_file', 'python_leading', 0, '', is_dummy_tag , not_include_metta_files ). start_analyse( Display_per_tag_or_file, LeadingTag, Tp, MdfKeyaft, Is_mk_update , Inc_metta ):- @@ -1122,6 +2334,44 @@ start_analyse( _, _, _Tp, _MdfKeyaft, _Is_mk_update , _ ):- !. +wri_rust( Lx , Linum , F ):- + rust_detect_tag( Tag_from, Tag_til , Second_tag_begin, Second_tag_end ), + sub_str_between( Lx, Tag_from, Tag_til, Subz10 ), +% replace + str_code_remove( Subz10, 92, Subz1 ), +% is_metta_function( + is_metta_function( Subz1 ), + sub_str_between( Lx, Second_tag_begin, Second_tag_end, Subz2 ), + + assert_eval_tag( 'rust', Linum, Subz1, F, Lx , 0), +% not( eval_tag( _, Subz1, _ ) ), assert( eval_tag( Linum, Subz1, F ) ), + asserta( found_search_result( 'rust', Subz1 , 0, Linum, F, Lx ) ), + write( Subz1 ), nl, + not( eval_tag_secondary( _, Subz2 ) ), assert( eval_tag_secondary( Subz1, Subz2 ) ), ! . + +%wri_rust( Lx , _, F ):- +% sub_string( Lx , _, _, _ , "regex" ), !, write("is_line-"), write( Lx ), nl . + + +wri_rust( _Lx, _ , _ ):- !. + +% end_of +read_rust_stream( Sea , N, Fnx ):- + read_line_to_string( Sea, Lx ), Lx \= end_of_file, !, + % write( Lx ), nl, + wri_rust( Lx , N , Fnx ), N2 is N + 1, + read_rust_stream( Sea , N2 , Fnx). +read_rust_stream( _Sea , _ ,_):- !. + +% '../../../hyperon-experimental/lib/src/metta/runner/stdlib.rs' +read_rustfile_tags( Fnx ):- + retractall( eval_tag( _, _, _, _ , _ , _ ) ), + retractall( eval_tag_secondary( _, _ ) ), + + open( Fnx , read, Sea , [ encoding(octet) ] ), + read_rust_stream( Sea, 1, Fnx ), + close( Sea ). + \ No newline at end of file