[antlr-interest] Package issues
Stefan Mätje
Stefan.Maetje at esd-electronics.com
Mon May 21 05:47:48 PDT 2012
Am 21.05.2012 09:04, schrieb Oana Ureche:
> Hi all,
> I get a XMLLexer cannot be resolved to a type at the following Java line of code: XMLLexer lex = new XMLLexer(input);
> I am importing both:
> import org.antlr.runtime.*;import org.antlr.runtime.tree.*;
> The imports are fine, no errors there. I added antlr-3.4.jar file on the build path using Eclipse. But I still get error when trying to use XMLLexer, XMLParser or XMLTreeParser.
> Isn't it enough to add antlr jar file?
No it is not. This jar doesn't contain the lexers/parsers for all known
languages. Your imports only reference the ANTLR runtime which only
supports the lexers and parsers generated by the ANTLR tool from a
grammar file on behalf of you.
Do I need something else?
You need to specify an ANTLR grammar file *.g that can be used to build
appropriate source code in Java for your language problem. This is then
translated to class files that could provide a XMLLexer class for instance.
I cannot find any documentation regarding this.
Start with the main page www.antlr.org. This also links to the
documentation page with a link to the command line options.
Use the getting started page at
http://www.antlr.org/wiki/display/ANTLR3/FAQ+-+Getting+Started
On that page is also a link "Parsing XML" to
http://www.antlr.org/wiki/display/ANTLR3/Parsing+XML
which talks about XML stuff.
Checkout the ANTLR example downloads at
http://www.antlr.org/download.html which contain at least the grammar of
an XML lexer. (Look for "sample grammars").
There is also a grammars list at
http://www.antlr.org/grammar/list
Can someone point me to one?
> Thank you,Oana.
This should give you a starting point.
Best regards,
Stefan
More information about the antlr-interest
mailing list