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

Parse surprise

 [1/11] from: lmecir:mbox:vol:cz at: 14-Jan-2003 17:14


Hi all, accidentally I tried this:
>> parse "abcdefgh" [thru 2 a: (print a) to 1 a: (print a)]
cdefgh abcdefgh == false It was quite a surprise for me. This isn't as useful as it may complicate block parsing IMO. What do you think? Regards -L

 [2/11] from: cyphre:seznam:cz at: 14-Jan-2003 18:24


Hi Ladislav, interesting, just tried
>> parse "abcdefgh" [thru 3 a: (print a) copy rslt to 1 a: (print a print
rslt)] defgh abcdefgh none == false why is the content of rslt set to none ? Shouldn't it be the rslt "b"? regards, Cyphre

 [3/11] from: petr:krenzelok:trz:cz at: 14-Jan-2003 18:34


Ladislav Mecir wrote:
> Hi all, > > accidentally I tried this: > >>>parse "abcdefgh" [thru 2 a: (print a) to 1 a: (print a)] > > cdefgh > abcdefgh > == false
what? :-) I did not know it is possible ... is that needed? Isn't it the same as using skip 2 skip 1? Well, as for parse ... still waiting for favorite to/thru [a | b | c], which can't be so easily done imo ... -pekr-

 [4/11] from: g:santilli:tiscalinet:it at: 14-Jan-2003 19:30


Hi Ladislav, On Tuesday, January 14, 2003, 5:14:18 PM, you wrote: LM> What do you think? It's a surprise for me too, and could be a problem in block parsing indeed (on the other hand, I wonder what kind of dialect would be doing something like "to 5" or "thru 44"...). I have to think if this behavior can be useful for something... Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [5/11] from: rotenca:telvia:it at: 14-Jan-2003 19:19


Hi,
> why is the content of rslt set to none ? Shouldn't it be the rslt "b"? >> parse "abcdefgh" [copy x thru 5 copy y thru 4] print [x y]
abcde none
>> parse "abcdefgh" [copy x thru 5 copy y thru 5] print [x y]
abcde none
>> parse "abcdefgh" [copy x thru 5 copy y thru 6] print [x y]
abcde f It seems that copy works if the second to/thru value is after the first. Other strange thing:
>> parse "abcdefgh" [copy x to 0] print [x]
abcdefgh
>> parse "abcdefgh" [copy x to 1] print [x]
none
>> parse "abcdefgh" [copy x to 2] print [x]
a Perhaps is undocumented because it is a unfinished or buggy feature. --- Ciao Romano

 [6/11] from: rotenca:telvia:it at: 14-Jan-2003 19:22


Hi,
> Well, as for parse ... still waiting for favorite to/thru [a | b | c], > which can't be so easily done imo ...
This can be done with parse-compile. Obviously a native parse command should be better. --- Ciao Romano

 [7/11] from: otherchaz::mindspring::com at: 15-Jan-2003 3:05


> It's a surprise for me too, and could be a problem in block > parsing indeed (on the other hand, I wonder what kind of dialect > would be doing something like "to 5" or "thru 44"...). > > I have to think if this behavior can be useful for something... >
this behavior can be useful for an RPG IV dialect http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QB3AGZ03/3.3.1

 [8/11] from: sqlab:gmx at: 16-Jan-2003 10:18


I find it more annoying, that it uses the absolute position starting from the head and not from the actual position.
>> parse next "abcdefgh" [thru 2 a: (print a) to 1 a: (print a)]
cdefgh abcdefgh AR Ladislav Mecir wrote:
> Hi all, > accidentally I tried this:
<<quoted lines omitted: 11>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- +++ GMX - Mail, Messaging & more http://www.gmx.net +++ NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!

 [9/11] from: lmecir:mbox:vol:cz at: 17-Jan-2003 16:19


Hi all, how about this?
>> a: does [parse "" [(return "done")]] >> a
== true Regards -L

 [10/11] from: rotenca:telvia:it at: 17-Jan-2003 19:05


Hi Ladislav,
> how about this? > > >> a: does [parse "" [(return "done")]] > >> a > == true
Break, throw and return do not stop a parse paren (like object spec), only make error! is able to do it. I should like to have a method to stop a parse rule inside paren code and reurn a value like true or false (or something else). --- Ciao Romano

 [11/11] from: lmecir:mbox:vol:cz at: 18-Jan-2003 11:18


Hi Romano, would you like to have something like PE? pe/pe "" [any (pe/ret "done")] ; == "done" ----- Original Message ----- From: "Romano Paolo Tenca"
> I should like to have a method to stop a parse rule inside paren code and > reurn a value like true or false (or something else).
The source of PE: pe: make object! [ pe: function [ "Parses a series according to rules." input [series!] "Input series to parse" rules [block! string! none!] "Rules to parse by" /all "Parses all chars including spaces." /case "Uses case-sensitive comparison." ] [value] [ res?: false either rebol/words/all [ error? value: try [ apply/r/a :parse compose [ (either all ['all] []) (either case ['case] []) ] reduce [input rules] ] res? ] [ res?: false return get/any 'res ] [value] ] res?: false res: none ret: func [ value [any-type!] ] [ res?: true error? set/any 'res get/any 'value make error! "" ] ]

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted