[antlr-interest] Not Matching

Quintin Beukes quintin.beukes at signio.co.za
Thu Feb 9 02:20:50 PST 2012


Hi,

I've been playing around with ANTLR 3.3 and am trying to match a very
simple input with a very simple grammar, though I keep getting this
error:
input.txt line 1:0 missing 'OnChange:' at ''

What am I doing wrong?

The input.txt file:
OnChange:

The grammar:
grammar TestGrammar;

@members {
  public static void main(String[] args) throws Exception {
    TestGrammarLexer lex = new TestGrammarLexer(new ANTLRFileStream(args[0]));
    CommonTokenStream tokens = new CommonTokenStream(lex);

    TestGrammarParser parser = new TestGrammarParser(tokens);

    try {
      parser.fieldRules();
    } catch (RecognitionException e)  {
      e.printStackTrace();
    }
  }
}

fieldRules
  : 'OnChange:' WS
  ;

WS
  : ('\t' | ' ' | '\n' | '\r')*
  ;


Quintin Beukes


More information about the antlr-interest mailing list