Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

parse/recycle bug

 [1/7] from: lmecir:mbox:vol:cz at: 13-Sep-2002 10:02


Hi all, Romano wrote a small macro interpreter. I simplified it a bit, used two variants (the second variant uses explicit RECYCLE command) and here are my results: delimit: ["*("] notpar: complement charset ")" compose-string: function [ [catch] String [string!] /trace ][ macro start end comm ][ macro: [ some [ start: delimit [ any [ [ (macro: use [start] reduce [copy/deep macro]) macro ] | notpar ] #")" end: ] opt ( if "" = comm: copy/part skip start 2 back end [comm: {""}] change/part start do comm end ) :start ] ] either parse/all String: copy String [some [macro | skip]][ string ][throw make error! "Invalid string"] ] compose-string-2: function [ [catch] String [string!] /trace ][ macro start end comm ][ macro: [ some [ start: delimit [ any [ [ (recycle macro: use [start] reduce [copy/deep macro]) macro ] | notpar ] #")" end: ] opt ( if "" = comm: copy/part skip start 2 back end [comm: {""}] change/part start do comm end ) :start ] ] either parse/all String: copy String [some [macro | skip]][ string ][throw make error! "Invalid string"] ] home: "to" comment [ ; the following crashes Rebol loop 500 [compose-string "go *(home) *(home)"] ; while this doesn't crash, but leaves the interpreter in a "strange state" compose-string-2 "go *(home) *(home)" ] I would guess, that this is another recycle bug. Cheers -L

 [2/7] from: lmecir:mbox:vol:cz at: 13-Sep-2002 12:10


Hi myself and all others, I succeeded to simplify further the issue. The following PARSE crashes Rebol rule1: [ (rule: copy/deep rule2) rule (print "rule1 done") ] rule2: [ (rule: copy/deep rule3) rule (print "rule2 done") ] rule3: [ ( recycle print "rule3 done" ) ] parse "" rule1 Cheers -L

 [3/7] from: anton::lexicon::net at: 13-Sep-2002 22:12


Ladislav, Might it be the same with 'change as 'remove ? Where you have written:
> opt ( > if "" = comm: copy/part skip start 2 back end [comm: {""}] > change/part start do comm end > ) > :start
What happens if you make this change: opt ( if "" = comm: copy/part skip start 2 back end [comm: {""}] ) :start ( change/part start do comm end ) ?? Anton.

 [4/7] from: lmecir:mbox:vol:cz at: 13-Sep-2002 15:46


Hi Anton, this is a different kind of bug. I found a simplification (in my last mail, did you receive it?), which uses neither REMOVE, nor CHANGE. Cheers -L

 [5/7] from: rotenca:telvia:it at: 13-Sep-2002 16:24


Hi Ladislav, This change removes the crash. It seems to me that recycling system does not keep in consideration word references inside a parse block. rebol [] rule1: [ (rule: copy/deep rule2 ) rule (print "rule1 done") ] rule2: [ ( x: rule ;************ rule: copy/deep rule3) rule (print "rule2 done") ] rule3: [ ( recycle print "rule3 done" ) ] parse "" rule1 --- Ciao Romano

 [6/7] from: rotenca:telvia:it at: 13-Sep-2002 16:29


Hi all this is the compose-string function with the references patch: rebol [] delimit: ["$(" | "%(" | "*("] escapes: ["$$" | "%%" | "**"] notpar: complement charset ")" compose-string: function [[catch] String [string!] /trace][ macro escape start end esc comm refs ][ refs: clear [] if trace [print [" +++ Compose-string" mold string]] escape: [esc: escapes opt (esc: remove next esc ) :esc] n: 0 macro: [ some [ start: delimit [ any [ [ (insert tail refs macro macro: use [start][bind/copy macro 'start]) macro ] | escape | notpar ] #")" end: ] opt ( if "" = comm: copy/part skip start 2 back end [comm: {""}] change/part start do comm end if trace [print [" === Eval" comm "=" mold do comm]] ) :start ] ] either parse/all String: copy String [ some [macro | escape | skip] ][string][throw make error! "Invalid string"] ] home: "to2" loop 500 [compose-string "go *(home) *(home)"] halt --- Ciao Romano

 [7/7] from: rotenca:telvia:it at: 13-Sep-2002 16:42


Hi Lasdislav, i forgot: thanks for your help! --- Ciao Romano