Re: 回复: Re: [antlr-interest] token position detection problem
Martin Probst
mail at martin-probst.com
Tue May 2 11:58:55 PDT 2006
> 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
More information about the antlr-interest
mailing list