[antlr-interest] character scan

Meena Moktali mmoktali at bphx.dk
Fri Apr 8 00:40:40 PDT 2005


hi Bharath,
Thanks a lot for the help.I am working on your suggestions.
The class ExtentToken will serve the purpose I guess.

Meena



-----Original Message-----
From: Bharath Sundararaman [mailto:Bharath.Sundararaman at starthis.com]
Sent: 7. april 2005 15:34
To: Meena Moktali; atripp at comcast.net; Bryan Ewbank; Antlr-Interest
(E-mail)
Subject: RE: [antlr-interest] character scan


Hi Meena,

Here's a suggestion for computing line length:

For each of your tokens, the getColumn() method already provides you
with the beginning column; If you know how to find the ending column
number of a token (for now, assume you do), endColumn() - getColumn()
gives you the length of a token. 

In the lexer, if you have a counter that keeps incrementing every time a
white space is encountered, you would cover the whitespaces.

Add up the lengths of the tokens that you encounter with the whitespaces
and you get the length of line.A

When the length increases 72, you could check if the next token fetched
is an "of" or "to" and then do the line break.

Two things you should definitely look at:

1) antlr-2.7.x\examples\java\preserveWhiteSpace is an example grammar
that comes with ANTLR installation and 

2) To compute the ENDING COLUMN of a token, refer to this tutorial:
http://www.milk.com/kodebase/antlr-tutorial/

Hope this helps.

Bharath.

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Meena Moktali
Sent: Thursday, April 07, 2005 7:07 AM
To: atripp at comcast.net; Bryan Ewbank; Antlr-Interest (E-mail)
Subject: RE: [antlr-interest] character scan

hi all!
I want to know the length of a line.A sample text is as follows.

"map CURRENCY_SPACE in KSPS4_MSG to TEXT_CODE of STD_MSG_PARM_V of
STD_MSG_CLIENT_SRV_I"

I want to divide the line into 2 if it increases more than 72
characters.And the line break should be at
an 'of' or 'to'.

any ideas?

Meena




-


More information about the antlr-interest mailing list