Want to parse XML
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vidar_Haakestad
Posted On:   Saturday, May 7, 2005 07:52 AM

I want to parse XML in general I have a parser entry like this: openTag : i:STARTTAG (property)* // Not shown ENDTAG { System.out.println("Tag name: "+i.getText()); } ; Then a lexical rule for the STARTTAG and ENDTAG like this: LETTER: ('a'..'z') | ('A'..'Z') | '$' | '_' '-'; ID : LETTER (LETTER | DIGIT)* GT: ">" ; LT: " <" ; STARTTAG : LT! ID; ENDTAG : ((SLASH! GT!) | GT!); protected DIGIT : ('0'..'9'); The generated parser complains that: line 1:49: expecting ENDTAG   More>>

I want to parse XML in general



I have a parser entry like this:

			
openTag
: i:STARTTAG
(property)* // Not shown
ENDTAG
{
System.out.println("Tag name: "+i.getText());
}
;


Then a lexical rule for the STARTTAG and ENDTAG like this:

			
LETTER: ('a'..'z') | ('A'..'Z') | '$' | '_' '-';
ID : LETTER (LETTER | DIGIT)*
GT: ">" ;
LT: " <" ;

STARTTAG : LT! ID;
ENDTAG : ((SLASH! GT!) | GT!);

protected
DIGIT : ('0'..'9');


The generated parser complains that:

line 1:49: expecting ENDTAG, found '>'

when I supply the following syntax:

			




My question is simple: Why would the lexer not find the terminating >? I get the same message if I terminate with /> (except that the offending character is the slash).    <<Less
About | Sitemap | Contact