[Pharo-project] [Moose-dev] Re: how to deal with string position in relation to cr/crlf

Tudor Girba tudor.girba at gmail.com
Thu Apr 28 11:40:45 CEST 2011


Hi,

On 28 Apr 2011, at 10:55, Toon Verwaest wrote:

> What is the problem exactly? Do you somewhere rely on exact position in the complete string?

Yes, I need to rely on this position afterwards, for example, for relating model pieces to the source code. The question is how to retrieve and how to store this information.

> What you could do is just keep line + column number since that stays fixed. Just increment newline on the systems newline sequence, and set column back to 0.

Indeed. The problem is that the token of PetitParser only knows the character position from the stream. This would mean that we would have to modify the tracking of the position with extra information.

Is there no other option?

Cheers,
Doru



> On Apr 28, 2011 10:48 AM, "Tudor Girba" <tudor.girba at gmail.com> wrote:
> > Hi,
> > 
> > I have a small problem related to file line endings and storing the token information of PetitParser.
> > 
> > Sometimes, we parse the sources on Windows and then manipulate the model on Linux or Mac. In this context, if I store the token positions in a string, I encounter problems because CR and LF are considered characters, but the line endings can vary.
> > 
> > ('abc', Character cr asString , 'd') findString: 'd'.
> > ==> 5
> > 
> > ('abc', Character cr asString , Character lf asString, 'd') findString: 'd'.
> > ==> 6
> > 
> > 
> > How would you approach this problem?
> > 
> > Cheers,
> > Doru
> > 
> > 
> > --
> > www.tudorgirba.com
> > 
> > "Every thing has its own flow."
> > 
> > 
> > 
> > 
> > 
> _______________________________________________
> Moose-dev mailing list
> Moose-dev at iam.unibe.ch
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"We are all great at making mistakes."










More information about the Pharo-project mailing list