[REBOL] Re: parsing..
From: volker:nitsch:gm:ail at: 9-Jan-2005 3:32
On Sat, 08 Jan 2005 16:04:17 -0500, Eric Haddix <[eric--ehrichweiss--com]> wrote:
> I'm an old school Amiga programmer(which probably means I'm among many
> old friends) and was especially fond of Arexx. Well that thought brought
> me to this post...
>
> The parse command seems to need improvement unless I'm not understanding
> it and I think that a great place to start might be by looking at what
> Arexx does. For example. I have several projects that require a single
> input line to be parsed into several variables. If I'm understanding
> Rebol's parse command, it can only do one variable at a time, Arexx did
> them until you were satisfied...so instead of multiple or recursive
> parse commands you could do "parse input "abc" variable1 "def" variable2
> "ghi" variable3 "jkl" " It's as simple as that for the most part.
parse input[
"abc" copy variable1 to "def"
"def" copy variable2 to "ghi"
"ghi"
]
> You
> can vary how the delimiters work with wildcard functions like "abc#?def"
[ .. "abc" thru "def" .. ]
> which means that there are some characters between 'c' and 'd' that are
> unknown in length. It's been a while since I used Arexx so forgive me if
> my syntax is off a bit.
>
> Anyway, if this is possible with a single line, please show me an
> example since the one on the language dictionary seems very limited. And
> if it isn't possible currently, what would be necessary to make it possible?
>
Generally there are three "versions" of parse:
The complete simple with delemiting chars
parse/all inp "^/"
The more complex with 'to 'thru 'copy, this is similar to arexx
abilities (IIRC).
copy var to "token"
goes to token and stops before it. copies the stuff.
Thus you have to skip the "token", or it is included in the next copy.
thus i write [ to "token" "token" ]. This case is rarelly needed
because there is 'thru
copy var to "delemiter" thru "begin" copy var2 to "del2"
like
thru {<a href="} copy url to {"}
thru ">" copy label to "<"
The ultracomplex is similar to EBNF and can parse
programming-languages if you really do the work.
> Eric
> --
> To unsubscribe from the list, just send an email to rebol-request
> at rebol.com with unsubscribe as the subject.
>
--
-Volker
Any problem in computer science can be solved with another layer of
indirection. But that usually will create another problem.
David
Wheeler