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

Dialecting......

 [1/3] from: idsrini::gmail at: 28-May-2008 20:56


Hi Gregg, I had a look at dialects and managed to get a simple one working using Blocks using Parse (not string parsing)... I was wondering if you or someone else could throw some light (with examples) on more complex parsing. Like recursive parsing for nested blocks For example, if I need to parse the block [IF A > B [SET VALUE OF DISCOUNT TO 10] ELSEIF A = B [SET VALUE OF DISCOUNT TO 15] ELSE [SET VALUE OF DISCOUNT TO 20] ] Next Example [IF A > B [IF CUSTOMER-TYPE = "VIP"] [SET VALUE OF DISCOUNT = 30] [ELSEIF CUSTOMER-TYPE = "REGULAR"] [SET VALUE OF DISCOUNT = 20] [ELSE] [SET VALUE OF DISCOUNT = 15] ] [ELSEIF A = B] [SET VALUE OF DISCOUNT TO 15] ELSE [SET VALUE OF DISCOUNT TO 20] ] Hope I have been able to communicate the query ......... Basically, if I could get the code to do nested blocks, then it becomes very helpful..... Regards, Srini

 [2/3] from: gregg:pointillistic at: 28-May-2008 10:31


Hi Srini, SI> I had a look at dialects and managed to get a simple one working using SI> Blocks using Parse (not string parsing)... Great! SI> I was wondering if you or someone else could throw some light SI> (with examples) on more complex parsing. Like recursive parsing SI> for nested blocks Look at the INTO keyword in parse.
>> b: ["hello" [world]]
== ["hello" [world]]
>> parse b [string! word!]
== false
>> parse b [string! block!]
== true
>> parse b [string! into [word!]]
== true
>> b: [hello [world]]
== [hello [world]]
>> rule=: [set w [into [word!] | word!] (print mold w)]
== [set w [into [word!] | word!] (print mold w)]
>> parse b [some rule=]
hello [world] == true HTH! -- Gregg

 [3/3] from: idsrini::gmail::com at: 29-May-2008 0:34


Hi Gregg, Thanks once again for the tip..... I'll now look forward to developing a more complex dialect..... -- Srini On 28/05/2008, Gregg Irwin <gregg-pointillistic.com> wrote: