[antlr-interest] generating runtime error messages with ANTLR

Mark Volkmann r.mark.volkmann at gmail.com
Mon Feb 18 08:08:02 PST 2008


On Feb 17, 2008 8:37 AM, Carter Cheng <carter_cheng at yahoo.com> wrote:
> Hi everyone,
>
> I have been trying to build a compiler using ANTLR
> 3.0.1 to handle most of the frontend work. I am
> curious if there is a canonical method for passing
> line count, character position information downstream
> to other phases of the compiler which can be then used
> for error reporting either in the type check phase
> after the AST is constructed or at runtime.
>
> Is there some canonical method for capturing this
> information in the AST which can then be used to
> generate error reports?

The default AST tree node class CommonTree has methods to get that
information. The getLine method works as expected, but it seems that
getCharPositionWithinLine always returns zero. Is that a known bug?

-- 
R. Mark Volkmann
Object Computing, Inc.


More information about the antlr-interest mailing list