I thought this parsing would be simple...

Posted by Rebol Tutorial on Stack Overflow See other posts from Stack Overflow or by Rebol Tutorial
Published on 2010-03-17T15:13:39Z Indexed on 2010/03/18 3:01 UTC
Read the original article Hit count: 437

Filed under:

... and I'm hitting the wall, I don't understand why this doesn't work (I need to be able to parse either the single tag version (terminated with />) or the 2 tag versions (terminated with ) ):

Rebol[]

content: {<pre:myTag      attr1="helloworld" attr2="hello"/>
<pre:myTag      attr1="helloworld" attr2="hello">
</pre:myTag>
<pre:myTag      attr3="helloworld" attr4="hello"/>
}

spacer: charset reduce [#" " newline]
letter: charset reduce ["ABCDEFGHIJKLMNOPQRSTUabcdefghijklmnopqrstuvwxyz1234567890="]

rule: [

any [
{<pre:myTag} 
any [any letter {"} any letter {"}] mark: 
(print {clipboard... after any letter {"} any letter {"}} write clipboard:// mark input)
any spacer mark: (print "clipboard..." write clipboard:// mark input) ["/>" | ">" 
any spacer </pre:myTag>
]
any spacer
(insert mark { Visible="false"}) 
]
to end

]

parse content rule
write clipboard:// content
print "The end"
input

© Stack Overflow or respective owner

Related posts about rebol