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

[REBOL] Re: [parse] Special characters in block parsing

From: apwing:zonnet:nl at: 3-Apr-2005 17:12

Volker Nitsch wrote:
>Composing was my first thought too. >But this looks cleaner (with complex rules): > >divide-word: to-lit-word "/" >probe parse [/][ set word divide-word ] >probe word > >On Apr 3, 2005 4:39 PM, Anton Rolls <[antonr--lexicon--net]> wrote: > >>Hi Arie, >> >> >> >>>>parse [/] compose [set word (to-lit-word first [/])] >>>> >>>> >>== true >> >> >>>>word >>>> >>>> >>== / >> >>Anton. >> >> >> >>>Hi all, >>> >>>while experimenting with a small dialect for calculations, I stumbled >>>into a problem. >>> >>>I've done simple things like: >>> >>> >> parse [6 * 3] [set num1 number! '* set num2 number! (print num1 * >>>num2) ] >>>18 >>>== true >>> >>>However, when I try: >>> >>> >> parse [6 / 3] [set num1 number! '/ set num2 number! (print num1 / >>>num2) ] >>>** Syntax Error: Invalid word-lit -- ' >>>** Near: (line 1) parse [6 / 3] [set num1 number! '/ set num2 number! >>>(print num1 / num2 >>>) ] >>> >>>REBOL complains, because (of course) '/ is not a proper lit-word. >>> >>>How can I still parse the / ? I already tried a charset, but I suppose >>>that's only possible with string-parsing, or not? >>> >>>TIA >>> Arie >>> >>> >>-- >>To unsubscribe from the list, just send an email to >>lists at rebol.com with unsubscribe as the subject. >> >> >> >> >
Hi Anton / Volker, many thanks for these useful solutions. In my case Volker's solution is somewhat simpler to use, but I can imagine situations where Anton's solution might be more appropriate! I tried both and indeed both do work fine! What I find strange however is that specifying '/ is an invalid lit-word but to-lit-word "/" is not. This looks like a contradiction to me... Any ideas why this works that way (and I am glad it does ;-) ? Thanks again! Arie