Wow, Romano,

That gives me something to mentally cogitate on for sure.
You must have been working with Rebol for a long time to code that solution so quick?
I guess working with C for such a long time (not nearly as expressive of course) makes 
the variety of Rebol approaches hurt my brain :-)

Dick


> ** Original Subject: [REBOL] Re: Embedded macros ..
> ** Original Sender: "Romano Paolo Tenca" <[EMAIL PROTECTED]>
> ** Original Date: Tue, 10 Sep 2002 12:57:48 -0500

> ** Original Message follows... 

> ---- code ----
> 
> Rebol []
> 
> delimit: ["$(" | "%(" | "*("]
> escapes: ["$$" | "%%" | "**"]
> notpar: complement charset ")"
> 
> alpha: charset [#"a" - #"z" #"A" - #"Z"]
> alphadigit: union alpha charset "0123456789"
> 
> Embed: function [[catch] String [string!] /trace][
>  macro escape start end esc comm
> ][
>  if trace [print [" +++ Embed" mold string]]
>  escape: [esc: escapes (esc: remove next esc ) :esc]
>  macro: [
>   some [
>    start:
>    delimit
>    [
>     any [
>      [
>       (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"]
> ]
> 
> ;--------test
> a: "A"
> n: "N"
> s: "S"
> ans: "Answer"
> home: "HOME"
> dir: "$(DIE)"
> die: "DIR"
> homedir: "HOMEDIR"
> home2: "$(kk)"
> kk: "$$(dir)"
> f: "%(g)"
> g: "%(h)"
> h: "333"
> m: "23"
> aa: "1"
> ab: "0"
> "*(aa)*(ab)"
> b: "*(aa)*(ab)"
> a1: "*(aa)*(ab)"
> op: " * "
> apname: "MEI"
> mei100: "language"
> foreach String [
>  "The answer is: $(ans)"
>  "The answer is: $$(ans)"
>  "The homedir is: %(homedir)"
>  "The answer is: $($(a)$(n)$(s))"
>  "The homedir is: %($(home)$(dir))"
>  "$$(home2) = $(home2)"
>  "$(h)$(h)"
>  "$($(f)$(g))"
>  "$($$$(m))"
>  "$($($(m)))"
>  "$($($(dir)))"
>  "$(aa)$(ab)"
>  "The answer is: *(*(a1)*(op)*(b)) I think"
>  "The application is: $(APNAME)"
>  "*($(APNAME): *(*(a1)*(op)*(b)))"
>  "*($(APNAME)*(*(a1)*(op)*(b)))"
>  "*(rejoin [{tot: } $(APNAME) * *(*(a1)*(op)*(b) + 345)])"
>  "*()*(a*()n*()s)"
>  "*({string})"
>  ][
>   probe Embed String
>  ]
> 
> halt
> 
> ---
> Ciao
> Romano
> 
> 
> 
> -- 
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the 
> subject, without the quotes.

>** --------- End Original Message ----------- **

> 


Download NeoPlanet at http://www.neoplanet.com

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to