With grammar (bnf form) and source code as input, Antlr is generating AST/Parse tree with tokens as terminals and "nil" as parent/root in this case.This is not appropriate tree. I came to know that grammar has to be rewritten in order to generate proper AST/Parse tree. But I couldnt find any appropriate rules to rewrite grammar.