[REBOL] Re: Parse and and recursion local variables?
From: lmecir:mbox:vol:cz at: 18-Mar-2007 17:37
Petr Krenzelok napsal(a):
> Volker Nitsch wrote:
>> My typicall way to do that is my own stack.
>> stack: copy
>> parse rule[
>> (insert/only stack reduce[local1 local2])
>> rule ;recursion
>> (set[local local2] first stack remove stack)
> Guys, got to go to have few beers tonight with my friends, but - that
> kinda sucks ;-) I can guarantee you, that most novices, like me, will
> swear like mad when developing and touching first recursion. I think,
> that rebol's aproach of implicit global nature of words, even those
> inside functions, is the main hell for novices :-)
> One quick question - how is that with function recursion? Can I have
> "local" function value to one level of recursion call? And then shared
> one? I know I can build my own stack, but ... :-) And if it is possible
> with functions, parser should explicitly behave like that, even if it
> breaks rebol rules :-) Will try with recursive function or stack later ...
here are the results obtained:
finished subsection mark-w
...and here is the code:
this is the beginning of html:-)
another html code
subsection html code
finishing mark-w html code
this is the end :-)
out: copy ""
;just to distinguish for eventual debugging ...
html: [copy char skip (append out char)]
rsp-html: [copy char skip (append out char)]
use [rsp-begin rsp-end rsp-tag-name] copy/deep [
rsp-begin: ["<!--[" copy rsp-tag-name to "]-->" "]-->" (print
rsp-end: ["<!--/[" rsp-tag-name "]-->" (print
[rsp-begin any [rsp-end break | do rsp-section (print ["finished
subsection" rsp-tag-name]) | rsp-html]]
parseen/all template [any [do rsp-section | html] end]