[antlr-interest] Add Import to parser.java?

Haralambi Haralambiev hharalambiev at gmail.com
Sun May 11 03:17:37 PDT 2008


Add the following to your grammar:

@header
{
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
}

If you want to add the import statements to the Lexer also, you should use
the @lexer::header.

-Hari

On 5/11/08, Andrés Mejía <andmej at gmail.com> wrote:
>
> Hello, I'm trying to do a simple action on my parser using embedded Java
> in my grammar.
>
> I want to display the date when the parser is being run, and I need to
> import some Java classes.
>
> How can I tell AntLR to add some import lines at the beginning of the
> myParser.java file?
>
> I need to add:
>
>     import java.util.Date;
>     import java.text.DateFormat;
>     import java.text.SimpleDateFormat;
>
> Else, I won't be able to compile my grammar.
>
> Thanks.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080511/713f6bf5/attachment.html 


More information about the antlr-interest mailing list