[antlr-interest] html parser, common rules and any combination of rules
Matěj Plch
plchmate at fit.cvut.cz
Tue Dec 20 03:28:55 PST 2011
Hi, Im trying to write simple HTML parser (with antlr4ruby) and Im
facing two problems:
1. If I have HTML element attributes I need to write rule to match any
combination of them, but every can be only once there, like:
<body bgcolor="" background=""> <body background="" bgcolor="">
2. I match attributes values in this way:
attr_svalue: ASSIGN SVALUE;
align_value: ASSIGN AVALUE;
SVALUE: { @tagMode }?=>
( '"' (~'"')* '"'
| '\'' (~'\'')* '\''
)
;
AVALUE
: { @tagMode }?=> '"' ('left'|'right'|'center') '"'
;
But SVALUE rule hides AVALUE. How can be this done to match both?
Thanks in advance.
Matej Plch
More information about the antlr-interest
mailing list