[antlr-interest] unexpected char exception

jean.morissette666 at videotron.ca jean.morissette666 at videotron.ca
Sat Feb 26 13:00:52 PST 2005


Hi,
I'm an Antlr newbie.  Could you tell me why I have this error and how to 
resolve it:

exception: line 1:1: unexpected char: 'a'

Here is my grammar:

class P extends Parser;

startRule
    :   "abc"
    ;

class L extends Lexer;

NEWLINE
    :	'\n'
    ;

And my test case:

import java.io.*;

class AntlrTest {
  public static void main(String[] args) {
	try {
	  String s = "abc";

	  L lexer = new L(new StringReader(s));
	  P parser = new P(lexer);
	  parser.startRule();
	} catch(Exception e) {
	  System.err.println("exception: "+e);
	}
  }

Thank for your help
-Jean
 


More information about the antlr-interest mailing list