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

[REBOL] Re: Embedded macros ..

From: al:bri:xtra at: 9-Sep-2002 19:30

Try something like: [ Rebol [] Embed: function [String [string!]] [Rule Start Word End] [ parse String: copy String Rule: [ any [ [ Start: [#"$" | #"%"] #"(" [copy Word [Alpha some Alphadigit] | Rule] #")" End: ( End: change/part Start get to-word Word End ) :End ] | skip ] end ] String ] a: "A" n: "N" s: "S" ans: "Answer" home: "HOME" dir: "DIR" homedir: "HOMEDIR" foreach String [ "The answer is: $(ans)" "The homedir is: %(homedir)" "The answer is: $($(a)$(n)$(s))" "The homedir is: %($(home)$(dir))" ] [ print Embed String ] halt ] Which gives results like: The answer is: Answer The homedir is: HOMEDIR The answer is: $($(a)$(n)$(s)) The homedir is: %(HOMEDIR) I haven't got the recursion part right. Andrew Martin ICQ: 26227169 http://valley.150m.com/