#] #] ********************* #] "$d_Qtest"'symbols flatliner derivations/symbols extract- develop.txt' #] to extract a list of [all, known, unkown] symbols from a text file, # with reference to a dictionary, ignoring comments and descriptions # www.BillHowell.ca 17Apr2018 initial # view this file in a text editor, with [constant width font, tab = 3 spaces], no line-wrap # 06Jul2018 general instructions for symbol [extract,translate,fix] see : "/media/bill/PROJECTS/Lucas - Universal Force/symbols instructions.txt" # 24************************24 # Table of Contents : # $ grep "^#]" "$d_Qtest"'symbols flatliner derivations/symbols extract- develop.txt' | sed 's/^#\]/ /' ********************* "$d_Qtest"'symbols flatliner derivations/symbols extract- develop.txt' to extract a list of [all, known, unkown] symbols from a text file, 02Jan2018 Older code initial far incomplete, 03Apr2018 update, symExtract_cube_test 20Apr2018 further refinements to "/media/bill/PROJECTS/Qnial/MY_NDFS/symbols extract.ndf" : 22Apr2018 symExtract_string - upgrade for unicode 22Apr2018 22:36 getting better - except should have parenthesized Rocs(POIo),Rpcs(POIo,t=0),sin(AOpc(POIo,t)) etc 23Apr2018 fixed chr-range error in in_unicode_2chrs, flag conditions for parens fixed symParen_contents_test IS symParen_contents_test IS 26Apr2018 09:18 Now to implement recursive cross-call between [syms_inParens, symExtract_string] 27Apr2018 adjust syms_inParens 20May2018 from 19May2018 I have a problem with substitutions WITHIN symbols (YIKES!!!!) 23May2018 17:12 Add unicode tests to symExtract_string 23May2018 22:02 symWrite IS OP symList - test of symExtract problem 03Aug2018 spaces must indicate new symbol in NOT in_paren : 24************************24 08********08 #] 02Jan2018 Older code initial far incomplete, 03Apr2018 update, # symExtract_string IS OP fot i_line str_in { LOCAL i flag_head textnew ; NONLOCAL trans_old trans_new trans_msg trans_rows ; textnew := str_in ; FOR i with tell trans_rows DO flag_head := l ; IF flag_head THEN writefile fot (link (string i_line) ' : ' str_in) ; flag_head := o ; ENDIF ; IF (find_Howell trans_old@i str_in) THEN writefile fot (link ' ' trans_old@i ' ; should be : ' trans_new@i) ; trans_msg@i EACHLEFT writefile fot ; ENDIF ; ENDFOR ; writefile fot ' ' ; } # symExtract_cube in form of IF statements : IF (= flags (o o)) THEN null ; ELSEIF (= flags (o l)) THEN symNew := link symNew str_in@i ; flag_in := l ; ELSEIF (= flags (l o)) THEN symList := link symList (solitary symNew) ; symNew := '' ; flag_in := o ; ELSEIF (= flags (l l)) THEN symNew := link symNew str_in@i ; ENDIF ; # # symExtract_file IS OP d_work fname_inn fname_out { LOCAL fin fot i str_in ; fin := open (link d_work fname_inn) "r ; fot := open (link d_work fname_out) "w ; writefile fot '>>> Starting search for bad symbols' ; i := 1 ; WHILE (~= ??eof (str_in := readfile fin)) DO badSym_findLine fot i str_in ; i := i + 1 ; ENDWHILE ; writefile fot '<<< Finished search for bad symbols' ; % ; EACH close fin fot ; } # symbols extract_sort IS OP { } # #to "/media/bill/ramdisk/symbols goodList Lucas sorted.ndf" # $ sort --unique "/media/bill/ramdisk/translate goodSyms sort.txt" >"/media/bill/ramdisk/symbols goodList Lucas sorted.ndf" # $ sort --unique --output-file "/media/bill/ramdisk/translate goodSyms sorted.txt" "/media/bill/ramdisk/symbols goodList Lucas.ndf" # in kwrite : # open : "/media/bill/ramdisk/translate goodSyms sorted.txt" # Menu -> Edit -> Block selection mode # select sorted symbols list # block copy list to below 08********08 #] symExtract_cube_test symExtract_cube_test := 2 2 reshape 'null ; ' 'null ; ' 'a := 17 ; b := 5 ; c := a*b ; write c ' 'null ; ' ; qnial> symExtract_cube_test +-----------------------------------------------+---------+ |null ; |null ; | +-----------------------------------------------+---------+ |a := 17 ; b := 5 ; c := a*b ; write c |null ; | +-----------------------------------------------+---------+ qnial> symExtract_cube_test@(1 0) a := 17 ; b := 5 ; c := a*b ; write c qnial> execute 'a := 17 ; b := 5 ; c := a*b ; write c ' 85 qnial> execute symExtract_cube_test@(0 1) >> no output!?? qnial> shape symExtract_cube_test@(1 0) 08********08 #] 20Apr2018 further refinements to "/media/bill/PROJECTS/Qnial/MY_NDFS/symbols extract.ndf" : symExtract_string IS OP symExtract_array str_in mostly to remove error induced by unicode characters that are "lost" $ - to prevent translation of strings on line % - to allow one-line comments, followed by "active" text that can be extracted use text file "/media/bill/SWAPPER/Lucas - Universal Force/symbols translate inn.txt" # symExtract_file (link d_Lucas 'Howell - math of Lucas Universal Force, no apostophes 180418.txt') (link d_Qnial_temp 'symExtract_file out.txt') >> 20Apr2018 greatly reduced cooment text - but still a lot >> still a problem with unicode charcters like dot product, and probably cross-product 08********08 #] 22Apr2018 symExtract_string - upgrade for unicode # old code IF (chr_code3 < 0) THEN IF (OR (AND (-50 = chr_code) (OR (AND ( -80 < chr_code2) (chr_code2 < -64)) (AND (-112 < chr_code2) (chr_code2 < -86)) )) (AND (-49 = chr_code) ( -80 < chr_code2) (chr_code2 < -64)) ) THEN flags@1 := 1 ; execute symExtract_array@(flags) ; i := i + 1 ; flags_old flags_mid := flags_mid flags ; execute symExtract_array@(flags) ; ELSE # #+-----+ ; # 22Apr2018 Successful tests of [in_string,in_unicode_3chrs] # note that tabs in string must be removed first!! # in_unicode_3chrs `∂ 1 # in_unicode_3chrs char (-30 -120 -126) 0 # a := char (-30 -120 -126) ∂ # ischar a o # isstring a l # in_string '∂' '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' l # #+-----+ # 22Apr2018 Failed tests # '∬' '∮' '' '∂' '∫' '∇' '·' EACHLEFT in_string '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' llolllo >> 22Apr2018 22:36 in_string ['','·'] are WRONG! ?? Why? # EACH charrep '∬' '∮' '' '∂' '∫' '∇' '·' +------------+------------+-------------+-------------+------------+-------------+-------+ |-30 -120 -84|-30 -120 -82|-18 -126 -108|-30 -120 -126|-30 -120 -85|-30 -120 -121|-62 -73| +------------+------------+-------------+-------------+------------+-------------+-------+ # '∬' '∮' '' '∂' '∫' '∇' '·' EACHLEFT in_string '∬∮∂∫∇·' llolllo >> 22Apr2018 22:36 in_string ['','·'] are WRONG! # EACH in_unicode_3chrs '∬' '∮' '' '∂' '∫' '∇' '·' 1 1 0 1 1 1 0 >> 22Apr2018 22:36 in_unicode_3chrs ['','·'] are WRONG! - same as for in_string # loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols extract- tests.ndf' 08********08 #] 22Apr2018 22:36 getting better - except should have parenthesized Rocs(POIo),Rpcs(POIo,t=0),sin(AOpc(POIo,t)) etc #+-----+ # Successful tests of "symExtract_string symExtract_2D" # symExtract_string symExtract_2D 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' +-+--+-+--+-+-+--+--+-+-+ |3|Bi|c|E0|q|r|rp|rs|t|v| +-+--+-+--+-+-+--+--+-+-+ >> 22Apr2018 22:36 looks OK, except would preferably also have Bi(r,v,t) & E0(r,t) >> but that is an "upgrade" to the current system? I had it before due to parenthesis # symExtract_string symExtract_2D '$ = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' +---+----+----+--+-+--+-+--+----+-+ |∂|∂O|∂P|Ei|O|Pp|r|rp|sinO|t| +---+----+----+--+-+--+-+--+----+-+ >> 22Apr2018 22:36 OK #+-----+ # failed tests # symExtract_string symExtract_2D ' e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) ' +-+-+-+-+---+---+-+-+--+--+ |2|3|6|b|Bep|Bpe|e|r|r1|r2| +-+-+-+-+---+---+-+-+--+--+ >> 22Apr2018 22:36 OK except for MISSING π # symExtract_string symExtract_2D '∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) ' +---+-----+-+--+--+--+--+-+----+ |∮|∂Σ|B|dA|dl|dp|dt|E|over| +---+-----+-+--+--+--+--+-+----+ >> 22Apr2018 22:36 OK except missing , which should work now 22Apr2018 22:36 # symExtract_string symExtract_2D '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' +---+-----+-----+-----+-+--+--+--+-+--+--+--+ |∂|∂x1|∂x2|∂x3|a|a1|a2|a3|n|n1|n2|n3| +---+-----+-----+-----+-+--+--+--+-+--+--+--+ >> 22Apr2018 22:36 OK, except "n" should NOT be in the list. # symExtract_string symExtract_2D '2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t))^4 ' +-+-+-+----+-+-+----+----+-+-----+----+----+----+---+-+----+ |0|1|2|2a1a|3|4|AOpc|beta|c|E0ods|POIo|Rocs|Rpcs|sin|t|Vons| +-+-+-+----+-+-+----+----+-+-----+----+----+----+---+-+----+ >> 22Apr2018 22:36 looks Ok except should have parenthesized Rocs(POIo),Rpcs(POIo,t=0),sin(AOpc(POIo,t)) etc 08********08 #] 23Apr2018 fixed chr-range error in in_unicode_2chrs, flag conditions for parens fixed #+-----+ ; # 23Apr2018 Successful tests of [in_string,in_unicode_3chrs] # note that tabs in string must be removed first!! # in_unicode_3chrs `∂ 1 # in_unicode_3chrs char (-30 -120 -126) 0 # a := char (-30 -120 -126) ∂ # ischar a o # isstring a l # in_string '∂' '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' l # #+-----+ # 23Apr2018 Failed tests # '∬' '∮' '' '∂' '∫' '∇' '·' EACHLEFT in_string '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' llolllo >> 22Apr2018 22:36 in_string ['','·'] are WRONG! ?? Why? # EACH charrep '∬' '∮' '' '∂' '∫' '∇' '·' +------------+------------+-------------+-------------+------------+-------------+-------+ |-30 -120 -84|-30 -120 -82|-18 -126 -108|-30 -120 -126|-30 -120 -85|-30 -120 -121|-62 -73| +------------+------------+-------------+-------------+------------+-------------+-------+ # '∬' '∮' '' '∂' '∫' '∇' '·' EACHLEFT in_string '∬∮∂∫∇·' llolllo >> 22Apr2018 22:36 in_string ['','·'] are WRONG! # EACH in_unicode_3chrs '∬' '∮' '' '∂' '∫' '∇' '·' 1 1 0 1 1 1 0 >> 22Apr2018 22:36 in_unicode_3chrs ['','·'] are WRONG! - same as for in_string #+-----+ ; 23Apr2018 getting better - except should have parenthesized Rocs(POIo),Rpcs(POIo,t=0),sin(AOpc(POIo,t)) etc #+-----+ # Successful tests of "symExtract_string symExtract_2D" # but now I want to extract recursively symbols in parenthesis # symExtract_string symExtract_2D 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' +-+--+-+--+-+-+--+--+-+-+ |3|Bi|c|E0|q|r|rp|rs|t|v| +-+--+-+--+-+-+--+--+-+-+ >> 23Apr2018 21:00 looks OK, except would preferably also have Bi(r,v,t) & E0(r,t) >> but that is an "upgrade" to the current system? I had it before due to parenthesis # symExtract_string symExtract_2D ' e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) ' +--+-+-+-+-+---+---+-+-+--+--+ |π|2|3|6|b|Bep|Bpe|e|r|r1|r2| +--+-+-+-+-+---+---+-+-+--+--+ >> 23Apr2018 21:00 OK # symExtract_string symExtract_2D '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' +---+-----+-----+-----+-+--+--+--+--+--+--+ |∂|∂x1|∂x2|∂x3|a|a1|a2|a3|n1|n2|n3| +---+-----+-----+-----+-+--+--+--+--+--+--+ >> 23Apr2018 21:00 OK # symExtract_string symExtract_2D '2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t))^4 ' +-+-+----+-+-+----+-+---------------+----------+--------------+-----------------+----+ |1|2|2a1a|3|4|beta|c|E0ods(POIo,t=0)|Rocs(POIo)|Rpcs(POIo,t=0)|sin(AOpc(POIo,t))|Vons| +-+-+----+-+-+----+-+---------------+----------+--------------+-----------------+----+ >> 23Apr2018 21:00 looks Ok #+-----+ # failed tests # symExtract_string symExtract_2D '$ = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' +---+----+----+--+-+--+-+--+----+-+ |∂|∂O|∂P|Ei|O|Pp|r|rp|sinO|t| +---+----+----+--+-+--+-+--+----+-+ >> 23Apr2018 21:00 OK except for r from a known error # symExtract_string symExtract_2D '∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) ' +-------------------------+--+----------+----+ |∮(·dl, over ∂Σ : E)|dA|dp[dt : B]|over| +-------------------------+--+----------+----+ >> 23Apr2018 21:00 OK except missing  -> (·dA, over : dp[dt : B] ) 08********08 symExtract_string_test IS { LOCAL t_name t_input t_standard t_result ; EACH write ' ' ' ' '#+-----+' (link 'symExtract_string_test, ' timestamp) ; % ; t_name := '# symExtract_string_test example 1' ; t_input := 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; t_standard := '3' 'Bi(r,v,t)' 'c' 'E0(r,t)' 'q' 'rp' 'rs' 'v' ; t_result := symExtract_string symExtract_2D t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExtract_string_test example 2' ; t_input := ' e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) ' ; t_standard := 'π' '2' '3' '6' 'b' 'Bep' 'Bpe' 'e' 'r' 'r1' 'r2' ; t_result := symExtract_string symExtract_2D t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExtract_string_test example 3' ; t_input := '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' ; t_standard := '∂' '∂x1' '∂x2' '∂x3' 'a' 'a1' 'a2' 'a3' 'n1' 'n2' 'n3' ; t_result := symExtract_string symExtract_2D t_input ; test_comment t_name t_input t_standard t_result ; % ; % for string 'dp(dP : Ei(rp,t)·rh)/sinO - dp(dr : Ei(rp,t)·Ph*rs) ]' ; t_name := '# symExtract_string_test example 4' ; t_input := '2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t))^4 ' ; t_standard := '1' '2' '2a1a' '3' '4' 'beta' 'c' 'E0ods(POIo,t=0)' 'Rocs(POIo)' 'Rpcs(POIo,t=0)' 'sin(AOpc(POIo,t))' 'Vons' ; t_result := symExtract_string symExtract_2D t_input ; test_comment t_name t_input t_standard t_result ; % ; % for string 'dp[dt : E0ods(POIo,t) * 15/8*beta^4*sin(AOpc(POIo,t))^4 *sin(AOpc(POIo,t)) ] ' ; t_name := '# symExtract_string_test example 5' ; t_input := '$ = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' ; t_standard := '∂' '∂O' '∂P' 'Ei' 'O' 'Pp' 'r' 'rp' 'sinO' 't' ; t_result := symExtract_string symExtract_2D t_input ; test_comment t_name t_input t_standard t_result ; % ; % for string 'dp[dt : E0ods(POIo,t) * 15/8*beta^4*sin(AOpc(POIo,t))^4 *sin(AOpc(POIo,t)) ] ' ; t_name := '# symExtract_string_test example 6' ; t_input := '∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) ' ; t_standard := '∮(·dl, over ∂Σ : E)' 'dA' 'dp[dt : B]' 'over' ; t_result := symExtract_string symExtract_2D t_input ; test_comment t_name t_input t_standard t_result ; } # 25Apr2018 - following stupid changes, this code doesn't work : +-----+ symExtract_string IS OP symExtract_array str_in { LOCAL chr_code chr_code2 chr_new dim_flags flags flags_old flags_mid i len n_paren symList symNew ; NONLOCAL sym_chrs chrs_stop_paren chrs_strt_paren ; % ; %------------ ; %stops recursive callS ; IF (isstring str_in) THEN % ; symNew := '' ; symList := null ; dim_flags := gage shape shape symExtract_array ; flags := dim_flags reshape 0 ; n_paren := 0 ; len := gage shape str_in ; i := 0 ; % ; WHILE (i < len) DO flags_old flags_mid := flags_mid flags ; chr_code := charrep str_in@i ; %check for [chrs_Greek_caps, chrs_Greek_small] ; IF (chr_code < 0) THEN IF (i < (len - 2)) THEN chr_code2 := charrep str_in@(i + 1) ; chr_code3 := charrep str_in@(i + 2) ; IF (AND (chr_code2 < 0) (chr_code3 < 0)) THEN chr_new := char (chr_code chr_code2 chr_code3) ; flags@1 := in_unicode_3chrs chr_new ; execute symExtract_array@(flags) ; i := i + 2 ; ELSEIF (chr_code2 < 0) THEN chr_new := char (chr_code chr_code2) ; flags@1 := in_unicode_2chrs chr_code chr_code2 ; execute symExtract_array@(flags) ; i := i + 1 ; ELSE chr_new := char (chr_code) ; flags@1 := 0 ; execute symExtract_array@(flags) ; ENDIF ; ELSEIF (i < (len - 1)) THEN chr_code2 := charrep str_in@(i + 1) ; IF (chr_code2 < 0) THEN chr_new := char (chr_code chr_code2) ; flags@1 := in_unicode_2chrs chr_code chr_code2 ; execute symExtract_array@(flags) ; i := i + 1 ; ELSE chr_new := char (chr_code) ; flags@1 := in_unicode_2chrs chr_code ; execute symExtract_array@(flags) ; ENDIF ; ELSE chr_new := char (chr_code) ; flags@1 := 0 ; execute symExtract_array@(flags) ; ENDIF ; ELSEIF (in (char chr_code) chrs_strt_paren) THEN chr_new := char (chr_code) ; flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_array@(flags) ; ELSEIF (in (char chr_code) chrs_stop_paren) THEN chr_new := char (chr_code) ; flags@1 := 0 ; execute symExtract_array@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSE chr_new := char (chr_code) ; flags@1 := in_unicode_1chr chr_code ; execute symExtract_array@(flags) ; ENDIF ; write_debug link link 'chr= ' (char chr_code) ' ' (string chr_code) ', flags_[old,mid,new],n_paren= ' (EACH string flags_old) ' ' (EACH string flags_mid) ' ' (EACH string flags) ' ' (string n_paren) ', symNew= ' symNew ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; % ; %------------ ; %stops recursive callS ; ELSE symNew := null ; ENDIF ; % ; symNew } >> Works now. I added a recursion-stop write-debug : % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; % ; %------------ ; %stops recursive callS ; ELSE symList := null ; write_debug 'symExtract_string : null string input' ; ENDIF ; % ; symList } 08********08 #] symParen_contents_test IS # NOTE : example 4 is [not a proper symbol expression, unbalanced parenthesis, but "illegal" parts still output # After all, the objective is to extract symbols #+-----+ symParen_contents_test, Wed Apr 25 09:33:05 2018 # symParen_contents_test example 1 : OK - result matches standard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E) ∮ ·dl, over ∂Σ : E ∮ ·dl, over ∂Σ : E # symParen_contents_test example 2 : OK - result matches standard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E ∮ ·dl, over ∂Σ : E ∮ ·dl, over ∂Σ : E # symParen_contents_test example 3 : OK - result matches standard t_input, t_standard, t_result = (·dA, over : dp[dt : B] )  ·dA, over : dp[dt : B]  ·dA, over : dp[dt : B] # symParen_contents_test example 4 : OK - result matches standard t_input, t_standard, t_result = dp(dP : Ei(rp,t)·rh)/sinO - dp(dr : Ei(rp,t)·Ph*rs) ] dp dP : Ei(rp,t)·rh /sinO - dp(dr : Ei(rp,t)·Ph*rs) ] dp dP : Ei(rp,t)·rh /sinO - dp(dr : Ei(rp,t)·Ph*rs) ] # symParen_contents_test example 5 : OK - result matches standard t_input, t_standard, t_result = dp[dt : E0ods(POIo,t) * 15/8*beta^4*sin(AOpc(POIo,t))^4 *sin(AOpc(POIo,t)) ] dp dt : E0ods(POIo,t) * 15/8*beta^4*sin(AOpc(POIo,t))^4 *sin(AOpc(POIo,t)) dp dt : E0ods(POIo,t) * 15/8*beta^4*sin(AOpc(POIo,t))^4 *sin(AOpc(POIo,t)) 08********08 #] symParen_contents_test IS # NOTE : example 4 is [not a proper symbol expression, unbalanced parenthesis, but "illegal" parts still output # After all, the objective is to extract symbols #+-----+ syms_inParens_test, Wed Apr 25 11:21:15 2018 # syms_inParens_test example 1 : OK - result matches standard t_input, t_standard, t_result = +-------------------------+ |∮(·dl, over ∂Σ : E)| +-------------------------+ +---+-----+--+-+----+ |∮|∂Σ|dl|E|over| +---+-----+--+-+----+ +---+-----+--+-+----+ |∮|∂Σ|dl|E|over| +---+-----+--+-+----+ # syms_inParens_test example 2 : OK - result matches standard t_input, t_standard, t_result = +------------------------+ |∮(·dl, over ∂Σ : E| +------------------------+ +---+-----+--+-+----+ |∮|∂Σ|dl|E|over| +---+-----+--+-+----+ +---+-----+--+-+----+ |∮|∂Σ|dl|E|over| +---+-----+--+-+----+ # syms_inParens_test example 3 : FAILED - result does NOT match standard t_input, t_standard, t_result = +-------------------------------+ |(·dA, over : dp[dt : B] ) | +-------------------------------+ +---+-+--+--+----------+--+----+ ||B|dA|dp|dp[dt : B]|dt|over| +---+-+--+--+----------+--+----+ +-+--+--+----------+--+----+ |B|dA|dp|dp[dt : B]|dt|over| +-+--+--+----------+--+----+ # syms_inParens_test example 4 : FAILED - result does NOT match standard t_input, t_standard, t_result = +------------------------+----+---------------------------+ |dp(dP : Ei(rp,t)·rh)|sinO|dp(dr : Ei(rp,t)·Ph*rs)| +------------------------+----+---------------------------+ +--+--+--+--+--------+-----+-----+--+--+-+ |dp|dP|dr|Ei|Ei(rp,t)|rh|Ph|rp|rs|t| +--+--+--+--+--------+-----+-----+--+--+-+ +--+--+--+--+--------+--+--+--+--+-+ |dp|dP|dr|Ei|Ei(rp,t)|Ph|rh|rp|rs|t| +--+--+--+--+--------+--+--+--+--+-+ # syms_inParens_test example 5 : OK - result matches standard t_input, t_standard, t_result = +---------------------+--+-+----+-+-----------------+-+-------------------+ |dp[dt : E0ods(POIo,t)|15|8|beta|4|sin(AOpc(POIo,t))|4|sin(AOpc(POIo,t)) ]| +---------------------+--+-+----+-+-----------------+-+-------------------+ +----+------------+--+--+-----+-------------+----+---+-+ |AOpc|AOpc(POIo,t)|dp|dt|E0ods|E0ods(POIo,t)|POIo|sin|t| +----+------------+--+--+-----+-------------+----+---+-+ +----+------------+--+--+-----+-------------+----+---+-+ |AOpc|AOpc(POIo,t)|dp|dt|E0ods|E0ods(POIo,t)|POIo|sin|t| +----+------------+--+--+-----+-------------+----+---+-+ >> Pretty good success, except for the problematic unicode characters '' 08********08 #] 26Apr2018 09:18 Now to implement recursive cross-call between [syms_inParens, symExtract_string] >> 1st small step - activate in syms_inParens EACH write_debug 'symList_subs1 : ' symList_subs ; symList_subs := link (symList_subs (link syms_inParens symList_subs)) ; EACH write_debug 'symList_subs2 : ' symList_subs ; write_debug ' ' ; >> OK >> now activate in syms_inParens : ENDIF ; EACH sym_stdForm (cull sortup link (symList syms_inParens symList)) ; +-----+ symExtract_string_test, Thu Apr 26 09:33:10 2018 # symExtract_string_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +-+---------+-+-------+-+--+--+-+ |3|Bi(r,v,t)|c|E0(r,t)|q|rp|rs|v| +-+---------+-+-------+-+--+--+-+ +---------+-+-+-+--+--+-+-+-+-------+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)| +---------+-+-+-+--+--+-+-+-+-------+ +-----+ >> syms_inParens results in loop loooolol l +---------------------+-----------------+-------------------+ |dp[dt : E0ods(POIo,t)|sin(AOpc(POIo,t))|sin(AOpc(POIo,t)) ]| +---------------------+-----------------+-------------------+ +---------------------+-----------------+-------------------+ |dp dt : E0ods(POIo,t)|sin AOpc(POIo,t) |sin AOpc(POIo,t) ]| +---------------------+-----------------+-------------------+ symList_subs1 : +---------------------+------------------+------------------+ |+--+--+-------------+|+---+------------+|+---+------------+| ||dp|dt|E0ods(POIo,t)|||sin|AOpc(POIo,t)|||sin|AOpc(POIo,t)|| |+--+--+-------------+|+---+------------+|+---+------------+| +---------------------+------------------+------------------+ syms_inParens : null list input symList_subs2 : +---------------------+------------------+------------------+ |+--+--+-------------+|+---+------------+|+---+------------+| ||dp|dt|E0ods(POIo,t)|||sin|AOpc(POIo,t)|||sin|AOpc(POIo,t)|| |+--+--+-------------+|+---+------------+|+---+------------+| +---------------------+------------------+------------------+ syms_inParens : null list input # syms_inParens_test example 5 : FAILED - result does NOT match standard t_input, t_standard, t_result = +---------------------+--+-+----+-+-----------------+-+-------------------+ |dp[dt : E0ods(POIo,t)|15|8|beta|4|sin(AOpc(POIo,t))|4|sin(AOpc(POIo,t)) ]| +---------------------+--+-+----+-+-----------------+-+-------------------+ +----+------------+--+--+-----+-------------+----+---+-+ |AOpc|AOpc(POIo,t)|dp|dt|E0ods|E0ods(POIo,t)|POIo|sin|t| +----+------------+--+--+-----+-------------+----+---+-+ +---------------------+------------------+ |+--+--+-------------+|+---+------------+| ||dp|dt|E0ods(POIo,t)|||sin|AOpc(POIo,t)|| |+--+--+-------------+|+---+------------+| +---------------------+------------------+ >> Missing a link to join lists. change to : symList_subs := link (symExtract_2D EACHRIGHT symExtract_string strList_contents) ; >> retry : #+-----+ syms_inParens_test, Thu Apr 26 09:46:42 2018 syms_inParens results in loop loooolol l +---------------------+-----------------+-------------------+ |dp[dt : E0ods(POIo,t)|sin(AOpc(POIo,t))|sin(AOpc(POIo,t)) ]| +---------------------+-----------------+-------------------+ +---------------------+-----------------+-------------------+ |dp dt : E0ods(POIo,t)|sin AOpc(POIo,t) |sin AOpc(POIo,t) ]| +---------------------+-----------------+-------------------+ symList_subs1 : +--+--+-------------+---+------------+---+------------+ |dp|dt|E0ods(POIo,t)|sin|AOpc(POIo,t)|sin|AOpc(POIo,t)| +--+--+-------------+---+------------+---+------------+ syms_inParens results in loop oololol l +-------------+------------+------------+ |E0ods(POIo,t)|AOpc(POIo,t)|AOpc(POIo,t)| +-------------+------------+------------+ +-------------+------------+------------+ |E0ods POIo,t |AOpc POIo,t |AOpc POIo,t | +-------------+------------+------------+ symList_subs1 : +-----+----+-+----+----+-+----+----+-+ |E0ods|POIo|t|AOpc|POIo|t|AOpc|POIo|t| +-----+----+-+----+----+-+----+----+-+ syms_inParens results in loop ooooooooo o syms_inParens : null list input symList_subs2 : +-----+----+-+----+----+-+----+----+-+ |E0ods|POIo|t|AOpc|POIo|t|AOpc|POIo|t| +-----+----+-+----+----+-+----+----+-+ syms_inParens : null list input symList_subs2 : +--+--+-------------+---+------------+---+------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |dp|dt|E0ods(POIo,t)|sin|AOpc(POIo,t)|sin|AOpc(POIo,t)|E|0|o|d|s|P|O|I|o|t|A|O|p|c|P|O|I|o|t|A|O|p|c|P|O|I|o|t +--+--+-------------+---+------------+---+------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- + | + syms_inParens : null list input # syms_inParens_test example 5 : FAILED - result does NOT match standard t_input, t_standard, t_result = +---------------------+--+-+----+-+-----------------+-+-------------------+ |dp[dt : E0ods(POIo,t)|15|8|beta|4|sin(AOpc(POIo,t))|4|sin(AOpc(POIo,t)) ]| +---------------------+--+-+----+-+-----------------+-+-------------------+ +----+------------+--+--+-----+-------------+----+---+-+ |AOpc|AOpc(POIo,t)|dp|dt|E0ods|E0ods(POIo,t)|POIo|sin|t| +----+------------+--+--+-----+-------------+----+---+-+ +-+-+------------+-+-+--+--+-+-------------+-+-+-+-+-+-+---+-+ |0|A|AOpc(POIo,t)|c|d|dp|dt|E|E0ods(POIo,t)|I|o|O|p|P|s|sin|t| +-+-+------------+-+-+--+--+-+-------------+-+-+-+-+-+-+---+-+ >> Oops, now a link too many, as legitimate symbols are broken into letters? 08********08 #] 27Apr2018 adjust syms_inParens After considerable work to get recursion to work in symExtract_string syms_inParens # old code symList_subs := link (symList_subs (link syms_inParens symList_subs)) ; EACH sym_stdForm (cull sortup link (symList syms_inParens symList)) ; symList_subs := link (symExtract_2D EACHRIGHT symExtract_string strList_contents) ; symList_augmt := first (symList_subs (link (syms_inParens recurLevelNow symList_subs))) ; symList_subs := EACH sym_stdForm symList_subs ; EACH write 'symList_subs : ' symList_subs ; EACH write 'symList_augmt : ' symList_augmt ; symExtract_string # old code cull sortup symList #+-----+ symExtract_string_test, Fri Apr 27 11:05:24 2018 symExtract_string recurLevelNow: 0 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 1 # symExtract_string_test example 1 : OK - result matches standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|Bi|r|v|t|E0|r|t| +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|Bi|r|v|t|E0|r|t| +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ symExtract_string recurLevelNow: 0 # symExtract_string_test example 2 : OK - result matches standard t_input, t_standard, t_result = e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ |e|2|r|b|r|r|b|r2|r1|2|6|Bpe|2|Bep|2|3|2|π| +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ |e|2|r|b|r|r|b|r2|r1|2|6|Bpe|2|Bep|2|3|2|π| +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ symExtract_string recurLevelNow: 0 # symExtract_string_test example 3 : OK - result matches standard t_input, t_standard, t_result = (a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3) +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ |a|a1|n1|a2|n2|a3|n3|∂|∂x1|n1|∂|∂x2|n2|∂|∂x3|n3| +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ |a|a1|n1|a2|n2|a3|n3|∂|∂x1|n1|∂|∂x2|n2|∂|∂x3|n3| +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ symExtract_string recurLevelNow: 0 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 2 # symExtract_string_test example 4 : OK - result matches standard t_input, t_standard, t_result = 2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t) )^4 +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- |2a1a|E0ods(POIo,t=0)|3|4|beta|2|Vons|c|Rocs(POIo)|Rpcs(POIo,t=0)|1|sin(AOpc(POIo,t))|4|E0ods|POIo|t|0|Rocs|PO +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- --+----+----+-+-+---+------------+----+----+-+ Io|Rpcs|POIo|t|0|sin|AOpc(POIo,t)|AOpc|POIo|t| --+----+----+-+-+---+------------+----+----+-+ +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- |2a1a|E0ods(POIo,t=0)|3|4|beta|2|Vons|c|Rocs(POIo)|Rpcs(POIo,t=0)|1|sin(AOpc(POIo,t))|4|E0ods|POIo|t|0|Rocs|PO +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- --+----+----+-+-+---+------------+----+----+-+ Io|Rpcs|POIo|t|0|sin|AOpc(POIo,t)|AOpc|POIo|t| --+----+----+-+-+---+------------+----+----+-+ symExtract_string recurLevelNow: 0 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 2 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 2 # symExtract_string_test example 5 : OK - result matches standard t_input, t_standard, t_result = $ = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] +-+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+----+--------+-+--+- |r|r|sinO|∂|∂O(sinO*Ei(rp,t)·Pp)|∂|∂P(Ei(rp,t)·O)|∂O|sinO|Ei(rp,t)|Pp|Ei|rp|t|∂P|Ei(rp,t)|O|Ei|r +-+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+----+--------+-+--+- -+-+ p|t| -+-+ +-+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+----+--------+-+--+- |r|r|sinO|∂|∂O(sinO*Ei(rp,t)·Pp)|∂|∂P(Ei(rp,t)·O)|∂O|sinO|Ei(rp,t)|Pp|Ei|rp|t|∂P|Ei(rp,t)|O|Ei|r +-+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+----+--------+-+--+- -+-+ p|t| -+-+ symExtract_string recurLevelNow: 0 symExtract_string recurLevelNow: 1 symExtract_string recurLevelNow: 1 # symExtract_string_test example 6 : OK - result matches standard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) +-------------------------+--+----+----------+---+--+----+-----+-+--+--+-+ |∮(·dl, over ∂Σ : E)|dA|over|dp[dt : B]|∮|dl|over|∂Σ|E|dp|dt|B| +-------------------------+--+----+----------+---+--+----+-----+-+--+--+-+ +-------------------------+--+----+----------+---+--+----+-----+-+--+--+-+ |∮(·dl, over ∂Σ : E)|dA|over|dp[dt : B]|∮|dl|over|∂Σ|E|dp|dt|B| +-------------------------+--+----+----------+---+--+----+-----+-+--+--+-+ >> Finally!! seems to work beautifully 08********08 # 08May2018 Oops! QNial version MUST account for NON(chrs_symbols_HFLN) characters [preceding,following] a symbol!! # this has to be done by symExtract_string # (previously it was done by a sed-based call, but the full-QNial version doesn't use that) # key [data, code] : >> symExtract_2D := 2 2 2 reshape >> also : ELSE chr_new := char (chr_code) ; flags@1 := in_unicode_1chr chr_code ; execute symExtract_array@(flags) ; # 08********08 09May2018 try to fix symExtract_string (I screwed it up again!) # 08May2018 Oops! QNial version MUST account for NON(chrs_symbols_HFLN) characters [preceding,following] a symbol!! # this has to be don by symExtract_string # 09May2018 - done # 18Apr2018 I'm trying to use chf_codes to make computations faster chrs_Greek_caps := 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩ' ; % chr_codes [[-50 -79]-[-50 -65],[-49 -128]-[-49 -119]] ; chrs_Greek_small := 'αβγδεζηθικλμνξοπρςστυφχψω' ; % chr_codes [[-50 -111]-[-50 -87] ; chrs_Greek_all := link chrs_Greek_caps chrs_Greek_small ; % chrs_Greek_caps chrs_Greek_small ; in_unicode_2chrs_coded IS OP chr_code chr_code2 { LOCAL flag_in ; IF (OR (AND (-50 = chr_code) (OR (AND ( -80 < chr_code2) (chr_code2 < -64)) (AND (-112 < chr_code2) (chr_code2 < -86)) )) (AND (-49 = chr_code) (-129 < chr_code2) (chr_code2 < -118)) ) THEN flag_in := 1 ; ELSE flag_in := 0 ; ENDIF ; flag_in } # 18Apr2018 YIKES! non-standard ASCII codes for QNial? >> Something is wrong with QNial charrep operator!! - small letters give wrong answer! but char seems correct >> see "strings.ndf" symExtractString - Get rid of the "codes" coding as it's too obscure and only 1/3 faster !! : +-----+ in_unicode_2chrs_direct IS OP str { in str 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψω' } in_unicode_2chrs IS OP str { in str 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψω' } test_speed IS OP n_iterations { LOCAL i t_new t_old ; % ; t_start := sec_from_timestamp ; FOR i WITH tell n_iterations DO in_unicode_2chrs -50 -79 ; ENDFOR ; t_end := sec_from_timestamp ; write link 'seconds duration 1 : ' (string - t_end t_start) ; % ; t_start := sec_from_timestamp ; FOR i WITH tell n_iterations DO in_unicode_2chrs_direct -50 -79 ; ENDFOR ; t_end := sec_from_timestamp ; write link 'seconds duration 2 : ' (string - t_end t_start) ; } # 09May2018 test speed of [in_unicode_2chrs_coded,in_unicode_2chrs_direct] qnial> test_speed 10000000 seconds duration 1 : 24 seconds duration 2 : 30 >> In essence, in_unicode_2chrs_direct takes 50% longeer, but is way more complicated and hard to read >> Therefore, just rename in_unicode_1chr IS OP chr_code { LOCAL flag_in ; IF (AND ( 64 < chr_code) ( chr_code < 91)) THEN flag_in := 1 ; % chrs_alpha_caps ; ELSEIF (AND ( 96 < chr_code) ( chr_code < 122)) THEN flag_in := 1 ; % chrs_alpha_small ; ELSEIF (AND ( 47 < chr_code) ( chr_code < 58)) THEN flag_in := 1 ; % chrs_numbers ; ELSEIF (= 95 chr_code) THEN flag_in := 1 ; % chr_underscore ; ELSEIF (AND ( 47 < chr_code) ( chr_code < 58)) THEN flag_in := 1 ; % chrs_Greek_small2 ; ELSEIF (AND ( 47 < chr_code) ( chr_code < 58)) THEN flag_in := 1 ; % chrs_Greek_caps ; ELSE flag_in := 0 ; ENDIF ; flag_in } # defined in "strings.ndf" : # not used, as for now there are no symbol-valid one-character unicodes other than alphaNumeric & '_' in_unicode_1chr IS OP str { in_string str 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_' * 1 } in_unicode_2chrs IS OP str { in_string str 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψω' * 1} in_unicode_3chrs IS OP str { in_string str '∫∂∬∮' * 1 } 10May2018 NOTE : can't do this blended list as str@i only brings up the first char of unicode! I must use the char_code for unicode >= 2 chars +-----+ Old coding : WHILE (i < len) DO flags_old flags_mid := flags_mid flags ; chr_code := charrep str@i ; %check for unicode including valid symChars [chrs_Greek_caps, chrs_Greek_small] and others like '∬∮∂∫·∇' ; IF (chr_code < 0) THEN IF (i < (len - 2)) THEN chr_code2 := charrep str@(i + 1) ; chr_code3 := charrep str@(i + 2) ; IF (AND (chr_code2 < 0) (chr_code3 < 0)) THEN chr_new := string char (chr_code chr_code2 chr_code3) ; flags@1 := in_unicode_3chrs chr_new ; execute symExtract_array@(flags) ; flags@1 := 0 ; i := i + 2 ; ELSEIF (chr_code2 < 0) THEN chr_new := string char (chr_code chr_code2) ; flags@1 := in_unicode_2chrs chr_new ; execute symExtract_array@(flags) ; flags@1 := 0 ; i := i + 1 ; ELSE % at present there are no valid single-code unicodes ; chr_new := string str@i ; execute symExtract_array@(flags) ; flags@1 := 0 ; ENDIF ; ELSEIF (i < (len - 1)) THEN chr_code2 := charrep str@(i + 1) ; IF (chr_code2 < 0) THEN chr_new := string char (chr_code chr_code2) ; flags@1 := in_unicode_2chrs chr_new ; execute symExtract_array@(flags) ; flags@1 := 0 ; i := i + 1 ; ELSE % at present there are no valid single-code unicodes ; chr_new := string str@i ; execute symExtract_array@(flags) ; flags@1 := 0 ; ENDIF ; ELSE % at present there are no valid single-code unicodes ; chr_new := string str@i ; execute symExtract_array@(flags) ; flags@1 := 0 ; ENDIF ; ELSEIF (in str@i chrs_strt_paren) THEN chr_new := string str@i ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_stop_paren) THEN chr_new := string str@i ; execute symExtract_array@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSEIF (in str@i chrs_alphaNumUnd) THEN chr_new := string str@i ; flags@1 := 1 ; execute symExtract_array@(flags) ; ELSE % non-[chrs_alphaNumUnd,valid_unicode,chrs_[strt,stop]_paren] characters ; chr_new := string str@i ; flags@1 := 0 ; execute symExtract_array@(flags) ; ENDIF ; %write_debug link link 'chr= ' (char chr_code) ' ' (string chr_code) ', flags_[old,mid,new],n_paren= ' (EACH string flags_old) ' ' (EACH string flags_mid) ' ' (EACH string flags) ' ' (string n_paren) ', symNew= ' symNew ; i := i + 1 ; ENDWHILE ; symExtractString IS OP str { LOCAL chr_code chr_code2 chr_new dim_flags flags flags_mid i len n_paren symParenList symList symNew ; NONLOCAL sym_chrs chrs_alphaNumUnder chrs_stop_paren chrs_strt_paren symExtract_array symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write_debug link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; % ; %------------ ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; dim_flags := gage shape shape symExtract_array ; flags := dim_flags reshape 0 ; flags_old := flags ; n_paren := 0 ; len := gage shape str ; i := 0 ; % ; IF flag_break THEN BREAK ; ENDIF ; WHILE (i < len) DO flags_mid := flags ; chr_code := charrep str@i ; IF (in_string (string str@i) chrs_blank) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; ELSEIF (in_string (string str@i) chrs_alphaNumUnder) THEN flags@1 := 1 ; execute symExtract_array@(flags) ; ELSEIF (chr_code < 0) THEN IF (i < (len - 2)) THEN chr_code2 := charrep str@(i + 1) ; chr_code3 := charrep str@(i + 2) ; IF (AND (chr_code2 < 0) (chr_code3 < 0)) THEN chr_new := char (chr_code chr_code2 chr_code3) ; flags@1 := in_unicode_3chrs chr_new ; execute symExtract_array@(flags) ; flags@1 := 0 ; i := i + 2 ; ELSEIF (chr_code2 < 0) THEN chr_new := char (chr_code chr_code2) ; flags@1 := in_unicode_2chrs chr_new ; execute symExtract_array@(flags) ; flags@1 := 0 ; i := i + 1 ; ELSE % at present there are no valid single-code unicodes ; chr_new := string str@i ; execute symExtract_array@(flags) ; flags@1 := 0 ; ENDIF ; ELSEIF (i < (len - 1)) THEN chr_code2 := charrep str@(i + 1) ; IF (chr_code2 < 0) THEN chr_new := char (chr_code chr_code2) ; flags@1 := in_unicode_2chrs chr_new ; execute symExtract_array@(flags) ; flags@1 := 0 ; i := i + 1 ; ELSE % at present there are no valid single-code unicodes ; chr_new := string str@i ; execute symExtract_array@(flags) ; flags@1 := 0 ; ENDIF ; ELSE % at present there are no valid single-code unicodes ; chr_new := string str@i ; execute symExtract_array@(flags) ; flags@1 := 0 ; ENDIF ; ELSEIF (in str@i chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_stop_paren) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSE % non-[chrs_blank,chrs_alphaNumUnder,chrs_[strt,stop]_paren] characters ; flags@1 := 0 ; execute symExtract_array@(flags) ; ENDIF ; %write_debug link link 'chr= ' char ' ' (string chr_code) ', flags_[mid,new],n_paren= ' str@i ' ' (EACH string flags_mid) ' ' (EACH string flags) ' ' (string n_paren) ', symNew= ' symNew ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symContentList := EACH symParen_contents symParenList ; symExStr_List := EACH symExtractString symContentList ; symList := link symList (link symExStr_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; write link 'symExtractstring recurLevel null string input: ' symExtractString_recurLevel ; ENDIF ; % ; symList } 10May2018 chrs_symbols_HFLN := link chrs_alphaNumUnder chrs_Greek_all '∬∮∂∫' ; % Howell's Flat-Liner Notation ; qnial> in_string '∬' chrs_unicode3 l qnial> symExtract_string_test #+-----+ symExtract_string_test, Thu May 10 13:21:39 2018 # symExtract_string_test example 1 : OK - result matches standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|Bi|r|v|t|E0|r|t| +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|Bi|r|v|t|E0|r|t| +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ # symExtract_string_test example 2 : OK - result matches standard t_input, t_standard, t_result = e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ |e|2|r|b|r|r|b|r2|r1|2|6|Bpe|2|Bep|2|3|2|π| +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ |e|2|r|b|r|r|b|r2|r1|2|6|Bpe|2|Bep|2|3|2|π| +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ # symExtract_string_test example 3 : OK - result matches standard t_input, t_standard, t_result = (a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3) +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ |a|a1|n1|a2|n2|a3|n3|∂|∂x1|n1|∂|∂x2|n2|∂|∂x3|n3| +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ |a|a1|n1|a2|n2|a3|n3|∂|∂x1|n1|∂|∂x2|n2|∂|∂x3|n3| +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ # symExtract_string_test example 4 : FAILED - result does NOT match standard t_input, t_standard, t_result = 2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t) )^4 +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- |2a1a|E0ods(POIo,t=0)|3|4|beta|2|Vons|c|Rocs(POIo)|Rpcs(POIo,t=0)|1|sin(AOpc(POIo,t))|4|E0ods|POIo|t|0|Rocs|PO +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- --+----+----+-+-+---+------------+----+----+-+ Io|Rpcs|POIo|t|0|sin|AOpc(POIo,t)|AOpc|POIo|t| --+----+----+-+-+---+------------+----+----+-+ +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- |2a1a|E0ods(POIo,t=0)|3|4|beta|2|Vons|c|Rocs(POIo)|Rpcs(POIo,t=0)|1|sin(AOpc(POIo,t))|4|E0ods|POIo|t|0|Rocs|PO +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- --+----+----+-+-+---+----+----+-+ Io|Rpcs|POIo|t|0|sin|AOpc|POIo|t| --+----+----+-+-+---+----+----+-+ # symExtract_string_test example 5 - $ commented-out string so null result when "unprotected" : OK - result matches standard t_input, t_standard, t_result = $ = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] # symExtract_string_test example 6 - $ commented-out string but "protected" : FAILED - result does NOT matc h standard t_input, t_standard, t_result = = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] +----+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+----+--------+-+- |r|r|sinO|∂|∂O(sinO*Ei(rp,t)·Pp)|∂|∂P(Ei(rp,t)·O)|∂O|sinO|Ei(rp,t)|Pp|Ei|rp|t|∂P|Ei(rp,t)|O|E +----+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+----+--------+-+- -+--+-+ i|rp|t| -+--+-+ +----+-+----+---+-----------------------+---+-----------------+----+----+--+--+-+--+----+--+--+-+-+ |r|r|sinO|∂|∂O(sinO*Ei(rp,t)·Pp)|∂|∂P(Ei(rp,t)·O)|∂O|sinO|Ei|rp|t|Pp|∂P|Ei|rp|t|O| +----+-+----+---+-----------------------+---+-----------------+----+----+--+--+-+--+----+--+--+-+-+ # symExtract_string_test example 7 : FAILED - result does NOT match standard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) +-------------------------+--+----+----------+---+--+----+-----+-+--+--+-+ |∮(·dl, over ∂Σ : E)|dA|over|dp[dt : B]|∮|dl|over|∂Σ|E|dp|dt|B| +-------------------------+--+----+----------+---+--+----+-----+-+--+--+-+ +-------------------------+-----------------------------+---+--+----+-----+-+---+--+----+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|∮|dl|over|∂Σ|E||dA|over|dp|dt|B| +-------------------------+-----------------------------+---+--+----+-----+-+---+--+----+--+--+-+ # symExtract_string_test example 8 ] - last char is symValid unicode : FAILED - result does NOT match stand ard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) + ζ +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+- |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|ζ|∮|dl|over|∂Σ|E||dA|over|dp[dt : B]|dp|dt|B +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+- + | + +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|ζ|∮|dl|over|∂Σ|E||dA|over|dp|dt|B| +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+--+--+-+ # symExtract_string_test example 9 : OK - result matches standard t_input, t_standard, t_result = *(vrp)/ +-+--+ |v|rp| +-+--+ +-+--+ |v|rp| +-+--+ >> OK, so the unicode problem is solved? (I hope!) plus I have much simpler code >> works : [1-3,5] >> fails : [4,6-9] go to end-point recursion for deeper symbols, but missing intermediate composite symbols. Note that parenthesis are properly interpreted Now for intermediate recursion composite symbols - why is it failing? looking at code symParenList := syms_inParens symList ; symContentList := EACH symParen_contents symParenList ; symExStr_List := EACH symExtractString symContentList ; symList := link symList (link symExStr_List) ; >> change to : symParenList := syms_inParens symList ; symContentList := EACH symParen_contents symParenList ; symExStr_List := link EACHRIGHT symExtractString symParenList symContentList ; symList := link symList (link symExStr_List) ; 10May2018 14:15 symExtractString IS OP str { LOCAL chr_code chr_code2 chr_new dim_flags flags flags_mid i len n_paren symParenList symList symNew ; NONLOCAL sym_chrs chrs_alphaNumUnder chrs_stop_paren chrs_strt_paren symExtract_array symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; % ; %------------ ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; dim_flags := gage shape shape symExtract_array ; flags := dim_flags reshape 0 ; flags_old := flags ; n_paren := 0 ; len := gage shape str ; i := 0 ; % ; WHILE (i < len) DO flags_mid := flags ; chr_code := charrep str@i ; IF (chr_code < 0) THEN chr_code2 := charrep str@(i + 1) ; IF (chr_code2 < 0) THEN chr_code3 := charrep str@(i + 2) ; IF (chr_code3 < 0) THEN chr_new := char (chr_code chr_code2 chr_code3) ; i := i + 2 ; ELSE chr_new := char (chr_code chr_code2 ) ; i := i + 1 ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; chr_new := string chr_new ; IF (in_string chr_new chrs_blank) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; ELSEIF (in_string chr_new chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_stop_paren) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSE % non-[chrs_blank,chrs_alphaNumUnder,chrs_[strt,stop]_paren] characters ; flags@1 := 0 ; execute symExtract_array@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_List := EACH symExtractString symParenList ; symList := link symList (link symExStr_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList } 10May2018 14:32 qnial> symExtract_string_test #+-----+ symExtract_string_test, Thu May 10 14:32:01 2018 # symExtract_string_test example 1 : OK - result matches standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|Bi|r|v|t|E0|r|t| +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|Bi|r|v|t|E0|r|t| +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ # symExtract_string_test example 2 : OK - result matches standard t_input, t_standard, t_result = e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ |e|2|r|b|r|r|b|r2|r1|2|6|Bpe|2|Bep|2|3|2|π| +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ |e|2|r|b|r|r|b|r2|r1|2|6|Bpe|2|Bep|2|3|2|π| +-+-+-+-+-+-+-+--+--+-+-+---+-+---+-+-+-+--+ # symExtract_string_test example 3 : OK - result matches standard t_input, t_standard, t_result = (a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3) +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ |a|a1|n1|a2|n2|a3|n3|∂|∂x1|n1|∂|∂x2|n2|∂|∂x3|n3| +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ |a|a1|n1|a2|n2|a3|n3|∂|∂x1|n1|∂|∂x2|n2|∂|∂x3|n3| +-+--+--+--+--+--+--+---+-----+--+---+-----+--+---+-----+--+ # symExtract_string_test example 4 : OK - result matches standard t_input, t_standard, t_result = 2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t))^4 +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- |2a1a|E0ods(POIo,t=0)|3|4|beta|2|Vons|c|Rocs(POIo)|Rpcs(POIo,t=0)|1|sin(AOpc(POIo,t))|4|E0ods|POIo|t|0|Rocs|PO +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- --+----+----+-+-+---+------------+----+----+-+ Io|Rpcs|POIo|t|0|sin|AOpc(POIo,t)|AOpc|POIo|t| --+----+----+-+-+---+------------+----+----+-+ +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- |2a1a|E0ods(POIo,t=0)|3|4|beta|2|Vons|c|Rocs(POIo)|Rpcs(POIo,t=0)|1|sin(AOpc(POIo,t))|4|E0ods|POIo|t|0|Rocs|PO +----+---------------+-+-+----+-+----+-+----------+--------------+-+-----------------+-+-----+----+-+-+----+-- --+----+----+-+-+---+------------+----+----+-+ Io|Rpcs|POIo|t|0|sin|AOpc(POIo,t)|AOpc|POIo|t| --+----+----+-+-+---+------------+----+----+-+ # symExtract_string_test example 5 - $ commented-out string so null result when "unprotected" : OK - result matches standard t_input, t_standard, t_result = $ = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] # symExtract_string_test example 6 - $ commented-out string but "protected" : OK - result matches standard t_input, t_standard, t_result = = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] +----+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+---+--+-+ |r|r|sinO|∂|∂O(sinO*Ei(rp,t)·Pp)|∂|∂P(Ei(rp,t)·O)|∂O|sinO|Ei(rp,t)|Pp|Ei|rp|t|∂P|Ei(rp,t)|O|Ei|rp|t| +----+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+---+--+-+ +----+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+--+--+-+ |r|r|sinO|∂|∂O(sinO*Ei(rp,t)·Pp)|∂|∂P(Ei(rp,t)·O)|∂O|sinO|Ei(rp,t)|Pp|Ei|rp|t|∂P|Ei(rp,t)|O|Ei|rp|t| +----+-+----+---+-----------------------+---+-----------------+----+----+--------+--+--+--+-+--+--+-+ # symExtract_string_test example 7 : OK - result matches standard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) +-------------------------+-----------------------------+---+--+----+-----+-+---+--+----+----------+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|∮|dl|over|∂Σ|E||dA|over|dp[dt : B]|dp|dt|B| +-------------------------+-----------------------------+---+--+----+-----+-+---+--+----+----------+--+--+-+ +-------------------------+-----------------------------+---+--+----+-----+-+---+--+----+----------+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|∮|dl|over|∂Σ|E||dA|over|dp[dt : B]|dp|dt|B| +-------------------------+-----------------------------+---+--+----+-----+-+---+--+----+----------+--+--+-+ # symExtract_string_test example 8 - last char is symValid in_unicode_3chrs character : OK - result matches standard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) + ζ +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|ζ|∮|dl|over|∂Σ|E||dA|over|dp[dt : B]|dp|dt|B +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|ζ|∮|dl|over|∂Σ|E||dA|over|dp[dt : B]|dp|dt|B +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ # symExtract_string_test example 9 - last char is symValid in_unicode_2chrs character : OK - result matches standard t_input, t_standard, t_result = ∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) + Ψ +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|Ψ|∮|dl|over|∂Σ|E||dA|over|dp[dt : B]|dp|dt|B | +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ |∮(·dl, over ∂Σ : E)|(·dA, over : dp[dt : B] )|Ψ|∮|dl|over|∂Σ|E||dA|over|dp[dt : B]|dp|dt|B | +-------------------------+-----------------------------+--+---+--+----+-----+-+---+--+----+----------+--+--+-+ # symExtract_string_test example 10 : OK - result matches standard t_input, t_standard, t_result = *(vrp)/ +-+--+ |v|rp| +-+--+ +-+--+ |v|rp| +-+--+ >> ALL are good, and that's good!! +-----+ 06May2018 from March or April - quick reference so I don't have to page up & down file # symExtract_2D IS - logic table of expressions (IS" included to put out with grep, actually is ":=") # flags = in_sym in_[chrs_symbols_HFLN,valid_unicode] in_paren symExtract_2D := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write ''symExtract_string ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew chr_new ; flags@0 := 1 ; ' '(0 1 1) ; write ''symExtract_string ; error with flags@2'' ; ' '(1 0 0) ; symList := link symList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew chr_new ; ' '(1 1 0) ; symNew := link symNew chr_new ; ' '(1 1 1) ; symNew := link symNew chr_new ; ' ; symExtract_array := symExtract_2D ; # see also "/media/bill/PROJECTS/Qnial/code development/strings - unicode usage.txt" ************************** 20May2018 08:15 remove all references to flag_strProtected from "symbols translate.ndf" and "symbols extract.ndf" copy content of symExtractString into symExtract_string # symExtractString IS OP str - to extract a list of [all, known, unknown] symbols from a string, # with reference to a dictionary, ignoring comments and descriptions # 17Apr2018 - want this generalised to any dimension of symExtract_array %write 'loading symExtract_string' ; # flags = (# in_sym in_unicode in_paren) ; symExtractString IS OP str { LOCAL chr_code chr_code2 chr_new dim_flags flags i len n_paren symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren symExtract_array symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %----------write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; % ; %------------ ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; dim_flags := gage shape shape symExtract_array ; flags := dim_flags reshape 0 ; n_paren := 0 ; len := gage shape str ; i := 0 ; % ; WHILE (i < len) DO chr_code := charrep str@i ; IF (chr_code < 0) THEN chr_code2 := charrep str@(i + 1) ; IF (chr_code2 < 0) THEN chr_code3 := charrep str@(i + 2) ; IF (chr_code3 < 0) THEN chr_new := char (chr_code chr_code2 chr_code3) ; i := i + 2 ; ELSE chr_new := char (chr_code chr_code2 ) ; i := i + 1 ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; chr_new := string chr_new ; IF (in_string chr_new chrs_blank) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; ELSEIF (in_string chr_new chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_stop_paren) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSE % non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; flags@1 := 0 ; execute symExtract_array@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_List := EACH symExtractString symParenList ; symList := link symList (link symExStr_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList } # useful debugging output : EACH write 'symExtractString_recurLevel, symList= ' (link symExtractString_recurLevel symList) ; EACH write 'symParenList= ' symParenList ; EACH write 'symContentList= ' symContentList ; EACH write 'symExStr_List= ' symExStr_List ; # not used any more %symContentList := EACH symParen_contents symParenList ; 08********08 #] 20May2018 from 19May2018 I have a problem with substitutions WITHIN symbols (YIKES!!!!) see "symbols translate - coding development.txt" I need to code this: # symExprExtract_stringPosn IS OP symExpr str - extracts [symbols,expressions] from str amd prides position of each # - decides whether [normal, protected] lines are extracted, or if null is simply returned # 20May2018 start with code from symExtract_string, but this is non-recursive "symbols extract- tests.ndf" : copy "symExtract_string" to "symExprExtract_stringPosn" adapt the code Quick mods then check loaddefs : qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' >>> loading start : symbols translate- tests.ndf >>>>>> loading start : strings.ndf >>>>>>>>> loading start : file_ops.ndf <<<<<<<<< loading ended : file_ops.ndf <<<<<< loading ended : strings.ndf >>>>>> loading start : symbols translate.ndf >>>>>>>>> loading start : symbols stdForm.ndf <<<<<<<<< loading ended : symbols stdForm.ndf >>>>>>>>> loading start : symbols extract.ndf <<<<<<<<< loading ended : symbols extract.ndf >>>>>>>>> loading start : tranList Lucas bads.ndf <<<<<<<<< loading ended : tranList Lucas bads.ndf >>>>>>>>> loading start : tranList Lucas to HLFN.ndf <<<<<<<<< loading ended : tranList Lucas to HLFN.ndf >>>>>>>>> loading start : tranList HLFN bads.ndf <<<<<<<<< loading ended : tranList HLFN bads.ndf <<<<<< loading ended : symbols translate.ndf <<< loading ended : symbols translate- tests.ndf "symbols extract- tests.ndf" : copy "symExtract_string_test" to "symExprExtract_stringPosn_test" adapt code - especially t_standard for each example Watch out for cross-over problems with : "symExtractString_recurLevel" OOPS! I already wrotethe code? Park the stuff of today : +-----+ # symExprExtract_decisonTable IS - logic table of expressions (IS" included to put out with grep, actually is ":=") # 20May2018 start with code from symExtract_string, but this is non-recursive # flags = in_sym in_[chrs_symbols_HFLN,valid_unicode] in_paren symExprExtract_decisonTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write ''symExtract_string ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew chr_new ; posnList := link posnList i ; flags@0 := 1 ; ' '(0 1 1) ; write ''symExtract_string ; error with flags@2'' ; ' '(1 0 0) ; symList := link symList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew chr_new ; ' '(1 1 0) ; symNew := link symNew chr_new ; ' '(1 1 1) ; symNew := link symNew chr_new ; ' ; # symExprExtract_stringPosn IS OP symExpr str - extracts [symbols,expressions] from str amd prides position of each # - decides whether [normal, protected] lines are extracted, or if null is simply returned # 20May2018 start with code from symExtract_string, but this is non-recursive symExpr_sub IS OP symExpr str { LOCAL chr_code chr_code2 chr_new dim_flags flags i len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren symExprExtract_decisonTable symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %----------write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; % ; %------------ ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExprExtract_decisonTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; len := gage shape str ; i := 0 ; % ; IF flag_break THEN BREAK ; ENDIF ; WHILE (i < len) DO chr_code := charrep str@i ; IF (chr_code < 0) THEN chr_code2 := charrep str@(i + 1) ; IF (chr_code2 < 0) THEN chr_code3 := charrep str@(i + 2) ; IF (chr_code3 < 0) THEN chr_new := char (chr_code chr_code2 chr_code3) ; i := i + 2 ; ELSE chr_new := char (chr_code chr_code2 ) ; i := i + 1 ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; chr_new := string chr_new ; IF (in_string chr_new chrs_blank) THEN flags@1 := 0 ; execute symExprExtract_decisonTable@(flags) ; ELSEIF (in_string chr_new chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExprExtract_decisonTable@(flags) ; ELSEIF (in str@i chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExprExtract_decisonTable@(flags) ; ELSEIF (in str@i chrs_stop_paren) THEN flags@1 := 0 ; execute symExprExtract_decisonTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSE % non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; flags@1 := 0 ; execute symExprExtract_decisonTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_List := EACH symExtract_string symParenList ; symList := link symList (link symExStr_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } # symExprExtract_stringPosn_test IS - # Notice that unicode has 3-byte chars! # 20May2018 symExprExtract_stringPosn_test IS { LOCAL t_name t_input t_standard t_result ; EACH write '#+-----+' (link 'symExprExtract_stringPosn_test, ' timestamp) ; % ; t_name := '# symExprExtract_stringPosn_test example 1' ; t_input := 'vrp' 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; t_standard := ('Bi(r,v,t)' 'q' 'c' 'v' 'rp' 'rs' '3' 'v' 'c' 'E0(r,t)' 'Bi' 'r' 'v' 't' 'E0' 'r' 't') (0 13 15 18 22 26 29 36 38 43 0 0 0 0 0 0 0 ) ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; } # full test list % ; t_name := '# symExprExtract_stringPosn_test example 1' ; t_input := 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; t_standard := ('Bi(r,v,t)' 'q' 'c' 'v' 'rp' 'rs' '3' 'v' 'c' 'E0(r,t)' 'Bi' 'r' 'v' 't' 'E0' 'r' 't') (0 3 15 18 20 24 27 34 36 39 0 0 0 0 0 0 0 ) ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 2' ; t_input := ' e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) ' ; t_standard := ('e' '2' 'r' 'b' 'r' 'r' 'b' 'r2' 'r1' '2' '6' 'Bpe' '2' 'Bep' '2' '3' '2' 'π') (10 12 15 17 20 23 25 29 34 38 40 42 46 48 52 56 58 60) ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 3' ; t_input := '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' ; t_standard := ('a' 'a1' 'n1' 'a2' 'n2' 'a3' 'n3' '∂' '∂x1' 'n1' '∂' '∂x2' 'n2' '∂' '∂x3' 'n3') ( 1 9 12 17 20 25 28 35 37 41 46 48 52 57 59 63) ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 4' ; t_input := '2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t))^4 ' ; t_standard := ('2a1a' 'E0ods(POIo,t=0)' '3' '4' 'beta' '2' 'Vons' 'c' 'Rocs(POIo)' 'Rpcs(POIo,t=0)' '1' 'sin(AOpc(POIo,t))' '4' 'E0ods' 'POIo' 't' '0' 'Rocs' 'POIo' 'Rpcs' 'POIo' 't' '0' 'sin' 'AOpc(POIo,t)' 'AOpc' 'POIo' 't') () ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 5 - $ commented-out string so null result when "unprotected"' ; t_input := '$ = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' ; t_standard := null null ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 6 - $ commented-out string but "protected"' ; flag_strProtected := l ; t_input := ' = r/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' ; t_standard := ('r' 'r' 'sinO' '∂' '∂O(sinO*Ei(rp,t)·Pp)' '∂' '∂P(Ei(rp,t)·O)' '∂O' 'sinO' 'Ei(rp,t)' 'Pp' 'Ei' 'rp' 't' '∂P' 'Ei(rp,t)' 'O' 'Ei' 'rp' 't') () ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; flag_strProtected := o ; % ; t_name := '# symExprExtract_stringPosn_test example 7' ; t_input := '∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) ' ; t_standard := ('∮(·dl, over ∂Σ : E)' '(·dA, over : dp[dt : B] )' '∮' 'dl' 'over' '∂Σ' 'E' '' 'dA' 'over' 'dp[dt : B]' 'dp' 'dt' 'B') () ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 8 - last char is symValid in_unicode_3chrs character ' ; t_input := '∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) + ζ' ; t_standard := ('∮(·dl, over ∂Σ : E)' '(·dA, over : dp[dt : B] )' 'ζ' '∮' 'dl' 'over' '∂Σ' 'E' '' 'dA' 'over' 'dp[dt : B]' 'dp' 'dt' 'B') () ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 9 - last char is symValid in_unicode_2chrs character ' ; t_input := '∮(·dl, over ∂Σ : E) = (·dA, over : dp[dt : B] ) + Ψ' ; t_standard := ('∮(·dl, over ∂Σ : E)' '(·dA, over : dp[dt : B] )' 'Ψ' '∮' 'dl' 'over' '∂Σ' 'E' '' 'dA' 'over' 'dp[dt : B]' 'dp' 'dt' 'B') () ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# symExprExtract_stringPosn_test example 10' ; t_input := '*(vrp)/' ; t_standard := ('v' 'rp') () ; t_result := symExprExtract_stringPosn t_input ; test_comment t_name t_input t_standard t_result ; +-----+ 22May2018 Re-ran full set of tests except [symExtractCompare_test, symExtract_file_test] via symExtract_alltest >> OK! - all are correct, see "symbols extract_alltest, 180522 15h19m21s.txt" 08********08 #] 23May2018 17:12 Add unicode tests to symExtract_string # 23May2018 unicode lines seek to be a problem (again!), for example : ∂(Area)ÂŽ(∇Ž[Bi(r - v*t,t)v]•np) [symExtract_file Lucas.txt,symDiff bads Lucas.txt] have many problematic symbols (probably almost all of the $ symbols!) and yet, maybe the translation is still working? Have ANY of the bad `$ symbols been translated in "Howell - math of Lucas Universal Force 180523 16h05m58s.txt"?? >> checking ~1/6th of the file - all translations look good, and they are certainly occuring! key lines in symExtract_file_Lucas : IF (= `$ symTrans_lineType) THEN fot_Lucas EACHRIGHT writefile symList ; ELSEIF (= `% symTrans_lineType) THEN fot_HFLN EACHRIGHT writefile symList ; ELSEIF (= `^ symTrans_lineType) THEN fot_Lucas_to_HFLN EACHRIGHT writefile symList ; ENDIF ; >> try some! create a test operator 08********08 #] 23May2018 22:02 symWrite IS OP symList - test of symExtract problem # created to study problem with symbol lists # symWrite IS OP symList { EACHRIGHT picture symList } qnial> fot := open '/media/bill/ramdisk/temp.txt' "w 3 qnial> writefile fot '∮[•dl´,.over.C: E) = -1/c*∂[∂t: ∮[dArea,.over.S: (B•n))' >> In temp.txt : ∮[•dl´,.over.C: E) = -1/c*∂[∂t: ∮[dArea,.over.S: (B•n)) >> this is OK symWrite_test IS { LOCAL t_name t_input t_standard t_result ; fot := open '/media/bill/ramdisk/temp.txt' "a ; fot EACHRIGHT writefile ' ' ' ' '#+-----+' (link 'symWrite_test, ' timestamp_YYMMDD_HMS ) ; % ; t_name := '# example 1' ; t_input := '∮[•dl´,.over.C: E) = -1/c*∂[∂t: ∮[dArea,.over.S: (B•n))' ; t_inter1 := symExtract_string t_input ; write t_inter1 ; t_inter2 := fot EACHRIGHT writefile t_inter1 ; write t_inter2 ; % ; close fot ; } #+-----+ symWrite_test, 180523 22h49m29s ∮[•dl´,.over.C: E) 1 c ∂[∂t: ∮[dArea,.over.S: (B•n)) ∮ dl´ over C E ∂ ∂t ∮[dArea,.over.S: (B•n)) ∮ dArea over S B n >> that worked Maybe the problem is ?? : symList := EACH sym_stdForm symList_line ; +-----+ sym_stdForm IS OP str_symbol { LOCAL chr i str_new ; NONLOCAL chrs_blank ; % ; str_new := '' ; % remove all [spaces,tabs] EXCEPT ensure 1 space around each '-+', retain '.', and following each chrs_stop_paren=')]}>' ; FOR i WITH tell gage shape str_symbol DO chr := str_symbol@i ; IF (in chr chrs_blank) THEN null ; ELSEIF (in chr '+-') THEN str_new := link str_new ' ' chr ' ' ; ELSEIF (in chr ':') THEN str_new := link str_new chr ' ' ; ELSE str_new := link str_new chr ; ENDIF ; ENDFOR ; % ; str_new +-----+ >> A Hah! looks like a problem! 24May2018 for next stage of work, see "/media/bill/PROJECTS/Qnial/code development/symbols stdForm development.txt" ********************************* 24May2018 Conversion over ti usung HFLN_to_Lucas No longer used in "symbols extract.ndf" : +-----+ # symExtract_check_mixed_paragraphs IS OP pname - checks for error of including lines starting with `$ # within contiguous comment paragraphs starting with `# symExtract_check_mixed_paragraphs IS OP pname { LOCAL fin i str ; fin := open pname "r ; i := 0 ; WHILE (~= ??eof (str := readfile fin)) DO i := i + 1 ; IF (= `# str@0) THEN REPEAT str := readfile fin ; i := i + 1 ; IF (= `$ str@0) THEN write link (string i) ' : ' str ; ENDIF ; UNTIL (OR (is_blankstring str) (= ??eof str)) ENDREPEAT ; ENDIF ; ENDWHILE ; close fin ; } # in_unicodes IS OP str - allowable symbol letters (unicode [1,2,3] bytes) # see also "/media/bill/PROJECTS/Qnial/code development/strings - unicode usage.txt" # 18Apr2018 need to fix so numerics must not be first character of a symbol chrs_alphaNumUnder := link chrs_alphabet chrs_numbers chr_underscore; % chr_codes [48-57,65-90,97-122] ; qnial> EACH charrep '∬' '∮' '' '∂' '∫' '' '∇' '·' '' +------------+------------+-------------+-------------+------------+------------+-------------+-------+------- |-30 -120 -84|-30 -120 -82|-18 -126 -108|-30 -120 -126|-30 -120 -85|-18 -123 -99|-30 -120 -121|-62 -73|-18 -12 +------------+------------+-------------+-------------+------------+------------+-------------+-------+------- -----+ 4 -87| -----+ >> YIKES! - I have two different symbols for the integral!! use the bigger one "∫" >> I search & replaced in "Howell - math of Lucas Universal Force 180418.txt", but keep both in in_unicode_3chrs # see "strings.ndf" in_unicode_1chr IS OP str { in_string str 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_' * 1 } in_unicode_2chrs IS OP str { in_string str 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψω' * 1} in_unicode_3chrs IS OP str { in_string str '∫∬∮∂' * 1 } # test lengths of unicodes qnial> EACH (gage shape charrep) 'A' 'Γ' '∂' '' 1 2 3 3 # 27Apr2018 symExtract_file_Lucas_test # flag_strProtected = l for Lucas symbols (lines starting with `$), # = o for other lines # choices of symExtract_arrays - loaddefs ONE of the following for Lucas project!!! loaddefs '/media/bill/PROJECTS/Lucas - Universal Force/symTranList Lucas bads.ndf' ; loaddefs '/media/bill/PROJECTS/Lucas - Universal Force/symTranList HLFN bads.ndf' ; loaddefs '/media/bill/PROJECTS/Lucas - Universal Force/symTranList Lucas to HLFN.ndf' ; # symExtractCompare_test IS OP symClass dname fname_math fname_extension { LOCAL fname_out pname_inn pname_out pname_std pname_dif t_name ; NONLOCAL flag_strProtected ; % ; EACH write_testStr ' ' ' ' '#+-----+' (link '#symExtract_file_Lucas_test ' symClass ' ' timestamp_YYMMDD_HMS ) ; IF (= symClass 'Lucas') THEN flag_strProtected := l ; ELSE flag_strProtected := o ; ENDIF ; pname_inn := link dname fname_math ; fname_out := link 'symExtract ' symClass ' ' timestamp_YYMMDD fname_extension ; pname_out := link d_QNial_temp fname_out ; symExtract_file_Lucas pname_inn pname_out ; symbols_compare_Lucas symClass dname pname_out ; } # old code (diff no longer dones at this stage! It's done in "symbols compare.ndf") loaddefs link d_Lucas 'symTranList Lucas bads.ndf' ; pname_std := link d_Lucas 'Howell - math of Lucas Universal Force, diff ' timestamp_YYMMDD '.txt' ; pname_dif := link d_QNial_temp 'trans_file_diff.txt' ; host link 'diff "' pname_out '" "' pname_std '" ' ; Howell - math of Lucas Universal Force 180517.txt # full list of tests # 17May2018 # symExtractCompare_test 'Lucas' '/media/bill/PROJECTS/Lucas - Universal Force/' 'Howell - math of Lucas Universal Force 180518.txt' ' math of Lucas Universal Force.txt' # 18May2018 # symExtractCompare_test 'Lucas' '/media/bill/PROJECTS/Lucas - Universal Force/' 'Howell - math of Lucas Universal Force 180518.txt' ' math of Lucas Universal Force.txt' # symWrite IS OP symList - test of symExtract problem # created to study problem with symbol lists # 23May2018 22:02 initial symWrite IS OP symList { EACHRIGHT picture symList } +-----+ *************************** 24May2018 I tried to modify sym_stdForm, but that didn't work : qnial> symTranslate_file_Lucas_test diff: /media/bill/PROJECTS/Lucas - Universal Force/symList good HFLN_to_Lucas.txt: No such file or directory diff: /media/bill/PROJECTS/Lucas - Universal Force/symList bads HFLN_to_Lucas.txt: No such file or directory >> Oops, I forgot to do that I redid symTranslate_file_Lucas_test : >> same problem!! So I need to revamp symExtract_string see "/media/bill/PROJECTS/Qnial/MY_NDFS/symbols extract.ndf" qnial> chrs_symbols_HFLN ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧ��Ωαβγδεζηθικλμνξοπρςστυφχψω∬∮´∂∫ >> so the uderscore IS in HFLN but the "Ψ" symbol is still problematic, so remove it ! (I thought that I had done that?) CHANGE the way I define unicode characters!! in "strings.ndf" +-----+ % unicode >1 byte sequences ; chrs_Greek_caps := 'Α' 'Β' 'Γ' 'Δ' 'Ε' 'Ζ' 'Η' 'Θ' 'Ι' 'Κ' 'Λ' 'Μ' 'Ν' 'Ξ' 'Ο' 'Π' 'Ρ' 'Σ' 'Σ' 'Τ' 'Υ' 'Φ' 'Χ' 'Ψ' 'Ω' ; chrs_Greek_small := 'α' 'β' 'γ' 'δ' 'ε' 'ζ' 'η' 'θ' 'ι' 'κ' 'λ' 'μ' 'ν' 'ξ' 'ο' 'π' 'ρ' 'ς' 'σ' 'τ' 'υ' 'φ' 'χ' 'ψ' 'ω' ; % chr_codes [[-50 -111]-[-50 -87] ; chrs_Greek_all := link chrs_Greek_caps chrs_Greek_small ; % chr_codes ; chrs_calculus := '∫' '∮' '∬' '∂' ; chrs_symbols_HFLN := link chrs_alphaNumeric '_' '´' chrs_Greek_all chrs_calculus ; % Howell's Flat-Liner Notation ; +-----+ qnial> chrs_symbols_HFLN:= link chrs_alphaNumeric '_' '´' chrs_Greek_all chrs_calculus +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- |3|4|5|6|7|8|9|_|�|�|Α|Β|Γ|Δ|Ε|Ζ|Η|Θ|Ι|Κ|Λ|Μ|Ν|Ξ|Ο|Π|Ρ|Σ|Σ|Τ|Υ|Φ|Χ|Ψ|Ω|α|β|γ|δ|ε +-+-+-+-+-+-+-+-+-+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---+---+---+---+ |ζ|η|θ|ι|κ|λ|μ|ν|ξ|ο|π|ρ|ς|σ|τ|υ|φ|χ|ψ|ω|∫|∮|∬|∂| +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---+---+---+---+ >> The forward apostrophe is a problem - change to a simple apostrophe? What about Qnial problems with readfile? shouldn't be a problem. >> I made the change, now to replace in "Howell - math of Lucas Universal Force 180518.txt" in "strings.ndf" +-----+ % unicode >1 byte sequences ; chrs_Greek_caps := 'Α' 'Β' 'Γ' 'Δ' 'Ε' 'Ζ' 'Η' 'Θ' 'Ι' 'Κ' 'Λ' 'Μ' 'Ν' 'Ξ' 'Ο' 'Π' 'Ρ' 'Σ' 'Σ' 'Τ' 'Υ' 'Φ' 'Χ' 'Ψ' 'Ω' ; chrs_Greek_small := 'α' 'β' 'γ' 'δ' 'ε' 'ζ' 'η' 'θ' 'ι' 'κ' 'λ' 'μ' 'ν' 'ξ' 'ο' 'π' 'ρ' 'ς' 'σ' 'τ' 'υ' 'φ' 'χ' 'ψ' 'ω' ; chrs_Greek_all := link chrs_Greek_caps chrs_Greek_small ; chrs_calculus := '∫' '∮' '∬' '∂' ; % Howell's Flat-Liner Notation : ; chrs_symbols_HFLN := link (EACH string chrs_alphaNumeric) '_' '''' chrs_Greek_all chrs_calculus ; % to see chr_codes : qnial> mix EACHBOTH pair chrs_symbols_HFLN a ; # 24May2018 15:07 WARNING!! >> I still have some problems with unicode # see also "/media/bill/PROJECTS/Qnial/code development/strings - unicode usage.txt" +-----+ Re-load and re-try symTranslate_file_Lucas_test : >> OOPS, forgot code changes in [symExtract_string,sym_stdForm] New code : +-----+ WHILE (i < len) DO chr_code1 := charrep str@i ; IF (chr_code1 < 0) THEN chr_code2 := charrep str@(i + 1) ; IF (chr_code2 < 0) THEN chr_code3 := charrep str@(i + 2) ; IF (chr_code3 < 0) THEN chr_code := chr_code1 chr_code2 chr_code3 ; i := i + 2 ; ELSE chr_code := chr_code1 chr_code2 ; i := i + 1 ; ENDIF ; ELSE chr_code := chr_code1 ; ENDIF ; ELSE chr_code := chr_code1 ; ENDIF ; chr_new := char chr_code ; +-----+ Re-load and re-try symTranslate_file_Lucas_test : >> NUTS!! same problem symExtract_file [*].txt are still all empty - extraction didn't work! Break-trace Identify the original string of a problematic line. ∮[*(A_cap/2/π*dφ)′: ∂[∂(t): Bi(r - v*t,t)]•n′) >> may be from : = -1/c*A_cap/2/π *∮[*dφ′ : dp[dt : Bi(r - v*t,t)]•n′) >> Note : A_cap is the actual symbol, but I get "A cap"?? WRONG! # symExtract_string_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = = -1/c*A_cap/2/π *∮[*dφ′ : dp[dt : Bi(r - v*t,t)]•n′) +-+--+ |v|rp| +-+--+ >> No output now!?? >> Do full test : >> Nope Break-trace Ah Hah, change : ELSEIF (in_string chr_new chrs_symbols_HFLN) THEN to : ELSEIF (in chr_new chrs_symbols_HFLN) THEN >> Still doesn't work >> WAIT! check symTranslate_string_test which has similar unicode code +-----+ qnial> sym_stdForm_test # example 1 : OK - result matches standard t_input, t_standard, t_result = ∮[•dl´,.over.C: E) = -1/c*∂[∂t: ∮[dArea,.over.S: (B•n)) +-----------------------+-+-+-------------------------------------+---+----+----+-+-+---+----+---------------------------+---+-----+----+-+-+-+ |∮[•dl´,.over.C: E)|1|c|∂[∂t: ∮[dArea,.over.S: (B•n))|∮|dl´|over|C|E|∂|∂t|∮[dArea,.over.S: (B•n))|∮|dArea|over|S|B|n| +-----------------------+-+-+-------------------------------------+---+----+----+-+-+---+----+---------------------------+---+-----+----+-+-+-+ +-----------------------+-+-+-------------------------------------+---+----+----+-+-+---+----+---------------------------+---+-----+----+-+-+-+ |∮[•dl´,.over.C: E)|1|c|∂[∂t: ∮[dArea,.over.S: (B•n))|∮|dl´|over|C|E|∂|∂t|∮[dArea,.over.S: (B•n))|∮|dArea|over|S|B|n| +-----------------------+-+-+-------------------------------------+---+----+----+-+-+---+----+---------------------------+---+-----+----+-+-+-+ +------+ >> it works, so problem is symExtract_string (so does symExprExtract_stringPosn!!) 24May2018 19:30 Finally - I fixed [chrs_symbols_HFLN,chrs_unicodes_HFLN,sym_stdForm] and symTranslate_file_Lucas_test WORKS!!! YAHOO!! **************************************** 03Jun2018 compare : symExtract_string IS OP str symExprExtract_stringPosn IS OP symExpr str $ cd "/media/bill/PROJECTS/Qnial/code develop_test/" $ diff "symExtract_string IS OP str.txt" "symExprExtract_stringPosn IS OP symExpr str.txt" +-----+ 1c1 < /media/bill/PROJECTS/Qnial/code develop_test/symExtract_string IS OP str.txt --- > /media/bill/PROJECTS/Qnial/code develop_test/symExprExtract_stringPosn IS OP symExpr str.txt 4,5c4,7 < #******************************* < # symExtract_decisonTable IS - logic table of expressions (IS" included to put out with grep, actually is ":=") --- > #*************************************************** > # symExprExtract_decisonTable IS - logic table of expressions (IS" included to put out with grep, actually is ":=") > # 20May2018 start with code from symExtract_string, but this is non-recursive > 7d8 < # 02Jun2018 WWARNING: if symbol separated from parenthetical expression by blanks, the latter are not treated as arguments! 9c10 < symExtract_decisonTable := 2 2 2 reshape --- > symExprExtract_decisonTable := 2 2 2 reshape 11,13c12,14 < '(0 0 1) ; write ''symExtract_string ; error with flags@2'' ; ' < '(0 1 0) ; symNew := link symNew chr_new ; flags@0 := 1 ; ' < '(0 1 1) ; write ''symExtract_string ; error with flags@2'' ; ' --- > '(0 0 1) ; write ''symExprExtract_stringPosn ; error with flags@2'' ; ' > '(0 1 0) ; symNew := link symNew chr_new ; posnList := link posnList i ; flags@0 := 1 ; ' > '(0 1 1) ; write ''symExprExtract_stringPosn ; error with flags@2'' ; ' 21,23c22,26 < #******************************* < # symExtract_string IS OP str - decides whether [normal, protected] lines are extracted, or if null is simply returned < # 21May2018 missing checks on index for unicode stuff --- > #*************************************************** > # symExprExtract_stringPosn IS OP symExpr str - extracts [symbols,expressions] from str and lists position of each > # - very handy when working with symExtrs and need positions to test operators > # 20May2018 start with code from symExtract_string, but this is non-recursive! > # (doesn't list sub-component positions, which it should!) 26,27d28 < symExtractString_recurLevel := -1 ; < 29,31c30,31 < < symExtract_string IS OP str < { LOCAL chr_code chr_code1 chr_code2 chr_code3 chr_new dim_flags flags i jump len n_paren --- > symExprExtract_stringPosn IS OP symExpr str > { LOCAL chr_code chr_code2 chr_new dim_flags flags i jump len n_paren posnList 33,34c33 < NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren < symExtract_decisonTable symExtractString_recurLevel ; --- > NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren symExprExtract_decisonTable symExtractString_recurLevel ; 44c43,44 < dim_flags := gage shape shape symExtract_decisonTable ; --- > posnList := null ; > dim_flags := gage shape shape symExprExtract_decisonTable ; 54,55c54,55 < execute symExtract_decisonTable@(flags) ; < ELSEIF (in chr_new chrs_symbols_HFLN) THEN --- > execute symExprExtract_decisonTable@(flags) ; > ELSEIF (in_string chr_new chrs_symbols_HFLN) THEN 57,58c57,58 < execute symExtract_decisonTable@(flags) ; < ELSEIF (in_string chr_new chrs_strt_paren) THEN --- > execute symExprExtract_decisonTable@(flags) ; > ELSEIF (in str@i chrs_strt_paren) THEN 61,62c61,62 < execute symExtract_decisonTable@(flags) ; < ELSEIF (in_string chr_new chrs_stop_paren) THEN --- > execute symExprExtract_decisonTable@(flags) ; > ELSEIF (in str@i chrs_stop_paren) THEN 64c64 < execute symExtract_decisonTable@(flags) ; --- > execute symExprExtract_decisonTable@(flags) ; 72c72 < execute symExtract_decisonTable@(flags) ; --- > execute symExprExtract_decisonTable@(flags) ; 89c89,90 < symList --- > chrStrGet_direction := 1 ; > symList posnList 90a92 > +-----+ ********************************* Remove as mostly redundant with respect to symExtract_string # symExprExtract_stringPosn IS OP symExpr str - extracts [symbols,expressions] from str and lists position of each # - very handy when working with symExtrs and need positions to test operators # 20May2018 start with code from symExtract_string, but this is NON-RECURSIVE! # (doesn't list sub-component positions, which it should!) # 03Jun2018 - I had separate operators for [symExtract_string,symExprExtract_stringPosn], but they were almost the same code # rather than debug symExprExtract_stringPosn, I should unify the code and pay a small penalty # 02Jun2018 WARNING: if symbol separated from parenthetical expression by blanks, the latter are not treated as arguments! symExprExtract_stringPosn IS OP symExpr str { LOCAL chr_new dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren symExprExtract_decisonTable symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %----------write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; % ; %------------ ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExprExtract_decisonTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; len := gage shape str ; i := 0 ; % ; WHILE (i < len) DO chr_new jump := chrStr_get 1 i str ; IF (in_string chr_new chrs_blank) THEN flags@1 := 0 ; execute symExprExtract_decisonTable@(flags) ; ELSEIF (in_string chr_new chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExprExtract_decisonTable@(flags) ; ELSEIF (in str@i chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExprExtract_decisonTable@(flags) ; ELSEIF (in str@i chrs_stop_paren) THEN flags@1 := 0 ; execute symExprExtract_decisonTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSE % non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; flags@1 := 0 ; execute symExprExtract_decisonTable@(flags) ; ENDIF ; i := i + jump + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_List := EACH symExtract_string symParenList ; symList := link symList (link symExStr_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } ************************ 24Jun2018 setup again after 3 weeks on [SummerDaze, Dads paintings] and [Duck Lake, Standard] festivals alltest strings 180604 10h59m13s.txt all OK alltest symExtract 180604 10h59m13s.txt FAILED symExtract_stringPosn_test example 3,5,6,7,8,9 alltest symTranslate 180604 10h59m13s.txt symTrans_test example 11 : FAILED - result does NOT match standard symExpr_sub_test example 2 : FAILED - result does NOT match standard symTranslate_string_test examples 1,5,8,9,9a,10 : FAILED - result does NOT match standard First fix symExtract_stringPosn # 26Jun2018 revamped to simply convert str to chrList, get rid of chrStr_get # symExtract_stringPosn IS OP str - decides whether [normal, protected] lines are extracted, or if null is simply returned # 21May2018 missing checks on index for unicode stuff # 02Jun2018 WWARNING: if symbol separated from parenthetical expression by blanks, the latter are not treated as arguments! symExtractString_recurLevel := -1 ; change : +-----+ symExtract_stringPosn IS OP str { LOCAL chr_new dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren symExtract_decisionTable symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; % ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; len := gage shape str ; i := 0 ; % ; WHILE (i < len) DO chr_new jump := chrStr_get 1 i str ; IF (in_string chr_new chrs_blank) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chr_new chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in_string chr_new chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_decisionTable@(flags) ; ELSEIF (in_string chr_new chrs_stop_paren) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + jump + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } symExtract_string IS OP str { first symExtract_stringPosn str } # useful debugging output : EACH write 'symExtractString_recurLevel, symList= ' (link symExtractString_recurLevel symList) ; EACH write 'symParenList= ' symParenList ; EACH write 'symContentList= ' symContentList ; EACH write 'symExStr_List= ' symExStr_List ; +-----+ to : +-----+ symExtract_stringPosn IS OP str { LOCAL chrList dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren symExtract_decisionTable symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; % ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; chrList := EACH string str ; len := gage shape str ; i := 0 ; % ; WHILE (i < len) DO IF (in chrList@i chrs_blank) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_stop_paren) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } +-----+ 26Jun2018 12:36 symExtract_stringPosn : changed chrList@i to (first chrList@i) in conditionals 28Jun2018 08:48 symExtract_stringPosn - modify for str_to_unicodeList see "/media/bill/PROJECTS/Qnial/MY_NDFS/z_Archive/symbols extract 180628.ndf" for intermediate operator >> Now it works! symExtract_string_test, 180628 10h43m26s - I fixed many "t_standard"s, in addition to code adjustments >> This works with NO changes! Change : chrs_paren_strt chrs_strt_paren To : chrs_stop_paren chrs_paren_stop ******************** 25Jul2018 Remove old code # $ sort "/media/bill/ramdisk/symExtract_file intermediate.txt" >"/media/bill/ramdisk/symExtract_file intermediate.txt" # not using these, as symbols validity only well defined within [HFLN,Lucas] contexts!? fot_Lucas_to_HFLN := open pname_Lucas_to_HFLN "w ; fot_HFLN_to_Lucas := open pname_HFLN_to_Lucas "w ; ELSEIF (= `^ symTrans_lineType) THEN fot_Lucas_to_HFLN EACHRIGHT writefile symList ; ELSEIF (= `& symTrans_lineType) THEN fot_HFLN_to_Lucas EACHRIGHT writefile symList ; host link 'sort --unique "' pname_Lucas_to_HFLN '" >"' pname_temp '" ' ; host link 'mv "' pname_temp '" "' pname_Lucas_to_HFLN '" ' ; host link 'sort --unique "' pname_HFLN_to_Lucas '" >"' pname_temp '" ' ; host link 'mv "' pname_temp '" "' pname_HFLN_to_Lucas '" ' ; # got rid of HFLN_to_Lucas,Lucas_to_HFLN] (now in [HFLN,Lucas] files) IF (in str@0 '#$%^&') THEN symTrans_lineType := str@0 ; ENDIF ; # old code pn_goodLtoH := link d_Lucas 'symList good Lucas_to_HFLN.txt' ; pn_badsLtoH := link d_Lucas 'symList bads Lucas_to_HFLN.txt' ; pd_badsLtoH := link d_Qnial_temp 'symDiff bads Lucas_to_HFLN.txt' ; pd_tranLtoH := link d_Qnial_temp 'symDiff tran Lucas_to_HFLN.txt' ; pn_goodHtoL := link d_Lucas 'symList good HFLN_to_Lucas.txt' ; pn_badsHtoL := link d_Lucas 'symList bads HFLN_to_Lucas.txt' ; pd_badsHtoL := link d_Qnial_temp 'symDiff bads HFLN_to_Lucas.txt' ; pd_tranHtoL := link d_Qnial_temp 'symDiff tran HFLN_to_Lucas.txt' ; pd_tranLucas := link d_Qnial_temp 'symDiff tran Lucas.txt' ; pd_tranHFLN := link d_Qnial_temp 'symDiff tran HFLN.txt' ; % ; host link 'diff "' pn_LtoH '" "' pn_english '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_equatnn '" | grep "< " | sed "s/< //" >"' p_temp2 '" ' ; host link 'diff "' p_temp2 '" "' pn_goodLtoH '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_badsLtoH '" | grep "< " | sed "s/< //" >"' pd_badsLtoH '" ' ; % ; host link 'diff "' pn_HtoL '" "' pn_english '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_equatnn '" | grep "< " | sed "s/< //" >"' p_temp2 '" ' ; host link 'diff "' p_temp2 '" "' pn_goodHtoL '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_badsHtoL '" | grep "< " | sed "s/< //" >"' pd_badsHtoL '" ' ; host link 'cp "' pd_badsLtoH '" "' pd_tranLtoH '"' ; host link 'cp "' pd_badsHtoL '" "' pd_tranHtoL '"' ; # 13Jul2018 don't filter out known bads!! - this is old code host link 'diff "' pn_Lucas '" "' pn_english '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_equatnn '" | grep "< " | sed "s/< //" >"' p_temp2 '" ' ; host link 'diff "' p_temp2 '" "' pn_goodLucas '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_badsLucas '" | grep "< " | sed "s/< //" >"' pd_badsLucas '" ' ; % ; host link 'diff "' pn_HFLN '" "' pn_english '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_equatnn '" | grep "< " | sed "s/< //" >"' p_temp2 '" ' ; host link 'diff "' p_temp2 '" "' pn_goodHFLN '" | grep "< " | sed "s/< //" >"' p_temp1 '" ' ; host link 'diff "' p_temp1 '" "' pn_badsHFLN '" | grep "< " | sed "s/< //" >"' pd_badsHFLN '" ' ; % ; host link 'cp "' pd_badsHFLN '" "' pd_tranHFLN '"' ; host link 'cp "' pd_badsLucas '" "' pd_tranLucas '"' ; 08********08 #] 03Aug2018 spaces must indicate new symbol in NOT in_paren : symExtract_stringPosn IS OP str { LOCAL chrList dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max ; % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; chrList := str_to_unicodeList str ; len := gage shape chrList ; i := 0 ; % ; WHILE (i < len) DO IF (in chrList@i chrs_blank) THEN flags@1 := 0 ; IF (= 0 flags@2) THEN flags@0 := 0 ; ENDIF ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } 03Aug2018 17:31 Try again : symExtract_stringPosn IS OP str { LOCAL chrList dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max ; % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; blanks := link chrs_blank ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; chrList := str_to_unicodeList str ; len := gage shape chrList ; in_blanks := o ; i := 0 ; % ; WHILE (i < len) DO IF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN symNew := link symNew ' ' ; ELSEIF (in chrList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } 03Aug2018 17:38 symExtract_stringPosn IS OP str { LOCAL chrList dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max ; % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; blanks := link chrs_blank ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; chrList := str_to_unicodeList str ; len := gage shape chrList ; in_blanks := o ; i := 0 ; % ; WHILE (i < len) DO IF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN symNew := link symNew ' ' ; in_blanks := l ; ELSEIF (in chrList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } 03Aug2018 17:45 symExtract_stringPosn IS OP str { LOCAL chrList dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max ; % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; blanks := link chrs_blank ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; chrList := str_to_unicodeList str ; len := gage shape chrList ; in_blanks := o ; i := 3 ; % ; WHILE (i < len) DO IF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN in_blanks := l ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } OOPS!!! this line had been accidentally illed!!! I put it back : ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; symExtract_stringPosn IS OP str { LOCAL chrList dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max ; % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; blanks := link chrs_blank ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; chrList := str_to_unicodeList str ; len := gage shape chrList ; in_blanks := o ; i := 3 ; % ; WHILE (i < len) DO IF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN in_blanks := l ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } 03Aug2018 18:26 OK - looks good!! EXCEPT - extra spaces added to [-,=,+], for example : ∫{∂(Aθpc),0.to.Aθpcf: cos(Aθpc(POIo(t),t))*Rpcs(POIo(t),t)^( - 4)} ∂[∂(Aθpc): Rpcs(POIo(t),t = 0)] ∂[∂(Aθpc): Rpcs(POIo(t),t)^( - β + 1)] >> take them out! This is caused by sym_stdForm ***************** 28Aug2018 14:29 fix symExtract_stringPosn after modifying sym_stdForm Current status : +-----+ symExtract_stringPosn IS OP str { LOCAL chrList dim_flags flags i jump len n_paren posnList symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max ; % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive callS ; IF (isstring str) THEN % ; blanks := link chrs_blank ; symNew := '' ; symList := null ; posnList := null ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; chrList := str_to_unicodeList str ; len := gage shape chrList ; in_blanks := o ; i := 0 ; % ; IF flag_break THEN BREAK ; ENDIF ; WHILE (i < len) DO IF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN in_blanks := l ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in chrList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_pairs := EACH symExtract_stringPosn symParenList ; symExStr_List := EACH first symExStr_pairs ; symExPosn_List := EACH second symExStr_pairs ; symList := link symList (link symExStr_List) ; posnList := link posnList (link symExPosn_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList posnList } +-----+ Ah Hah!! str_to_unicodeList str >> fails!! >> see "strings- develop.txt" *********************** 30Aug2018 continue edits symExtract_stringPosn IS OP str check on LMDE2 AFTER modification to : str_to_unicodeList IS OP str ***************************** 05Sep2018 13:10 Standard tests of "symbols translate- tests.ndf" where am I? qnial> symExtract_alltest >> Again : failed tests : symExtract_stringPosn_test, 180904 14h19m08s symExtract_string_test, 180904 14h19m08s set break in "symExtract_stringPosn_test" qnial> symExtract_stringPosn_test all treated as '/*' comments, but ['/%' '/$' '/^'] are irrelevant! "symbols extract.ndf" Keep : +-----+ IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; ELSE % treated same as ELSE in first IF ; in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; +-----+ >> as tests could use symTrans_lineType with comments and changes in symTrans_lineType I need to modify the tests. Change : +-----+ symExtract_stringPosn_test IS { LOCAL t_name t_input t_standard t_result ; EACH write_testStr ' ' ' ' '#+-----+' (link 'symExtract_stringPosn_test, ' timestamp_YYMMDD_HMS ) ; % ; t_name := '# symExtract_stringPosn_test example 1' ; t_input := 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; t_standard := mix ('Bi(r,v,t)' 'q' 'c' 'v' 'rp' 'rs' '3' 'v' 'c' 'E0(r,t)' 'Bi' 'r' 'v' 't' 'E0' 'r' 't') ( 0 13 15 18 20 24 27 34 36 39 0 3 5 7 0 3 5 ) ; t_result := mix (symExtract_stringPosn sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; } +-----+ To : +-----+ symExtract_stringPosn_test IS { LOCAL t_name t_input t_standard t_result ; EACH write_testStr ' ' ' ' '#+-----+' (link 'symExtract_stringPosn_test, ' timestamp_YYMMDD_HMS ) ; % ; t_name := '# symExtract_stringPosn_test example 1' ; t_input := '/$Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; t_standard := mix ('Bi(r,v,t)' 'q' 'c' 'v' 'rp' 'rs' '3' 'v' 'c' 'E0(r,t)' 'Bi' 'r' 'v' 't' 'E0' 'r' 't') ( 0 13 15 18 20 24 27 34 36 39 0 3 5 7 0 3 5 ) ; t_result := mix (symExtract_stringPosn sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; } +-----+ Retry qnial> symExtract_stringPosn_test all treated as '/*' comments, but ['/%' '/$' '/^'] are irrelevant! #+-----+ symExtract_stringPosn_test, 180905 08h50m22s # symExtract_stringPosn_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = /%Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q |c |v |rp|rs|3 |v |c |E0(r,t)|Bi|r|v|t|E0|r|t| +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ | 0|13|15|18|20|24|27|34|36| 39| 0|3|5|7| 0|3|5| +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ ?conform +-----+ >> I DON'T get a response, but an error with break : +-----+ ?.. WHILE ( I < Len ) DO IF ( = Chrlist @ I '/' ) THEN (...) -->[nextv] ?.. ( I < Len ) -->[nextv] ?.. I < Len -->[nextv] l l ?.. IF ( = Chrlist @ I '/' ) THEN IF ( ( I + 1 ) < Len ) THEN (...) -->[nextv] ?.. ( = Chrlist @ I '/' ) -->[nextv] ?.. = Chrlist @ I '/' -->[nextv] l l +-----+ >> it does the tests, gets right answeer then continues to next WHILE Move break to after WHILE condition #+-----+ symExtract_stringPosn_test, 180905 09h00m21s ------------------------------------------------------------- Break debug loop: enter debug commands, expressions or type: resume to exit debug loop executes the indicated debug command current call stack : symextract_stringposn_test symextract_stringposn ------------------------------------------------------------- -->[stepv] nextv ?.. %capture the symNew at the end of the line (if there is one) -->[nextv] symNew typeList posnList +-------+-------------------------------+----------------------------+ |E0(r,t)|+--+--+--+--+--+--+--+--+--+--+|3 15 17 20 22 26 29 34 36 39| | ||/%|/%|/%|/%|/%|/%|/%|/%|/%|/%|| | | |+--+--+--+--+--+--+--+--+--+--+| | +-------+-------------------------------+----------------------------+ -->[nextv] ?.. %THIS HAS CHANGED! a triplet of lists is returned by symExtract_stringPosn! -->[nextv] ?.. IF ( = 1 Flags @ 0 ) THEN Symlist := link Symlist ( solitary Symnew ) ; (...) -->[nextv] ?.. ( = 1 Flags @ 0 ) -->[nextv] ?.. = 1 Flags @ 0 -->[nextv] l l ?.. Symlist := link Symlist ( solitary Symnew ) -->[nextv] +---------+-+-+-+--+--+-+-+-+-------+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)| +---------+-+-+-+--+--+-+-+-+-------+ ?.. Posnlist := link Symlist ( solitary I ) -->[nextv] +---------+-+-+-+--+--+-+-+-+-------+--+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|46| +---------+-+-+-+--+--+-+-+-+-------+--+ ?.. % placeholder as this is WRONG! -->[nextv] ?.. Typelist := link Symlist ( solitary Symtrans_linetype ) -->[nextv] +---------+-+-+-+--+--+-+-+-+-------+--+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|/%| +---------+-+-+-+--+--+-+-+-+-------+--+ -->[nextv] ?.. Symparenlist := syms_inparens Symlist -->[nextv] +---------+-------+ |Bi r,v,t |E0 r,t | +---------+-------+ ?.. Symexstr_list Symexposn_list Symextype_list := EACH symextract_stringposn Symparenlist .. then goes to analyse [Bi(r,v,t), E0(r,t)] +-----+ >> wrong [conditions, typeList posnList] Change : +-----+ symExStr_List symExPosn_List symExType_List := EACH symExtract_stringPosn symParenList ; symList posnList typeList := EACHBOTH link (symList posnList typeList) (symExStr_List symExPosn_List symExType_List) ; +-----+ To : +-----+ symExStr_List symExType_List symExPosn_List := EACH symExtract_stringPosn symParenList ; symList typeList posnList ) := EACHBOTH link (symList typeList posnList ) (symExStr_List symExType_List symExPosn_List) ; +-----+ >> keep the order the same in the code to avoid [confusion, mistakes] Why do I now get ?no_value at the end of [symList posnList typeList] ?? >> maybe its the post-WHILE last symbol? +-----+ -->[nextv] symExStr_List symExType_List symExPosn_List ?no_value ?no_value ?no_value +-----+ >> extraction lists are empty - should drop explicitly Test after simple change : Problem of ?no_value +-----+ -->[nextv] +------------------+--------------------+---------------+ |+--+-+-+---------+|+--+--+--+---------+|0 3 5 ?no_value| ||E0|r|t|?no_value|||/%|/%|/%|?no_value|| | |+--+-+-+---------+|+--+--+--+---------+| | +------------------+--------------------+---------------+ ?assignment ?.. Symlist Typelist Posnlist := EACHBOTH link ( Symlist Typelist Posnlist ) ( Symexstr_list Symextype_list Symexposn_list ) -->[nextv] symExStr_List symExType_List symExPosn_List ?no_value ?no_value ?no_value -->[nextv] a := 'a' 'b' 'c' +-+-+-+ |a|b|c| +-+-+-+ -->[nextv] b := '1' '2' '3' +-+-+-+ |1|2|3| +-+-+-+ -->[nextv] c := 1 2 3 1 2 3 -->[nextv] d := 'd' 'e' 'f' +-+-+-+ |d|e|f| +-+-+-+ -->[nextv] e := '4' '5' '6' +-+-+-+ |4|5|6| +-+-+-+ -->[nextv] f := 4 5 6 4 5 6 -->[nextv] EACHBOTH link (a b c) (d e f) +-------------+-------------+-----------+ |+-+-+-+-+-+-+|+-+-+-+-+-+-+|1 2 3 4 5 6| ||a|b|c|d|e|f|||1|2|3|4|5|6|| | |+-+-+-+-+-+-+|+-+-+-+-+-+-+| | +-------------+-------------+-----------+ +-----+ >> note the last eval of [symExStr_List symExType_List symExPosn_List] ?no_value ?no_value ?no_value >> Note that the simple check works : EACHBOTH link (a b c) (d e f) >> There are NO expressions in t_input, perhaps the results should be nulls? This is what the code suggests : Change : +-----+ %stops recursive calls ; ELSE symbList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; +-----+ To : +-----+ %stops recursive calls ; ELSE symbList typeList posnList := null null null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; +-----+ Only in symExtract_stringPosn : I changed [symList symExStr_List symExPosn_List symExType_List] To : [symbList symbListRecur typeListRecur posnListRecur ] Also Change : +-----+ IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; typeList := link typeList (solitary symTrans_lineType) ; posnList := link posnList (solitary i) ; % placeholder as this is WRONG! ; ENDIF ; +-----+ To : +-----+ IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; typeList := link typeList (solitary symTrans_lineType) ; posnList := link posnList (solitary i) ; % placeholder as this is WRONG! ; ENDIF ; +-----+ I moved this BEFOR the outer-IF loop : symbList typeList posnList := null null null ; The FIRST symbol doesn't leave a type for typeList!!! (comment by default) Change : +-----+ IF (= chrList@i '/') THEN IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; ELSE % treated same as ELSE in first IF ; in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; +-----+ To : +-----+ IF (= chrList@i '/') THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN execute symExtract_decisionTable@(flags) ; symTrans_lineType := '/*' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN execute symExtract_decisionTable@(flags) ; symTrans_lineType := '/$' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN execute symExtract_decisionTable@(flags) ; symTrans_lineType := '/%' ; i := i + 1 ; ELSE % treated same as ELSE in first IF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; +-----+ Try this : >> nyet, same problem Change : +-----+ symExtract_decisionTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew chrList@i ; posnList := link posnList i ; typeList := link typeList (solitary symTrans_lineType) ; flags@0 := 1 ; ' '(0 1 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(1 0 0) ; symbList := link symbList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew chrList@i ; ' '(1 1 0) ; symNew := link symNew chrList@i ; ' '(1 1 1) ; symNew := link symNew chrList@i ; ' ; +-----+ To : +-----+ symExtract_decisionTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew chrList@i ; posnList := link posnList i ; typeList := link typeList (solitary symTrans_lineType) ; flags@0 := 1 ; ' '(0 1 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(1 0 0) ; symbList := link symbList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew chrList@i ; ' '(1 1 0) ; symNew := link symNew chrList@i ; ' '(1 1 1) ; symNew := link symNew chrList@i ; ' ; +-----+ *************************** 06Sep2018 16:21 symExtract_stringPosn problems I wrongly added last [typeList, posnList] to [typeList, posnList] Change : +-----+ IF (= 1 flags@0) THEN % I tried (= 1 flags@0), (NOT = null symNew) ; symbList := link symbList (solitary symNew) ; typeList := link typeList (solitary symTrans_lineType) ; posnList := link posnList (solitary i) ; % placeholder as this is WRONG! ; ENDIF ; +-----+ BACK To : +-----+ IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; +-----+ Undo another mistaken change : Change : +-----+ ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; +-----+ To : +-----+ ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; +-----+ Change : +-----+ symExtract_decisionTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew chrList@i ; typeList := link typeList (solitary symTrans_lineType) ; flags@0 := 1 ; posnList := link posnList i ; ' '(0 1 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(1 0 0) ; symbList := link symbList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew chrList@i ; ' '(1 1 0) ; symNew := link symNew chrList@i ; ' '(1 1 1) ; symNew := link symNew chrList@i ; ' ; +-----+ To : +-----+ symExtract_decisionTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew chrList@i ; typeList := link typeList (solitary symTrans_lineType) ; posnList := link posnList (solitary i) ; flags@0 := 1 ; ' '(0 1 1) ; write_testStr ''symExtract_string ; error with flags@2'' ; ' '(1 0 0) ; symbList := link symbList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew chrList@i ; ' '(1 1 0) ; symNew := link symNew chrList@i ; ' '(1 1 1) ; symNew := link symNew chrList@i ; ' ; +-----+ Change : +-----+ %capture the symNew at the end of the line (if there is one) ; %THIS HAS CHANGED! a triplet of lists is returned by symExtract_stringPosn! ; IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symbList ; symbListRecur typeListRecur posnListRecur := EACH symExtract_stringPosn symParenList ; symbList typeList posnList ) := EACHBOTH link (symbList typeList posnList ) (symbListRecur typeListRecur posnListRecur) ; ENDIF ; +-----+ To : +-----+ %capture the symNew at the end of the line (if there is one) ; %THIS HAS CHANGED! a triplet of lists is returned by symExtract_stringPosn! ; IF (= null symList) THEN symbList typeList posnList := null null null ; ELSE IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symbList ; symbListRecur typeListRecur posnListRecur := EACH symExtract_stringPosn symParenList ; symbList typeList posnList := EACHBOTH link (symbList typeList posnList ) (symbListRecur typeListRecur posnListRecur) ; ENDIF ; +-----+ Change : +-----+ symbListRecur typeListRecur posnListRecur := EACHBOTH link symExtract_stringPosn symParenList ; +-----+ To : +-----+ symbListRecur typeListRecur posnListRecur := EACHALL link EACH symExtract_stringPosn symParenList ; +-----+ 06Sep2019 Why are character positions wrong (but close) with symExtract_stringPosn? Might be the unicode characters? - positions are the chrList positions, NOT the str positions, so maybe t_standards should be changed? #+-----+ symExtract_stringPosn_test, 180706 11h16m19s Most recent CORRECT response : +-----+ # symExtract_stringPosn_test example 1 : OK - result matches standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q |c |v |rp|rs|3 |v |c |E0(r,t)|Bi|r|v|t|E0|r|t| +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ | 0|13|15|18|20|24|27|34|36| 39| 0|3|5|7| 0|3|5| +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q |c |v |rp|rs|3 |v |c |E0(r,t)|Bi|r|v|t|E0|r|t| +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ | 0|13|15|18|20|24|27|34|36| 39| 0|3|5|7| 0|3|5| +---------+--+--+--+--+--+--+--+--+-------+--+-+-+-+--+-+-+ +-----+ As of yesterday : +-----+ # symExtract_stringPosn_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |Bi(r,v,t)|q |c |v |rp|rs|3 |v |c |E0(r,t)|Bi|r |v |t |E0|r |t | +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |/% |/%|/%|/%|/%|/%|/%|/%|/%|/% |/%|/%|/%|/%|/%|/%|/%| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ | 0|13|15|18|20|24|27|34|36| 39| 0| 3| 5| 7| 0| 3| 5| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |Bi(r,v,t)|q |c |v |rp|rs|3 |v |c |E0(r,t)|Bi|r |v |t |E0|r |t | +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |/% |/%|/%|/%|/%|/%|/%|/%|/%|/% |/%|/%|/%|/%|/%|/%|/%| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ | 0|12|14|17|19|23|26|31|33| 36| 0| 3| 5| 7| 0| 3| 5| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ +-----+ I must have had a unicode length correction in the past? Nope - looks like spaces are the problem. +-----+ Original in July : ELSEIF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN in_blanks := l ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; +-----+ Current : +-----+ IF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN in_blanks := l ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; +-----+ >> This code has NOT changed!??? Ah-Hah! - but this an error ONLY for `/ as last character of line. Change : +-----+ IF (= chrList@i '/') THEN flags@1 := 0 ; in_blanks := o ; IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; +-----+ To : +-----+ IF (= chrList@i '/') THEN flags@1 := 0 ; in_blanks := o ; IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; execute symExtract_decisionTable@(flags) ; +-----+ Change : +-----+ ELSEIF (AND (NOT in_blanks) (in chrList@i chrs_blank) (= 0 flags@2)) THEN in_blanks := l ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; +-----+ To : +-----+ ELSEIF (in chrList@i chrs_blank) THEN flags@1 := 0 ; IF in_blanks THEN null ; % throw away extra blank ; ELSE in_blanks := l ; IF (= 0 flags@2)) THEN execute symExtract_decisionTable@(flags) ; ELSE null ; % retain one space in parenthesis ; ENDIF ; ENDIF ; +-----+ >> Actually - the new version is functionally the same as the previous, but is more clear about other conditions So back to square one - are the new chrList-based positions the "right answer", or not? expressions will be key : MOST [sym, xprs] cart [extract, tranlate] operators MUST be fed a string str_stdForm in standard format to get proper symbols. These operators REQUIRE str_stdForm input : # symExpr_sub IS OP symExpr_old symExpr_new str_stdForm - substitutes symExpr_new for sub_old in str_stdForm # must ensure that the positions found are NOT immediately [preceded,followed] by chrs_symbols_HFLN # xprs_in IS OP str_stdForm - searches str_stdForm for strings in transExpr_table, and # produces a list of found strings and list of their translations # symTrans IS OP symbol - returns translation of a given symbol, or the symbol itself These operators do NOT require str_stdForm input, they do it IF required (ie input NOT in sym_stdForm # symTranslate_string IS OP str_stdForm - prepares a string and a sed expression # for translate_sed using a dictionary, so all dictionary subs are done These change input to chrList : # symExpr_sub IS OP symExpr_old symExpr_new str_stdForm - substitutes symExpr_new for sub_old in str_stdForm # must ensure that the positions found are NOT immediately [preceded,followed] by chrs_symbols_HFLN **************************** 10Sep2018 symExtract_stringPosn, Dumb-ass - add unicode shape - 1 to i Change : +-----+ ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; +-----+ To : +-----+ ELSEIF (in chrList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; i := i + (gage shape chrList@i) - 1 ; +-----+ >> Result - that wasn't the problem! +-----+ # symExtract_stringPosn_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |Bi(r,v,t)|q |c |v |rp|rs|3 |v |c |E0(r,t)|Bi|r |v |t |E0|r |t | +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |/% |/%|/%|/%|/%|/%|/%|/%|/%|/% |/%|/%|/%|/%|/%|/%|/%| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ | 0|13|15|18|20|24|27|34|36| 39| 0| 3| 5| 7| 0| 3| 5| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |Bi(r,v,t)|q |c |v |rp|rs|3 |v |c |E0(r,t)|Bi|r |v |t |E0|r |t | +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ |/% |/%|/%|/%|/%|/%|/%|/%|/%|/% |/%|/%|/%|/%|/%|/%|/%| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ | 0|12|14|17|19|23|26|31|33| 36| 0| 3| 5| 7| 0| 3| 5| +---------+--+--+--+--+--+--+--+--+-------+--+--+--+--+--+--+--+ +-----+ # 10Sep2018 posnList should have the str_stdForm j, not the chrList i, as required by symExpr_sub Change : +-----+ '(0 1 0) ; symNew := link symNew chrList@i ; typeList := link typeList (solitary symTrans_lineType) ; posnList := link posnList (solitary i) ; flags@0 := 1 ; ' ... IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; j := j + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; ... ENDIF ; i := i + 1 ; ENDWHILE ; +-----+ To : +-----+ '(0 1 0) ; symNew := link symNew chrList@i ; typeList := link typeList (solitary symTrans_lineType) ; posnList := link posnList j ; flags@0 := 1 ; ' ... IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; j := j + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; ... ENDIF ; i := i + 1 ; j := j + (gage shape chrList@i) ; ENDWHILE ; +-----+ NOT required! +-----+ IF in_blanks THEN null ; % throw away extra blank ; +-----+ Oops - extra (last) execute? Change : +-----+ IF (= chrList@i '/') THEN flags@1 := 0 ; in_blanks := o ; IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; j := j + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; execute symExtract_decisionTable@(flags) ; +-----+ To : +-----+ IF (= chrList@i '/') THEN flags@1 := 0 ; in_blanks := o ; IF ((i + 1) < len) THEN IF (= chrList@(i + 1) '*') THEN symTrans_lineType := '/*' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '$') THEN symTrans_lineType := '/$' ; i := i + 1 ; j := j + 1 ; ELSEIF (= chrList@(i + 1) '%') THEN symTrans_lineType := '/%' ; i := i + 1 ; j := j + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; +-----+ ******************************** 11Sep2018 continue with posnList challenge, and formatting of translated text in "strings.ndf" % Howell's Flat-Liner Notation (HFLN) : ; chrs_symbols_HFLN := link chrs_alphaNumeric chrs_Greek_all chrs_calculus ('_' '´') ; unicodes_HFLN := EACH charrep chrs_symbols_HFLN ; unicodes_HFLN_shapes := EACH (gage shape) unicodes_HFLN ; unicodes_HFLN_2 := (2 EACHRIGHT = unicodes_HFLN_shapes) sublist unicodes_HFLN ; unicodes_HFLN_3 := (3 EACHRIGHT = unicodes_HFLN_shapes) sublist unicodes_HFLN ; % HFLN does not currently have 4-byte unicode symbol characters ; chrs_HFLN_2 := EACH char unicodes_HFLN_2 ; chrs_HFLN_3 := EACH char unicodes_HFLN_3 ; % non-HFLN symbols ; chrs_non_HFLN := '•' '·' '´' '' '∇' '∆' '≈' '∞' '≤' '≥' '∈' '∘' ; chrs_bad := '·' '' '' '.' ; chrs_all := link chrs_symbols_HFLN chrs_non_HFLN chrs_bad ; unicodes_ALL := EACH charrep chrs_ALL ; >> This doesn't include : chrs_operators := EACH string '~!@#$%^&:+-*/\|"' ; % chr_codes [126,33-41,etc...] ; chrs_paren_strt := EACH string '([{' ; % chr_codes ??? ; chrs_paren_stop := EACH string ')]}' ; % chr_codes ??? ; chrs_parenthesis := EACH string '()[]{}<>' ; % chr_codes ??? ; chrs_blank := EACH string chr_space chr_tab ; % chr_codes [32,9] ; chrs_punctuation := link chrs_operators chrs_blank chrs_parenthesis ; % chr_codes [126,33-41,etc...] ; chrs_arithmetic := EACH string '*+-/=' ; % chr_codes [42,43,45,47,61] ; chrs_math_spaced := EACH string '+-=' ; % chr_codes [42,43,45,47,61] ; chrs_lineType := EACH string '#$%^' ; % for "symbols translate.ndf -> symTranslate_string" ; BUT - posnList is a position within the ASCII (byte) chrList of str_stdForm, and : # 03Sep2018 NOTE : symExtract_stringPosn MUST be fed a string str_sdForm to get proper symbols! >> otherwise expressions won't be recognized! So - preconvert the symExtract_stringPosn_test examples to sym_stdForm! >> I have already done that! >> but I've stated that : # 03Sep2018 NOTE : symExpr_sub MUST be fed a string str_stdForm in standard format to get proper symbols! >> so I lose ALL formatting in the orginal string... not acceptable symTranslate_file - I am resigned to having expression formats corrupted, but not the entire original string! : +-----+ WHILE ( ~= ??eof (str := readfile fin)) DO line_in := symTranslate_string flag_debug str ; writefile fot line_in ; i := i + 1 ; ENDWHILE ; +-----+ Either live with corrupted formatting fo the entire file when translation does occur -> very EASY to do -> I don't think I need ANY indexes! OR revamp the whole chain of reasoning I STILL want to retain the original formatting, possibly making use of index j +-----+ xprs_ExtractTranslate IS OP str_stdForm -> symTrans : Does NOT need indexing with the str_stdForm -> xprs_ExtractTranslate : -> In order to retain original formatting, the j index is required, not the i index -> I have to convert to sym_stdForm for this operator -> maybe THIS is where posnList should be generated? use xprs_ExtractTranslate IS OP str_stdForm Do I need flag_debug? +-----+ Old code cleanup : +-----+ # %convert symbList back to a normal string ; %28Jun2018 NYET! symbList := EACH link symbList ; (EACH link EACH first symbList) posnList # a := ('∮' '(' '·' 'dl' ',' 'over' '∂Σ') ('r' '´' '/' 'r' '/' 'sinO' ' ' '*' '[') # b := link EACH char EACH charrep a # c := EACH link a +-----+ *********************************************** *********************************************** 12Sep2018 08:31 MAJOR CHANGE!!! - Write a separate systme to "align-format" derivations!!! Abandon tracking of [symbol, expression] positions - translations work in str_stdForm I still need typeList Huge difference : - enormously simplify sym[Extract, Translate] - highly useful for non-aligned derivations and adhoc work day-by-day Just do a file-based approach Hopefully independent of symbol system -> don't have to "recognized" [symbols, expressions] After making code changes and changing tests : qnial> symExtract_stringRecur_test >> recursion now fails!? >> Oops - still have symExtract_stringPosn call within symExtract_stringRecur qnial> symExtract_stringRecur_test >> 3 or 4 tests OK, problem! : +-----+ # symExtract_stringRecur_test example 3 : FAILED - result does NOT match standard t_input, t_standard, t_result = (a·∇) = (a1*n1 + a2*n2 + a3*n3)/∂x1*n1 · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3) +--+--+--+--+--+--+--+-----+--+---+-----+--+---+-----+--+---+-----+--+ |a |a1|n1|a2|n2|a3|n3|∂x1|n1|∂|∂x1|n1|∂|∂x2|n2|∂|∂x3|n3| +--+--+--+--+--+--+--+-----+--+---+-----+--+---+-----+--+---+-----+--+ |/%|/%|/%|/%|/%|/%|/%|/% |/%|/% |/% |/%|/% |/% |/%|/% |/% |/%| +--+--+--+--+--+--+--+-----+--+---+-----+--+---+-----+--+---+-----+--+ +-----+ >> There is no output of t_result!!??? Why? >> oops, t_standard had '/%' instead of '/*' >> that didn't go any farther in processing debug mode : -->[nextv] symExtractString_recurLevel 0 >> so problem occurs during first run through symExtract_stringRecur -->[nextv] symbList -->[nextv] symParenList >> both the above are empty - why? -->[nextv] uniList +-+-+--+---+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+-+-+-+-+-+--+-+---+-+---+-+-+-+-+-+-+- |(|a|·|∇|)| |=| |(|a|1|*|n|1| |+| |a|2|*|n|2| |+| |a|3|*|n|3|)|/|∂|x|1|*|n|1|·|(|∂|/|∂|x|1|*|n|1| |+ +-+-+--+---+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+-+-+-+-+-+--+-+---+-+---+-+-+-+-+-+-+- +-+---+-+---+-+-+-+-+-+-+-+-+---+-+---+-+-+-+-+-+-+ | |∂|/|∂|x|2|*|n|2| |+| |∂|/|∂|x|3|*|n|3|)| +-+---+-+---+-+-+-+-+-+-+-+-+---+-+---+-+-+-+-+-+-+ >> this looks good -->[nextv] i typeList +--++ |71|| +--++ >> shouldn' i be 70? -> NO because i is incremented one greater than lenght of uniList >> OK Confusing - try tests 5 to 10 >> oops - extra spaces in t_standard 7-9 >> getting there - but there are NO spaces around `: : dp[dt:B]. Is this what I want? I thought I had that? +-----+ ELSEIF (in chrList@i chrs_math_spaced) THEN IF (in chrListLast chrs_blank) THEN spc := null ; ELSE spc := ' ' ; ENDIF ; strStdForm := link strStdForm spc chrList@i ' ' ; ELSEIF (= chrList@i ':') THEN strStdForm := link strStdForm chrList@i ' ' ; +-----+ >> Nope - I eliminated it >> I put it back in... >> still didn't work >> Is ':' in chrs_math_spaced? chrs_math_spaced := EACH string '+-=' ; % chr_codes [42,43,45,47,61] ; >> no chrs_operators := EACH string '~!@#$%^&:+-*/\|"' ; % chr_codes [126,33-41,etc...] ; >> not in "symbols extract.ndf" Ah Hah! - `: is NOT a symbol, but instead only appears as part of an expression. Does that affect anything in sym_stdForm? no symExtract_stringRecur - strips out the blank for `:, whereas not for chrs_math_spaced? Turn on "%write uniList ; " in symExtract_stringRecur +-----+ +---+-+--+-+-+-+-+-+-+-+---+--+-+-+-+-+-+-+-+---+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |∮|(|·|d|l|,|o|v|e|r|∂|Σ|:| |E|)| |=| |∫|(|·|d|A|,|o|v|e|r|:| |d|p|[|d|t|:| |B|]|)| +---+-+--+-+-+-+-+-+-+-+---+--+-+-+-+-+-+-+-+---+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +---+-+--+-+-+-+-+-+-+-+---+--+-+-+-+ |∮| |·|d|l|,|o|v|e|r|∂|Σ|:|E| | +---+-+--+-+-+-+-+-+-+-+---+--+-+-+-+ +---+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |∫| |·|d|A|,|o|v|e|r|:|d|p|[|d|t|:|B|]| | +---+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |d|p| |d|t|:|B| | +-+-+-+-+-+-+-+-+ +-----+ so uniList still has space after `: I need tests to see what happens to [chrs_math_spaced, :] in expressions - so I added one (example 11) |∮(·dl,over∂Σ:E+dp[dt:B-∂/∂O(sinO*Ei(rp,t)·Pp-ET(manp,t3)·O)])|Ψ|∮|dl|over∂Σ|E |dp[dt:B-∂/∂O(sinO*Ei(rp,t)·Pp-ET(manp,t3)·O)]|dp|dt|B |∂|∂O(sinO*Ei(rp,t)·Pp-ET(manp,t3)·O)|∂O|sinO|Ei(rp,t)|Pp|ET(manp,t3)|O |Ei|rp|t |ET|manp|t3| >> well, that shows that. symExtract_stringRecur destroys sym_stdForm, so Change : +-----+ IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; +-----+ To : +-----+ IF (= 1 flags@0) THEN symbList := EACH sym_stdForm (link symbList (solitary symNew)) ; ENDIF ; +-----+ Try again symExtract_stringRecur_test : recursed levels don't convert with sym_stdForm revert to " IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; Change : +-----+ IF (~= null symParenList) THEN symbListRecur typeListRecur := EACHALL link EACH symExtract_stringRecur symParenList ; symbList typeList := EACHBOTH link (symbList typeList ) (symbListRecur typeListRecur) ; ENDIF ; +-----+ To : +-----+ IF (~= null symParenList) THEN symbListRecur typeListRecur := EACHALL link EACH symExtract_stringRecur symParenList ; symbList typeList := EACHBOTH link (symbList typeList ) (symbListRecur typeListRecur) ; ENDIF ; symbList := EACH sym_stdForm symbList ; +-----+ Try again symExtract_stringRecur_test : ?conform for [7,8,9] - maybe due to nulls? check with debug recurlevels still not in sy_stdForm... ? >> OK, now only [3,4] fail example 4 - t_standard needs spaces around `= (OK - that fixed problem) example 3 - no t_result. Is this a ?conform problem (would have seen error msg?) flag_break it -->[nextv] symbList >> symbList is null??? -> IDIOT! it was commented out! qnial> b := symExtract_stringRecur sym_stdForm t_input +++ ||| +++ qnial> c := mix b qnial> diagram c + | + | + qnial> shape c 2 0 qnial> d := 2 0 reshape null qnial> = c d l So t_standard should be : 2 0 reshape null +-----+ qnial> symExtract_stringRecur_test #+-----+ symExtract_stringRecur_test, 180912 12h22m25s # symExtract_stringRecur_test example 3a : OK - result matches standard t_input, t_standard, t_result = (a·∇) = (a1*n1 + a2*n2 + a3*n3)/∂x1*n1 · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3) symTrans_lineType = "/$" so there is No symNew. Note the resulting t_standard!! +-----+ >> OK! This works ... ******************************** 12Sep2018 12:29 symExtract_string_test - now try this Change : +-----+ symExtract_string IS OP str_stdForm { symExtractString_recurLevel := -1 ; 2 take (symExtract_stringRecur str_stdForm) } +-----+ To : +-----+ symExtract_string IS OP str_stdForm { symExtractString_recurLevel := -1 ; first (symExtract_stringRecur str_stdForm) } +-----+ Change or all symExtract_string_test : +-----+ t_result := symExtract_string t_input ; +-----+ To : +-----+ t_result := symExtract_string sym_stdForm t_input ; +-----+ qnial> symExtract_string_test #+-----+ symExtract_string_test, 180912 13h36m09s # symExtract_string_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t) +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ |Bi(r,v,t)|q|c|v|rp|rs|3|v|c|E0(r,t)|Bi|r|v|t|E0|r|t| +---------+-+-+-+--+--+-+-+-+-------+--+-+-+-+--+-+-+ >> no t_results flag_break it was missing : NONLOCAL symTrans_lineType ; >> now try full list [4,6,7,8,10] failed of 23 t_standard - fix spaces before `:, around `=, before `) qnial> symExtract_string_test #+-----+ symExtract_string_test, 180912 14h05m40s >> ALL are OK!! Summary of test results : /media/bill/PROJECTS/Qnial/code develop_test/alltest symExtract 180912 14h15m12s.txt, date= 180912 14h15m # symParen_contents_test example 1 : OK - result matches standard # symParen_contents_test example 2 : OK - result matches standard # symParen_contents_test example 3 : OK - result matches standard # symParen_contents_test example 4 : OK - result matches standard # symParen_contents_test example 5 : OK - result matches standard # syms_inParens_test example 1 : OK - result matches standard # syms_inParens_test example 2 : OK - result matches standard # syms_inParens_test example 3 : OK - result matches standard # syms_inParens_test example 4 : OK - result matches standard # syms_inParens_test example 5 : OK - result matches standard # symExtract_stringRecur_test example 1 : OK - result matches standard # symExtract_stringRecur_test example 2 : OK - result matches standard # symExtract_stringRecur_test example 3 : OK - result matches standard # symExtract_stringRecur_test example 3a : OK - result matches standard # symExtract_stringRecur_test example 4 : OK - result matches standard # symExtract_stringRecur_test example 5 : OK - result matches standard # symExtract_stringRecur_test example 6 : OK - result matches standard # symExtract_stringRecur_test example 7 : OK - result matches standard # symExtract_stringRecur_test example 8 : OK - result matches standard # symExtract_stringRecur_test example 9 : OK - result matches standard # symExtract_stringRecur_test example 10 : OK - result matches standard # symExtract_stringRecur_test example 11 : OK - result matches standard # symExtract_string_test example 1 : OK - result matches standard # symExtract_string_test example 2 : OK - result matches standard # symExtract_string_test example 3 : OK - result matches standard # symExtract_string_test example 4 : OK - result matches standard # symExtract_string_test example 5 : OK - result matches standard # symExtract_string_test example 6 : OK - result matches standard # symExtract_string_test example 7 : OK - result matches standard # symExtract_string_test example 8 : OK - result matches standard # symExtract_string_test example 9 : OK - result matches standard # symExtract_string_test example 10 : OK - result matches standard # symExtract_string_test example 11 : OK - result matches standard # symExtract_string_test example 21 : OK - result matches standard # symExtract_string_test example 22 : OK - result matches standard # symExtract_string_test example 23 : OK - result matches standard **************************************** 20Nov2018 strStd_extract_symParnPosn - I need to use symParn positions!!!! trnType is NOT NEEDED to extract viable symParns Actually, I need to revert to an OLD version, as positions are not taken care of in the new operators!!! Use "/media/bill/SEAGATE3_4T/180716 PROJECTS monthly_backup/Qnial/MY_NDFS/symbols extract.ndf" Remove : +-----+ # strStd_extract_symParnRecur IS OP str_stdForm - returns only symbol [characters, type]s (not positions) from a string in standard format # uses strStd_extract_symParnPosn # 03Sep2018 NOTE : strStd_extract_symParn MUST be fed a string str_stdForm in standard format to get proper symbols! strStd_extract_symParnRecur IS OP str_stdForm { LOCAL uniList dim_flags flags i jump len n_paren symNew symParenList symbList typeList symbListRecur typeListRecur ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max trnType ; % ; symbList typeList := null null ; symbListRecur typeListRecur := null null ; % ; IF (isstring str_stdForm) THEN % 12Sep2018 I need to add check that str_stdForm is in str_stdForm!! ; % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive calls ; blanks := link chrs_blank ; symNew := '' ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; uniList := str_to_unicodeList str_stdForm ; %write uniList ; len := gage shape uniList ; in_blanks := o ; i := 0 ; % ; WHILE (i < len) DO IF (= uniList@i '/') THEN flags@1 := 0 ; in_blanks := o ; IF ((i + 1) < len) THEN IF (= uniList@(i + 1) '*') THEN trnType := '/*' ; i := i + 1 ; ELSEIF (= uniList@(i + 1) '$') THEN trnType := '/$' ; i := i + 1 ; ELSEIF (= uniList@(i + 1) '%') THEN trnType := '/%' ; i := i + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; ELSEIF (= trnType '/*') THEN null ; % comments are not output, and don't affect flags ; ELSEIF (in uniList@i chrs_blank) THEN flags@1 := 0 ; in_blanks := l ; IF (= 0 flags@2) THEN execute symExtract_decisionTable@(flags) ; ENDIF ; ELSEIF (in uniList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; ELSEIF (in uniList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in uniList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symbList ; IF (~= null symParenList) THEN symbListRecur typeListRecur := EACHALL link EACH strStd_extract_symParnRecur symParenList ; symbList typeList := EACHBOTH link (symbList typeList ) (symbListRecur typeListRecur) ; ENDIF ; symbList := EACH sym_stdForm symbList ; % ; %------------ ; %stops recursive calls ; ELSE write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symbList typeList } +-----+ # strStd_extract_symParn IS OP strStd - returns [symAtomic, symParn] symbols from a string in standard format # 03Sep2018 NOTE : strStd_extract_symParn MUST be fed a string strStd in standard format to get proper symbols! strStd_extract_symParn IS OP strStd { NONLOCAL symExtractString_recurLevel ; symExtractString_recurLevel := -1 ; first (strStd_extract_symParnRecur strStd) } +-----+ # strStd_extract_symParnRecur IS OP str_stdForm - extracts symbol [characters, type, position]s from a string in standard format # Notice that unicode has 3-byte chars! # 20May2018 # 05Sep2018 must preset the trnType - or results ill be inconsistent strStd_extract_symParnRecur_test IS { LOCAL t_name t_input t_standard t_result ; NONLOCAL trnType ; EACH write_testStr ' ' ' ' '#+-----+' (link 'strStd_extract_symParnRecur_test, ' timestamp_YYMMDD_HMS ) ; % ; t_name := '# strStd_extract_symParnRecur_test example 1' ; trnType := '/%' ; t_input := 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; t_standard := mix ('Bi(r,v,t)' 'q' 'c' 'v' 'rp' 'rs' '3' 'v' 'c' 'E0(r,t)' 'Bi' 'r' 'v' 't' 'E0' 'r' 't') ('/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParnRecur_test example 2' ; trnType := '/%' ; t_input := ' e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) ' ; t_standard := mix ('e' '2' 'r' 'b' 'r' 'r' 'b' 'r2' 'r1' '2' '6' 'Bpe' '2' 'Bep' '2' '3' '2' 'π') ('/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParnRecur_test example 3' ; trnType := '/$' ; t_input := '(a·∇) = (a1*n1 + a2*n2 + a3*n3)/∂x1*n1 · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' ; t_standard := mix ('a' 'a1' 'n1' 'a2' 'n2' 'a3' 'n3' '∂x1' 'n1' '∂' '∂x1' 'n1' '∂' '∂x2' 'n2' '∂' '∂x3' 'n3') ('/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParnRecur_test example 3a' ; trnType := '/*' ; t_input := '(a·∇) = (a1*n1 + a2*n2 + a3*n3)/∂x1*n1 · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' ; t_standard := 2 0 reshape null ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; write_testStr 'trnType = "/$" so there is No symNew. Note the resulting t_standard!!' ; % ; t_name := '# strStd_extract_symParnRecur_test example 4' ; trnType := '/%' ; t_input := '2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t))^4 ' ; t_standard := mix ('2a1a' 'E0ods(POIo,t = 0)' '3' '4' 'beta' '2' 'Vons' 'c' 'Rocs(POIo)' 'Rpcs(POIo,t = 0)' '1' 'sin(AOpc(POIo,t))' '4' 'E0ods' 'POIo' 't' '0' 'Rocs' 'POIo' 'Rpcs' 'POIo' 't' '0' 'sin' 'AOpc(POIo,t)' 'AOpc' 'POIo' 't') ('/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%' '/%') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParnRecur_test example 5' ; trnType := '/$' ; t_input := '$ = r´/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' ; t_standard := mix ('r´' 'r' 'sinO' '∂' '∂O(sinO*Ei(rp,t)·Pp)' '∂' '∂P(Ei(rp,t)·O)' '∂O' 'sinO' 'Ei(rp,t)' 'Pp' 'Ei' 'rp' 't' '∂P' 'Ei(rp,t)' 'O' 'Ei' 'rp' 't') ('/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParnRecur_test example 6' ; trnType := '/$' ; t_input := ' = r´/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' ; t_standard := mix ('r´' 'r' 'sinO' '∂' '∂O(sinO*Ei(rp,t)·Pp)' '∂' '∂P(Ei(rp,t)·O)' '∂O' 'sinO' 'Ei(rp,t)' 'Pp' 'Ei' 'rp' 't' '∂P' 'Ei(rp,t)' 'O' 'Ei' 'rp' 't') ('/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParnRecur_test example 7' ; trnType := '/$' ; t_input := '∮(·dl, over ∂Σ : E) = ∫(·dA, over : dp[dt : B] ) ' ; t_standard := mix ('∮(·dl,over∂Σ: E)' '∫(·dA,over: dp[dt: B])' '∮' 'dl' 'over∂Σ' 'E' '∫' 'dA' 'over' 'dp[dt: B]' 'dp' 'dt' 'B') ('/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; write_testStr 'Note how over∂Σ is merged' ; % ; t_name := '# strStd_extract_symParnRecur_test example 8' ; trnType := '/$' ; t_input := '∮(·dl, over ∂Σ : E) = ∫(·dA, over : dp[dt : B] ) + ζ' ; t_standard := mix ('∮(·dl,over∂Σ: E)' '∫(·dA,over: dp[dt: B])' 'ζ' '∮' 'dl' 'over∂Σ' 'E' '∫' 'dA' 'over' 'dp[dt: B]' 'dp' 'dt' 'B') ('/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; write_testStr ' - last char is symValid in_unicode_3chrs character' ; % ; t_name := '# strStd_extract_symParnRecur_test example 9' ; trnType := '/$' ; t_input := '∮(·dl, over ∂Σ : E) = ∫(·dA, over : dp[dt : B] ) + Ψ' ; t_standard := mix ('∮(·dl,over∂Σ: E)' '∫(·dA,over: dp[dt: B])' 'Ψ' '∮' 'dl' 'over∂Σ' 'E' '∫' 'dA' 'over' 'dp[dt: B]' 'dp' 'dt' 'B') ('/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; write_testStr ' - last char is symValid in_unicode_2chrs character ' ; % ; t_name := '# strStd_extract_symParnRecur_test example 10' ; trnType := '/$' ; t_input := '*(vrp)/' ; t_standard := mix ('v' 'rp') ('/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParnRecur_test example 11' ; trnType := '/$' ; t_input := '∮(·dl, over ∂Σ : E + dp[dt : B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)] ) + Ψ' ; t_standard := mix ('∮(·dl,over∂Σ: E + dp[dt: B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)])' 'Ψ' '∮' 'dl' 'over∂Σ' 'E' 'dp[dt: B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)]' 'dp' 'dt' 'B' '∂' '∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)' '∂O' 'sinO' 'Ei(rp,t)' 'Pp' 'ET(manp,t3)' 'O' 'Ei' 'rp' 't' 'ET' 'manp' 't3') ('/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$' '/$') ; t_result := mix (strStd_extract_symParnRecur sym_stdForm t_input) ; test_comment t_name t_input t_standard t_result ; write_testStr ' - last char is symValid in_unicode_2chrs character ' ; } # full test list - 22May2018 incomplete examples!!! # +-----+ # strStd_extract_symParn IS OP str - returns only symbol [characters, type]s (not positions) from a string in standard format # uses strStd_extract_symParnRecur # 25Apr2018 strStd_extract_symParn_test IS { LOCAL t_name t_input t_standard t_result ; EACH write_testStr ' ' ' ' '#+-----+' (link 'strStd_extract_symParn_test, ' timestamp_YYMMDD_HMS ) ; % ; t_name := '# strStd_extract_symParn_test example 1' ; t_input := 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; t_standard := 'Bi(r,v,t)' 'q' 'c' 'v' 'rp' 'rs' '3' 'v' 'c' 'E0(r,t)' 'Bi' 'r' 'v' 't' 'E0' 'r' 't' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 2' ; t_input := ' e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) ' ; t_standard := 'e' '2' 'r' 'b' 'r' 'r' 'b' 'r2' 'r1' '2' '6' 'Bpe' '2' 'Bep' '2' '3' '2' 'π' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 3' ; t_input := '(a·∇) = (a1*n1 + a2*n2 + a3*n3) · (∂/∂x1*n1 + ∂/∂x2*n2 + ∂/∂x3*n3)' ; t_standard := 'a' 'a1' 'n1' 'a2' 'n2' 'a3' 'n3' '∂' '∂x1' 'n1' '∂' '∂x2' 'n2' '∂' '∂x3' 'n3' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 4' ; t_input := '2a1a) + E0ods(POIo,t=0) * 3/4 *beta^2*Vons/c/Rocs(POIo)*Rpcs(POIo,t=0)^(-1)*sin(AOpc(POIo,t))^4 ' ; t_standard := '2a1a' 'E0ods(POIo,t = 0)' '3' '4' 'beta' '2' 'Vons' 'c' 'Rocs(POIo)' 'Rpcs(POIo,t = 0)' '1' 'sin(AOpc(POIo,t))' '4' 'E0ods' 'POIo' 't' '0' 'Rocs' 'POIo' 'Rpcs' 'POIo' 't' '0' 'sin' 'AOpc(POIo,t)' 'AOpc' 'POIo' 't' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 5' ; t_input := ' = r´/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] ' ; t_standard := 'r´' 'r' 'sinO' '∂' '∂O(sinO*Ei(rp,t)·Pp)' '∂' '∂P(Ei(rp,t)·O)' '∂O' 'sinO' 'Ei(rp,t)' 'Pp' 'Ei' 'rp' 't' '∂P' 'Ei(rp,t)' 'O' 'Ei' 'rp' 't' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 6' ; t_input := '∮(·dl, over ∂Σ : E) = ∫(·dA, over : dp[dt : B]) ' ; t_standard := '∮(·dl,over∂Σ: E)' '∫(·dA,over: dp[dt: B])' '∮' 'dl' 'over∂Σ' 'E' '∫' 'dA' 'over' 'dp[dt: B]' 'dp' 'dt' 'B' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 7' ; t_input := '∮(·dl, over ∂Σ : E) = ∫(·dA, over : dp[dt : B] ) + ζ' ; t_standard := '∮(·dl,over∂Σ: E)' '∫(·dA,over: dp[dt: B])' 'ζ' '∮' 'dl' 'over∂Σ' 'E' '∫' 'dA' 'over' 'dp[dt: B]' 'dp' 'dt' 'B' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; write_testStr ' - last char is invalid in_unicode_3chrs character ' ; % ; t_name := '# strStd_extract_symParn_test example 8' ; t_input := '∮(·dl, over ∂Σ : E) = ∫(·dA, over : dp[dt : B] ) + Ψ' ; t_standard := '∮(·dl,over∂Σ: E)' '∫(·dA,over: dp[dt: B])' 'Ψ' '∮' 'dl' 'over∂Σ' 'E' '∫' 'dA' 'over' 'dp[dt: B]' 'dp' 'dt' 'B' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; write_testStr ' - last char is symValid in_unicode_2chrs character ' ; % ; t_name := '# strStd_extract_symParn_test example 9' ; t_input := '*(vrp)/' ; t_standard := 'v' 'rp' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 10' ; t_input := ' = -1/c*A_cap/2/π *∮[*dφ′ : dp[dt : Bi(r - v*t,t)]•n′)' ; t_standard := '1' 'c' 'A_cap' '2' 'π' '∮[*dφ′: dp[dt: Bi(r - v*t,t)]•n′)' '∮' 'dφ' 'dp[dt: Bi(r - v*t,t)]' 'n' 'dp' 'dt' 'Bi(r - v*t,t)' 'Bi' 'r' 'v' 't' 't' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 11' ; t_input := '∮(·dl, over ∂Σ : E + dp[dt : B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)] ) + Ψ' ; t_standard := ('∮(·dl,over∂Σ: E + dp[dt: B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)])' 'Ψ' '∮' 'dl' 'over∂Σ' 'E' 'dp[dt: B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)]' 'dp' 'dt' 'B' '∂' '∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)' '∂O' 'sinO' 'Ei(rp,t)' 'Pp' 'ET(manp,t3)' 'O' 'Ei' 'rp' 't' 'ET' 'manp' 't3') ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; write_testStr ' - last char is symValid in_unicode_2chrs character ' ; % ; t_name := '# strStd_extract_symParn_test example 21' ; t_input := '∮[•dl´,.over.C: Ei´(r´,t´)) = -1/c*∂[∂t: ∮[dArea,.over.S: (Bi(r - v*t,t)•nh))' ; t_standard := '∮[•dl´,.over.C: Ei´(r´,t´))' '1' 'c' '∂[∂t: ∮[dArea,.over.S: (Bi(r - v*t,t)•nh))' '∮' 'dl´' 'over' 'C' 'Ei´(r´,t´)' 'Ei´' 'r´' 't´' '∂' '∂t' '∮[dArea,.over.S: (Bi(r - v*t,t)•nh))' '∮' 'dArea' 'over' 'S' 'Bi(r - v*t,t)' 'nh' 'Bi' 'r' 'v' 't' 't' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 22' ; t_input := 'B(r´,t´) = (v/c)[ E0(r´,t´) + Ei(r´,t´) ] ' ; t_standard := 'B(r´,t´)' 'v' 'c' 'E0(r´,t´)' 'Ei(r´,t´)' 'B' 'r´' 't´' 'E0' 'r´' 't´' 'Ei' 'r´' 't´' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# strStd_extract_symParn_test example 23' ; t_input := '= ∂[∂(t): Bi(r - v*t,t)] + (v•∇´)*Bi(r - v*t,t) ' ; t_standard := '∂[∂(t): Bi(r - v*t,t)]' 'v' '´' 'Bi(r - v*t,t)' '∂' '∂(t)' 'Bi(r - v*t,t)' '∂' 't' 'Bi' 'r' 'v' 't' 't' 'Bi' 'r' 'v' 't' 't' ; t_result := strStd_extract_symParn sym_stdForm t_input ; test_comment t_name t_input t_standard t_result ; } +-----+ ************************************* Summary of test results : /media/bill/PROJECTS/Qnial/code develop_test/181121 18h46m30s alltest symExtract.txt, date= 181121 18h46m # symParen_contents_test example 1 : OK - result matches standard # symParen_contents_test example 2 : OK - result matches standard # symParen_contents_test example 3 : OK - result matches standard # symParen_contents_test example 4 : OK - result matches standard # symParen_contents_test example 5 : OK - result matches standard # syms_inParens_test example 1 : OK - result matches standard # syms_inParens_test example 2 : OK - result matches standard # syms_inParens_test example 3 : OK - result matches standard # syms_inParens_test example 4 : OK - result matches standard # syms_inParens_test example 5 : OK - result matches standard # strStd_extract_symParnPosn_test example 10 : OK - result matches standard # strStd_extract_symParnPosn_test example 1 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 2 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 3 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 4 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 5 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 6 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 7 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 8 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 9 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 11 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 21 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 22 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 23 : FAILED - result does NOT match standard >> Back to problem of a few months ago when the position calculation was wrong. Look at this tomorrow... ***************************************** 22Nov2018 Change back to 12Sep2018 version without typeLists Change : +-----+ symExtract_decisionTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write_testStr ''strStd_extract_symParn ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew uniList@i ; typeList := link typeList (solitary trnType) ; posnList := link posnList j ; flags@0 := 1 ; ' '(0 1 1) ; write_testStr ''strStd_extract_symParn ; error with flags@2'' ; ' '(1 0 0) ; symbList := link symbList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew uniList@i ; ' '(1 1 0) ; symNew := link symNew uniList@i ; ' '(1 1 1) ; symNew := link symNew uniList@i ; ' ; +-----+ To : +-----+ symExtract_decisionTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write_testStr ''strStd_extract_symParn ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew uniList@i ; posnList := link posnList j ; flags@0 := 1 ; ' '(0 1 1) ; write_testStr ''strStd_extract_symParn ; error with flags@2'' ; ' '(1 0 0) ; symbList := link symbList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew uniList@i ; ' '(1 1 0) ; symNew := link symNew uniList@i ; ' '(1 1 1) ; symNew := link symNew uniList@i ; ' ; +-----+ Change : +-----+ #12Sep2018 - MAJOR CHANGE - no longer trying to maintain original [alignment, formatting] # will just write derivations alignment sofware # keep this "unfinished" version of strStd_extract_symParnPosn strStd_extract_symParnPosn IS OP str_stdForm { LOCAL uniList dim_flags flags i j jump len n_paren symNew symParenList symbList typeList posnList symbListRecur typeListRecur posnListRecur ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel symExtractString_recurLevel_max trnType ; % ; symbList typeList posnList := null null null ; symbListRecur typeListRecur posnListRecur := null null null ; % ; IF (isstring str_stdForm) THEN % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive calls ; blanks := link chrs_blank ; symNew := '' ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; uniList := str_to_unicodeList str_stdForm ; write uniList ; len := gage shape uniList ; in_blanks := o ; i := 0 ; j := 0 ; % ; WHILE (i < len) DO IF (= uniList@i '/') THEN flags@1 := 0 ; in_blanks := o ; IF ((i + 1) < len) THEN IF (= uniList@(i + 1) '*') THEN trnType := '/*' ; i := i + 1 ; j := j + 1 ; ELSEIF (= uniList@(i + 1) '$') THEN trnType := '/$' ; i := i + 1 ; j := j + 1 ; ELSEIF (= uniList@(i + 1) '%') THEN trnType := '/%' ; i := i + 1 ; j := j + 1 ; ELSE % treated same as ELSE in first IF ; execute symExtract_decisionTable@(flags) ; ENDIF ; ENDIF ; ELSEIF (= trnType '/*') THEN null ; % comments are not output, and don't affect flags ; ELSEIF (in uniList@i chrs_blank) THEN flags@1 := 0 ; in_blanks := l ; IF (= 0 flags@2) THEN execute symExtract_decisionTable@(flags) ; ENDIF ; ELSEIF (in uniList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; ELSEIF (in uniList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in uniList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; j := j + (gage shape uniList@i) ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; %THIS HAS CHANGED! a triplet of lists is returned by strStd_extract_symParnPosn! ; IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symbList ; IF (~= null symParenList) THEN IF flag_break THEN BREAK ; ENDIF ; symbListRecur typeListRecur posnListRecur := EACHALL link EACH strStd_extract_symParnPosn symParenList ; symbList typeList posnList := EACHBOTH link (symbList typeList posnList ) (symbListRecur typeListRecur posnListRecur) ; ENDIF ; % ; %------------ ; %stops recursive calls ; ELSE write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symbList typeList posnList } +-----+ To : +-----+ #12Sep2018 - MAJOR CHANGE - no longer trying to maintain original [alignment, formatting] # will just write derivations alignment sofware # keep this "unfinished" version of strStd_extract_symParnPosn strStd_extract_symParnPosn IS OP str_stdForm { LOCAL symbList posnList uniList dim_flags flags i j len n_paren symNew symParenList symbListRecur posnListRecur ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel ; % ; symbList posnList := null null ; symbListRecur posnListRecur := null null ; % ; IF (isstring str_stdForm) THEN % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive calls ; blanks := link chrs_blank ; symNew := '' ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; uniList := str_to_unicodeList str_stdForm ; write uniList ; len := gage shape uniList ; in_blanks := o ; i := 0 ; j := 0 ; % ; WHILE (i < len) DO IF (in uniList@i chrs_blank) THEN flags@1 := 0 ; in_blanks := l ; IF (= 0 flags@2) THEN execute symExtract_decisionTable@(flags) ; ENDIF ; ELSEIF (in uniList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; ELSEIF (in uniList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in uniList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; j := j + (gage shape uniList@i) ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; %THIS HAS CHANGED! a triplet of lists is returned by strStd_extract_symParnPosn! ; IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symbList ; IF (~= null symParenList) THEN symbListRecur posnListRecur := EACHALL link EACH strStd_extract_symParnPosn symParenList ; symbList posnList := EACHBOTH link (symbList posnList ) (symbListRecur posnListRecur) ; ENDIF ; % ; %------------ ; %stops recursive calls ; ELSE write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symbList posnList } +-----+ 22Nov2018 I ran several tests with updates to "symbols extract- tests.ndf" qnial> symExtract_alltest >> Ok, operators run, but sym_stdForm is screwed!! see "symbols system loaddefs- develop.txt" see "strings- develop.txt" for strings_alltest results and fixes **************************************** 26Nov2018 - OK after much head-banging, symn_stdForm seems to work for now So I must now fix : strStd_extract_symParnPosn IS OP str_stdForm Change : +-----+ symExtract_decisionTable := 2 2 2 reshape '(0 0 0) ; null ; ' '(0 0 1) ; write_testStr ''strStd_extract_symParn ; error with flags@2'' ; ' '(0 1 0) ; symNew := link symNew uniList@i ; posnList := link posnList j ; flags@0 := 1 ; ' '(0 1 1) ; write_testStr ''strStd_extract_symParn ; error with flags@2'' ; ' '(1 0 0) ; symbList := link symbList (solitary symNew) ; symNew := null ; flags@0 := 0 ; ' '(1 0 1) ; symNew := link symNew uniList@i ; ' '(1 1 0) ; symNew := link symNew uniList@i ; ' '(1 1 1) ; symNew := link symNew uniList@i ; ' ; strStd_extract_symParnPosn IS OP str_stdForm { LOCAL symbList posnList uniList dim_flags flags i j len n_paren symNew symParenList symbListRecur posnListRecur ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel ; % ; symbList posnList := null null ; symbListRecur posnListRecur := null null ; % ; IF (isstring str_stdForm) THEN % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive calls ; blanks := link chrs_blank ; symNew := '' ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; uniList := str_to_unicodeList str_stdForm ; %write uniList ; len := gage shape uniList ; in_blanks := o ; i := 0 ; j := 0 ; % ; WHILE (i < len) DO IF (in uniList@i chrs_blank) THEN flags@1 := 0 ; in_blanks := l ; IF (= 0 flags@2) THEN execute symExtract_decisionTable@(flags) ; ENDIF ; ELSEIF (in uniList@i chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; in_blanks := o ; ELSEIF (in uniList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; in_blanks := o ; execute symExtract_decisionTable@(flags) ; ELSEIF (in uniList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; in_blanks := o ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE in_blanks := o ; flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; j := j + (gage shape uniList@i) ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; %THIS HAS CHANGED! a triplet of lists is returned by strStd_extract_symParnPosn! ; IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symbList ; IF (~= null symParenList) THEN symbListRecur posnListRecur := EACHALL link EACH strStd_extract_symParnPosn symParenList ; symbList posnList := EACHBOTH link (symbList posnList ) (symbListRecur posnListRecur) ; ENDIF ; % ; %------------ ; %stops recursive calls ; ELSE write link 'symExtractstring ERROR : recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symbList posnList } +-----+ To : +-----+ +-----+ 27Nov2018 11:41 strStd_extract_symParnPosn - recursion not working strStd_extract_symParnPosn ERROR : != str_stdForm (sym_stdForm str_stdForm) >> it appears that the symParenLists aren't in str_stdForm. WHY? >> break trace example 11 (only one recursion) : -->[nextv] symParenList +----------------------------------------------------------------------------------+ |∮ ·dl,over ∂Σ: E + dp[dt: B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)] | +----------------------------------------------------------------------------------+ >> OK - parens etc have been removed Change : +-----+ symParenList := syms_inParens symbList ; +-----+ To : +-----+ symParenList := EACH sym_stdForm syms_inParens symbList ; +-----+ Retry : +----------------------------------------------------------------------------------+--+---+--+----+-----+--+--------------------------------------------------------+--+--+-+---+----------------------------------------+----+----+--------+--+-----------+--+--+--+-+--+----+--+ |∮(·dl,over ∂Σ: E + dp[dt: B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)])|Ψ|∮|dl|over|∂Σ|E |dp[dt: B - ∂/∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)]|dp|dt|B|∂|∂O(sinO*Ei(rp,t)·Pp - ET(manp,t3)·O)|∂O|sinO|Ei(rp,t)|Pp|ET(manp,t3)|O |Ei|rp|t|ET|manp|t3| +----------------------------------------------------------------------------------+--+---+--+----+-----+--+--------------------------------------------------------+--+--+-+---+----------------------------------------+----+----+--------+--+-----------+--+--+--+-+--+----+--+ | 0|84| 0| 3| 6| 13|18| 22| 0| 3|7| 13| 17| 0| 3| 8|18| 23|36| 0| 3|6| 0| 3| 8| +----------------------------------------------------------------------------------+--+---+--+----+-----+--+--------------------------------------------------------+--+--+-+---+----------------------------------------+----+----+--------+--+-----------+--+--+--+-+--+----+--+ >> OK!? ***************************** 29Nov2018 strStd_extract_symParnPosn It seems that the "single letter" false substitution problem of strOfType_extTranSub_symGenl failures may be caused by recursion issues in strStd_extract_symParnPosn? Hints : # strStd_extract_symParnPosn_test example 8 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 9 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 21 : FAILED - result does NOT match standard # strStd_extract_symParnPosn_test example 23 : FAILED - result does NOT match standard >> but all of these work fine with strStd_extract_symParnPosn Change : +-----+ strStd_extract_symParnPosn IS OP str_stdForm { LOCAL dim_flags flags h_new h_old h_skp i j len n_paren symNew symParenList uniList symbList posnList symbListRecur posnListRecur ; NONLOCAL chrs_symbols_HFLN chrs_paren_stop chrs_paren_strt symExtract_decisionTable symExtractString_recurLevel ; % ; symbList posnList := null null ; symbListRecur posnListRecur := null null ; % ; IF (= str_stdForm (sym_stdForm str_stdForm)) THEN % ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; %stops recursive calls ; blanks := link chrs_blank ; symNew := '' ; dim_flags := gage shape shape symExtract_decisionTable ; flags := dim_flags reshape 0 ; n_paren := 0 ; uniList := str_to_unicodeList str_stdForm ; %write uniList ; len := gage shape uniList ; i := 0 ; j := 0 ; h_skp h_new := o o ; % ; WHILE (i < len) DO h_old := h_new ; IF (in uniList@i chrs_symbols_HFLN) THEN h_new := l ; ELSE h_new := o ; ENDIF ; IF (in uniList@i chrs_blank) THEN flags@1 := 0 ; IF (= 0 flags@2) THEN execute symExtract_decisionTable@(flags) ; ELSE execute symExtract_decisionTable@(flags) ; ENDIF ; ELSEIF h_new THEN flags@1 := 1 ; execute symExtract_decisionTable@(flags) ; ELSEIF (in uniList@i chrs_paren_strt) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_decisionTable@(flags) ; ELSEIF (in uniList@i chrs_paren_stop) THEN flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; % for non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; ELSE flags@1 := 0 ; execute symExtract_decisionTable@(flags) ; ENDIF ; i := i + 1 ; j := j + (gage shape uniList@i) ; ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; %THIS HAS CHANGED! a triplet of lists is returned by strStd_extract_symParnPosn! ; IF (= 1 flags@0) THEN symbList := link symbList (solitary symNew) ; ENDIF ; symParenList := EACH sym_stdForm syms_inParens symbList ; IF (~= null symParenList) THEN symbListRecur posnListRecur := EACHALL link EACH strStd_extract_symParnPosn symParenList ; symbList posnList := EACHBOTH link (symbList posnList ) (symbListRecur posnListRecur) ; ENDIF ; % ; %------------ ; %stops recursive calls ; ELSE write link 'strStd_extract_symParnPosn ERROR : != str_stdForm (sym_stdForm str_stdForm)' ; IF flag_break THEN BREAK ; ENDIF ; ENDIF ; % ; symbList posnList } +-----+ To : +-----+ >> I changed : IF (= str_stdForm (sym_stdForm str_stdForm)) THEN >> back to previous version : IF (isstring str_stdForm) THEN +-----+ Retry strOfType_extTranSub_symGenl (in "symbols translate- develop.txt") **************** 20Mar2019 Run symbols [extract, translate] tests using new code see "symbols translate- develop.txt" qnial> lq_symTests ?undefined identifier: GAGE SHAPE PARNSYMBLIST <***> ) RESHAPE 'parn' >> search symParnList - no, symList_parn -no strStd_extract_symParnPosn IS OP str_stdForm typeList := (gage shape parnSymbList) reshape 'parn' ; >> seems that parnSymbList is an old symbol, check this file! >> nothing $ find "/media/bill/PROJECTS/Qnial/MY_NDFS/" -maxdepth 1 -name "*" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "parnSymbList" "FILE" /media/bill/PROJECTS/Qnial/MY_NDFS/symbols extract.ndf:337: typeList := (gage shape parnSymbList) reshape 'parn' ; >> no result other than that line - looks like a brain fart >> just substitute "symbList" for "parnSymbList" and see what happens >> From typeList := (gage shape parnSymbList) reshape 'parn' ; >> To typeList := (gage shape symbList) reshape 'parn' ; qnial> loaddefs link d_Qnial_mine 'symbols extract.ndf' >>> loading start : symbols extract.ndf <<< loading ended : symbols extract.ndf >> This works, but does it work? # enddoc