Hi Lukas, all 
I'm finally working on a HTML petit parser (a very basic one, based on XML 
petit parser) and I have a serious problem (well... besides my complete 
ignorance about petit parser, he...)
I need to match this pattern: 

openTag, contents, closeTag     (that will be something like "<html> ... 
</html>")
inlineTag                                       (that will be something like 
"<br/>")
openTag                                         (that will be something like 
"<link ...>" or "<img src='anUrl'>")

so, after try some variants... I came with this construct: 

element
        "[39]           element    ::=           EmptyElemTag | STag content 
ETag"
        
        ^(self inlineTag / (self openTag, content, self closeTag) / self 
openTag)
                ==> [ :nodes | ].

openTag
        ^ $< asParser, qualified, whitespace optional, attributes, whitespace 
optional, $> asParser

inlineTag
        ^ $< asParser, qualified, whitespace optional, attributes, whitespace 
optional, '/>' asParser

closeTag
        ^'</' asParser , qualified , whitespace optional , $> asParser


so... the problem here is that the statement 

self openTag, contents, self closeTag

matchs with 

...
        <link ...>
</html> 
        
and for that reason, the resulting tree is invalid. 

So, I need a way to ensure the openTag name is equal to the closeTag name. 

How can I do that?

Cheers,
Esteban

Reply via email to