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

Parse: Splitting headache

 [1/5] from: sunandadh::aol::com at: 18-Feb-2003 15:13


If I've got a string with an inner string like this: s1: {one "two three" four} then parse correctly (in my eyes) splits it into three strings: parse s1 " " == ["one" "two three" "four"] If I swap the quotes around, I get a different result.... s2: "one {two three} four" parse s2 " " == ["one" "{two" "three}" "four"] ....I've now got four strings, not three I'd like both s1 and s2 to return me three strings. And I've failed to find the secret of making parse do that.. Any ideas? Thanks, Sunanda.

 [2/5] from: rebol:laurent-chevalier at: 18-Feb-2003 23:18


>> s2: "one {two three} four"
== "one {two three} four"
>> make block! s2
== [one "two three" four] Just an idea. Maybe it's not exactly what you are looking for. Laurent [SunandaDH--aol--com] wrote:

 [3/5] from: sunandadh:aol at: 18-Feb-2003 17:49


Laurent
> >> s2: "one {two three} four" > == "one {two three} four > >> make block! s2 > == [one "two three" four]
Thanks. That would be a perfect solution if my strings were limited to valid Rebol words. Unfortunately, they are not....
>> s2: "one {two three} four ["
== "one {two three} four ["
>> parse s2 " "
== ["one" "{two" "three}" "four" "["]
>> make block! s2
** Syntax Error: Missing ] at end-of-script ** Near: (line 1) one {two three} four [ Sunanda

 [4/5] from: rotenca:telvia:it at: 19-Feb-2003 0:45


Hi,
> If I swap the quotes around, I get a different result.... > s2: "one {two three} four"
<<quoted lines omitted: 3>>
> I'd like both s1 and s2 to return me three strings. And I've failed to find > the secret of making parse do that..
Rebol does not support {} strings inside "" strings, but only ^" strings You should use one of these syntax: "a ^"b^" c" {a "b" c} {a ^"b^" c} You need a specific parse rule for: "a {b} c" --- Ciao Romano

 [5/5] from: sunandadh:aol at: 19-Feb-2003 4:26


Romano:
> Rebol does not support {} strings inside "" strings, but only ^" strings > You should use one of these syntax:
Thanks. That's a real shame. And an annoying inconsistency. Core.pdf defines a string like this: <<Strings are written in a single-line format or a multiline format. Single-line-format strings are enclosed in quotes. Multiline-format strings are enclosed in brackets.>> and explains parse as <<parse series rules The series argument is the input that is parsed and can be a string or a block. If the argument is a string, it is parsed by character.>> string is being used here in two different senses -- 'parse doesn't recognise {...} as an inner string, though 'load and 'to-block do. At the least the documentation needs a note of clarification. I'm going to drop a note to feedback. Sunanda

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