datalust / superpower

A C# parser construction toolkit with high-quality error reporting
Apache License 2.0
1.05k stars 98 forks source link

Unify StringSegment/TextSpan #113

Closed candoumbe closed 3 years ago

candoumbe commented 4 years ago

Recently, .NET landed the new StringSegment structure and I think this library could benefit of it. It seems that the TextSpan class serves the same purpose and this project could greatly benefit Am I right ? I started working on a small project called DataFilters that extensively uses this library to build a kinda generic search syntax and I must say I really enjoyed working with this library so far.

chrisspre commented 4 years ago

StringSegment seems to be not very different from ReadOnlySpan/ReadOnlyMemory Would moving to ReadOnlySpan (or a wrapper around ReadOnlySpan that captures line and column numbers) be another option ?

AndrewSav commented 4 years ago

@candoumbe @chrisspre what problem are you trying to solve? To me it seems that TextSpan is working well for what it was designed. Also it is not possible to change StringSegment/ReadOnlySpan for our purposes, and they do not have Position so in any case a new class will have to be created, similar to TextSpan. Which is already there and working well.

Could you please expand a bit more on benefits of your proposal, balanced vs additional work to implement it?

candoumbe commented 4 years ago

@candoumbe @chrisspre what problem are you trying to solve? To me it seems that TextSpan is working well for what it was designed. Also it is not possible to change StringSegment/ReadOnlySpan for our purposes, and they do not have Position so in any case a new class will have to be created, similar to TextSpan. Which is already there and working well.

Could you please expand a bit more on benefits of your proposal, balanced vs additional work to implement it?

Hi ! It was only a question and not a request to modify the existing code. I did not do a thorough analysis of the changes this would require and am more than happy with the way this library is now. In fact, I successfully used it to create a parser of my own