|Get line numbers with Antlr parser email@example.com (Ulrich Hobelmann) (2006-05-16)|
|Re: Get line numbers with Antlr parser firstname.lastname@example.org (Antoine Reilles) (2006-05-18)|
|Re: Get line numbers with Antlr parser email@example.com (Kai Koehne) (2006-05-18)|
|Re: Get line numbers with Antlr parser firstname.lastname@example.org (Ulrich Hobelmann) (2006-05-18)|
|From:||Ulrich Hobelmann <email@example.com>|
|Date:||18 May 2006 23:52:38 -0400|
|Posted-Date:||18 May 2006 23:52:38 EDT|
Ulrich Hobelmann wrote:
> Now for some reason the line information disappears while the tree is
> being built. In java15.tree.g I can add printlns, but the line number
> of the *same* node as in java15.g is suddenly 0, while it was, say 15,
> only a second (and I assume a "return") before.
> (or is this a bug?)
I haven't found an answer to the above, but for the record let me post
since Antlr seems to exterminate the line numbers when the nodes are
passed between parsers, the workaround was to "wrap" line numbers as
In the tree parser, the IDENTs are then collected and disassembled (i.e.
getText() extracts the text and Integer.parseInt() unwraps them into the
line number they once were). Ugly, but it does the job.
Until last night, that is. This morning I did some more typing, but now
for some reason I get the message: "<AST>: expecting IDENT, found
'<empty tree>'", and I forgot what exactly I changed that suddenly
produces this behavior. Everything seems to work correctly as before,
except for the annoying message.
Of course, Antlr is being true to its tradition of transparency, and
doesn't bother to mention *where* this occurs, so I have - again - no
idea what exactly is going on.
If anybody has any idea, I'd be thankful for that. (Otherwise I just
hope I'll be done with this project as soon as possible (and don't have
to touch it again).)
Return to the
Search the comp.compilers archives again.