[antlr-interest] For getCharPositionInLine(), is there a way to make tab count for 8 chars instead of 1?

Sam Harwell sharwell at pixelminegames.com
Thu Sep 8 10:23:33 PDT 2011


I actually asked Dr. Parr recently about why the property is called
CharPositionInLine instead of just Column. The name was actually picked to
make it clear that tab and space are each treated as 1 character. When
talking about parsing, the term "Column" also always refers to the character
position within a line.

The notion that the width of a tab is not equal to the width of a space is a
UI concept independent of the parsing problem, and widely varies as you move
from IDEs to word processors to typesetting systems. Whether it's called
"CharPositionInLine" or "Column", the parser will provide consistent
information about character positions and you'll need to independently
implement the "width" of your tab characters as it applies to your
particular target environment.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Dejas Ninethousand
Sent: Thursday, September 08, 2011 11:59 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] For getCharPositionInLine(), is there a way to
make tab count for 8 chars instead of 1?

I want to ensure that line and cols reported by my parser line up with what
the user would see in a program like Textpad.  In Textpad if you move the
cursor across a tab character the column counter and cursor advance by 8 and
not 1 even though only one char in the stream has been traversed.  Can I
configure some setting in ANTRL such that tab chars are treated the same way
for column reporting?

Thanks.

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list