[REBOL] Re: Strange parsing behavior
From: andreas:bolka:gmx at: 5-Aug-2002 18:30
I know Gabriele has provided a (very nice!) solution already, but I'm
contributing that anyway.
Saturday, August 3, 2002, 1:04:43 PM, Robert wrote:
> Try the following, which can't be done:
> Text: "this-is-a test of some parsing^/
> this-is-a - test of some parsing"
> The result should be
> Text: ["this-is-a test of some parsing" "this-is-a" "test of some
> parsing"]
> You have to solve the problem to trigger on " - " or 'newline
> whichever comes first ;-). Robert
generally, everything that can be described with an (E)BNF expression,
can be parsed/validated by REBOL's 'parse.
so here's the pure (? :) bnf-based 'parse rule-set:
-- snip --
char: complement charset " -^/"
name: [some [char | propws | prophyph2] opt [name]]
propws: [" " [char | propws | prophyph | end]]
prophyph: ["-" [char | prophyph2 | end]]
prophyph2: ["-" [char | " " | prophyph2 | end]]
sep: [newline | " - "]
-- snap --
to try this out, use for example:
-- snip --
teststr: {this-is-a test of some parsing^/this-is-a - test of some parsing}
p_name: [ copy t_name name (probe t_name) ]
parse/all teststr [ some [ p_name opt [ sep ] ] end ]
-- snap--
--
Best regards,
Andreas mailto:[andreas--bolka--gmx--net]