[antlr-interest] Compiler Issue (Eclipse 3.1.2 / Antlr Studio 1.1)

Jeff Barnes jbarnesweb at yahoo.com
Fri Mar 24 06:48:35 PST 2006


You have to add the generated code to the build path
in Eclipse.

Commonly you do this by adding the folder where the
generated code is placed to the build path in Eclipse.

Regards,
Jeff


--- Dominik Holenstein <dholenstein at gmail.com> wrote:

> Hello,
> 
> I am very new to Eclipse, Java and ANTLR. So my
> question is a very basic one
> but after looking for a solution for several hours I
> want to ask you whether
> you can help me:
> 
> This is my grammar file:
> 
> 
> header {
> }
> class XMLParser extends Parser;
> 
> startMark
>   : name:NAME
>   {System.out.println("Name: "+name.getText());} ;
> 
> 
> class XMLLexer extends Lexer;
> NAME: ('a'..'z'|'A'..'Z'|'0'..'9')+ NEWLINE;
> NEWLINE
>     :   '\r' '\n'   // DOS   ;
> 
> And this is my Main.java file:
> 
> import java.io.*;
> 
> class Main {
>  public static void main(String[] args) {
>   try {
>         XMLLexer lexer = new XMLLexer(new
> DataInputStream(System.in));  /*
> Problem see below
>         XMLParser parser = new
> XMLParser(lexer);                                   
>   /* Problem see below
>         parser.startMark();
>   }
> 
>   catch(Exception e) {
>    System.err.println("exception: "+e);
>   }
>  }
> }
> 
> This is the system I am working with:
> - Windows XP
> - Eclipse 3.1.2
> - ANTLR Studio 1.1
> 
> When I want to run the application (Run -> Run as ->
> Java Application) I get
> this very nice messages in the console view of
> Eclipse:
> 
> Exception in thread "main" java.lang.Error:
> Unresolved compilation problems:
> 
>  XMLLexer cannot be resolved to a type
>  XMLLexer cannot be resolved to a type
>  XMLParser cannot be resolved to a type
>  XMLParser cannot be resolved to a type
> 
>  at Main.main(Main.java:7)
> 
> 
> 
> Where do I have to look at to solve this issue?
> - java or antlr code files?
> - classpath and variables settings?
> - other project settings?
> - other ideas?
> 
> I know it is a  very basic question but I appreciate
> any help very much.
> My plans are to develop a simple XML parser first
> just for learning
> purposed.
> 
> Kind regards,
> 
> Dominik
> Zurich, Switzerland
> 


=========
Jeff Barnes
(206)245-6100


Few things are impossible to diligence and skill.
--- Samuel Johnson (Rasselas Chap. xii.)


More information about the antlr-interest mailing list