[antlr-interest] New to ANTLR; Problems with the grammar
Schütz Tomi (KSFC 413)
tomi.schuetz at credit-suisse.com
Thu Jun 1 08:05:53 PDT 2006
Hi there
I would like to parse an XML file and to extract some entity information.
sample.xml:
<!ENTITY commonVerification SYSTEM "../includes/commonVerification.xml">
..
My grammar looks like this...
b.g:
class P extends Parser;
startRule
: (
PREFIX n:NAME SYS p:PATH SUFFIX
{
System.out.println("("+n.getText()+","+p.getText()+")");
}
)+
;
class L extends Lexer;
PREFIX
: "<!ENTITY"
;
SUFFIX
: '>'
;
NAME
: (
'a'..'z' |
'A'..'Z' |
'_'
)+
;
SYS
: "SYSTEM"
;
PATH
: (
'"' |
'a'..'z' |
'A'..'Z' |
'.' |
'/'
)+
;
WS
: (
' ' |
'\t' |
'\r' '\n' { newline(); } |
'\n' { newline(); }
)
{$setType(Token.SKIP);} //ignore this token
;
I get an error message which I don't understand and I can't find an answer or link which brings me further...
<!ENTITY commonVerification SYSTEM "../includes/commonVerification.xml">
line 1:29: expecting SYS, found 'SYSTEM'
Could anyone point me to the problem? Any hint is very much appreciated.
Thanks in advance,
Tomi
More information about the antlr-interest
mailing list