[REBOL] Re: how to parse thru nested parens?
From: robert:muench:robertmuench at: 12-Dec-2001 9:30
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
> [nitsch-lists--netcologne--de]
> Sent: Tuesday, December 11, 2001 3:02 PM
> To: [rebol-list--rebol--com]
> Subject: [REBOL] Re: how to parse thru nested parens?
> beware, this is recursive and parse has no local variables for that.
> so real processing needs some workaround.
> whats the best way to to this?
Hi, the best way to solve this is to use inline variables and put the values on
stack variables ;-) as soon as possible. I use this all the time when parsing.
Here is my stack-context I normally use:
; Stack Datastructure Object
stack!: make object! [
stack: make block! []
push: func['value][
insert head stack value
]
pop: does [
value: first stack
remove stack
return value
]
top: does [
if not empty? [return first stack]
]
empty?: does [
either (length? stack) == 0 [return true][return false]
]
ontop?: func ['value][
either value == top [return true][return false]
]
instack?: func ['value][
either result: find stack value [return index? result][return none]
]
]
--
Robert M. Münch
IT & Management Freelancer
Mobile: +49 (0)177 2452 802
Fax : +49 (0)721 8408 9112
Web : http://www.robertmuench.de