[REBOL] parse/recycle bug
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