=?gb2312?q?=BB=D8=B8=B4=A3=BA=20Re:=20=BB=D8=B8=B4=A3=BA=20Re:=20[antlr-i?=
=?gb2312?q?nterest]=20token=20position=20detection=20problem?=
=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20Sun?=
sunjigang1965 at yahoo.com.cn
Tue May 2 16:06:42 PDT 2006
Thanks a lot.
In lexer grammar, I changed " '\t' {setTabSize(4);} " to " | {setTabSize(4);} '\t' ". Works ok.
I am sure, in this way, TAB width had changed from 8 to 4 before the first TAB met.
Jigang
--- Martin Probst <mail at martin-probst.com>дµÀ:
>
> > As showed on the attached picture, in the 4th line "
> > System.out.println(8);", the position of '8'
> > is detected as line = 4, column=28,the only TAB character before
> > "System" is conted as 8 spaces; I
> > made an exact same text by copy and paste,this time the position
> > of 8 inside method add is
> > line=17, column=24, the TAB inside is counted as 4 correctly.
>
> I might be mistaken (no ANTLR source tree at hands) but aren't you
> supposed to do:
> "setTabWidth(4);" before starting to parse? E.g.
>
> Parser myParser = new Parser();
> myParser.setTabWidth(4);
> myParser.axiom();
>
> I think you're setting it every time you encounter a tab, but only
> after actually consuming the tab. This way, the first tab will always
> be mistaken, subsequent ones will be read correctly.
>
> Regards,
> Martin
>
>
___________________________________________________________
ÑÅ»¢1GÃâ·ÑÓÊÏä°Ù·Ö°Ù·ÀÀ¬»øÐÅ
http://cn.mail.yahoo.com/
More information about the antlr-interest
mailing list