Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: New parsing problem
Pages: [1] Print
Author Topic: New parsing problem  (Read 234 times)
parser
Guest


Email
New parsing problem
« on: September 27, 2005, 10:20:05 AM »

I really don't understand why it gives "command1 <" instead of
{command1
command1
command2}

rules: [

any [
[
some newline
copy command to " " "<"
copy param to ">" ">"
some newline
(probe command)
]
|
[
some newline
copy Command to newline
some newline
(probe command)
]

]
some newline
to end
]

list-commands: {
command1 <
test1
>

command1


command2 <
test2
>

}

parse/all list-commands rules

>> parse/all list-commands rules
"command1 <"
== false
>>  
Logged
Guest
Guest


Email
New parsing problem
« Reply #1 on: October 04, 2005, 04:11:35 PM »

I don't have enough time to explain where you went wrong, but, if you need to extract the commands I can give you a different approach that might suit your needs.

parse/all list-commands [any [
        to "<" tag-start:
        thru ">" tag-end:
        (remove/part a B)
        :a
        ]
    to end
]

This will remove the "tags" in list-commands (assuming they are all well-formed), leaving behind the commands and some whitespace.

If your tags didn't span multiple lines like that, REBOL could have recognized the tags, and then we could just use load/markup and remove-each. See the one-liner from Carl (http://www.rebol.com/oneliners.html) for an example.
Logged
Guest
Guest


Email
New parsing problem
« Reply #2 on: October 04, 2005, 04:13:38 PM »

Sorry, got tangle up in emoticons. Here's that code again:

parse/all list-commands [any [
        to "<" tag-start:
        thru ">" tag-end:
        (remove/part tag-start tag-end)
        :tag-start
        ]
    to end
]
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: New parsing problem
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2008, 10:27:54 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2315 Posts in 597 Topics by 4205 Members
Latest Member: TimTearton

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc