[antlr-interest] Input parsing ending before end of file

David Holroyd dave at badgers-in-foil.co.uk
Sun Mar 30 09:44:11 PDT 2008


On Sun, Mar 30, 2008 at 12:12:58PM -0400, Ymo wrote:
> Hi i am trying to parse an input file and the generated parser seems to just
> quit without apparent errors :
> 
> input file :
> package org.test;
> 
> import org.antlr.runtime.ANTLRFileStream;
> import org.antlr.runtime.CharStream;
> import org.antlr.runtime.CommonTokenStream;
> import org.antlr.runtime.RecognitionException;
> import org.antlr.runtime.tree.CommonTreeNodeStream;
> import org.antlr.runtime.tree.Tree;
> 
> { // As soon as it sees the braces it just exits  !

[...]

> grammar:
> templateFile
>    :  packageDeclaration?
>       importDeclaration*
>       templateDeclaration*
>    ;

How about,

 templateFile
    :  packageDeclaration?
       importDeclaration*
       templateDeclaration*
       EOF
    ;


ta,
dave

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list