On Sun, 12 Sep 2004 01:30:24 +0200, Khamis Abuelkomboz
<khamis@[EMAIL PROTECTED]
>
wrote:
> Hi Isaac
>
> thank you for the feedback. I have downloaded ANTLR and tried it. I have
> here one question, how to get the location of found scopes within ANTLR,
> as example, I define a role:
>
> ident
> : IDENT
> {
> printf("function name = %s, at %i.%i\n",
> t->getText(),
> t->get??????(), //how to get the location in the
file?
> t->get??????());
> }
>
> regards
> Khamis
I believe you are looking for t->getLine() and t->getColumn().
I think there is a little housekeeping to do in order to use them.
You have to make sure that in the lexer when a \n is found,
newline() is called. Otherwise I believe that ANTLR 2.7.4 automatically
tracks column and line information. There may be some work to do
in order to get tabs to display proper column info.
Did you see the do***entation on www.antlr.org?
Isaac


|