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

[REBOL] Re: Parse and and recursion local variables?

From: lmecir:mbox:vol:cz at: 17-Mar-2007 17:54

Hi Pekr, ...
> My tags look like: > > <!--[section-x]--> > subsection html code > <!--/[section-x]--> > > I want to detect particular sections and invoke particular modules/code > for them, submitting it section content. Basically it works, but I also > wanted to try my very primitive parser to do some recursion. And it > seems to me I tracked down, why it does not work - inside of nested > sections, when the recursive rule is applied, I think that > rsp-section-name is not kept local to particular recursion level? Can I > make it local by putting e.g. parse into function body, defining a word > (rsp-tag-nested) as a local variable? Or the issue is more complex and > my rules simply build insufficiently? >
I tried your code below uncommenting the marked lines and didn't reveal what you meant by "incorrect behaviour". Can you tell me what you expected?
> --------------------- > REBOL [] > > template: { > this is the beginning of html:-) > <b><!--[mark-x]-->Hello x!<!--/[mark-x]--></b> > <b><!--[mark-y]-->Hello y!<!--/[mark-y]--></b> > <b><!--[mark-z]-->Hello z!<!--/[mark-z]--></b> > <b><!--[mark-w]-->Hello w! > another html code > <!--[mark-u]--> > subsection html code > <!--/[mark-u]--> > finishing mark-w html code > <!--/[mark-w]--></b> > this is the end :-) > } > > out: copy "" > > ;--- uncommend following to get incorrect recursion behavior > ;rsp-begin: ["<!--[" copy rsp-tag-name to "]-->" "]-->"] > ;rsp-end: ["<!--/[" rsp-tag-name "]-->"] > > ;--- comment following if enabling above ones ... > rsp-begin: ["<!--[" s: some [e: "]-->" (print copy/part s e) break | skip]] > rsp-end: ["<!--/[" s: some [e: "]-->" (print copy/part s e) break | skip]] > > ;just to distinguish for eventual debugging ... > html: [copy char skip (append out char)] > rsp-html: [copy char skip (append out char)] > > rsp-section: [rsp-begin any [rsp-end break | rsp-section | rsp-html] > ] > > rsp-rules: [any [rsp-section | html] end] > > parse/all template rsp-rules > > probe out > > halt >
-L