[antlr-interest] Help me get started

Pavel Grinfeld pg at freeboundaries.com
Tue Jun 22 01:22:01 PDT 2010


Hi,

Here's my first attempt at an ANTLR project. For practice, I just want 
to read a file with lowercase words and print them. I feed it "hi there 
how are you"
All that the program prints is "hi".

Many thanks in advance,

PG

grammar pg;

doc
:    a = word {System.out.println($a.value);} ( WS b = word 
{System.out.println($b.value);}  )*;

word    returns[String value]
:LETTERS  {$value = $LETTERS.text;}  ;

WS  :   ( ' '
         | '\t'
         | '\r'
         | '\n'
         ) {$channel=HIDDEN;}
     ;

LETTERS:    ('a'..'z')+;


More information about the antlr-interest mailing list