Start and end positions

Aaron Tomb aarontomb at
Sat Jun 6 15:25:12 EDT 2009

On Thu, Jun 4, 2009 at 5:38 AM, Benedikt Huber<benedikt.huber at> wrote:
> On 01.06.2009, at 22:29, Aaron Tomb wrote:
>> Hello,
>> A number of parsers that I've encountered before decorate their ASTs
>> with two pieces of position information: a start position and an end
>> position. Currently, Language.C only has one piece of position
>> information, although I notice that there is a PosLength data type in
>> Language.C.Data.Position.
> Hi Aaron,
> The function you're looking for is getLastTokenPos.
> A while ago I discussed this with John von Enk
> (
> Language.C supports exactly what you asked for, given preprocessed source.
> In the presence of macros, the position information is neccessarily
> inaccurate;
> you need cooperation from the preprocessor for exact back annotation then.

Ah, great. I'll look into that some more.

>> Does anyone have any thoughts on either adding an end position or
>> making wider use of PosLength?
> Please have a look at the (incomplete) sourceview example.
>> Of course, there will be an issue with
>> preprocessor macros, as there is with the current position
>> information. However, it seems as though start and end line numbers
>> would still be useful, even if column information is unreliable.
> As I said, I've added this some time ago. It wasn't that easy, and I'm
> pretty sure
> the current implementation is still buggy, so I'm grateful for any bug
> reports.

I'll be sure to file a bug report if I find anything amiss.

> I'm sorry I don't have much time to spend on the project lately, but if the
> analysis stuff
> you have been working on is in good shape, I'll release a new version on
> hackage this
> weekend.

The type checking code still has some bugs, so I'm not sure if it's
quite ready for a release. However, I am going to have a bit more time
to spend on it shortly, so I can probably get it into good shape soon.


More information about the Language-c mailing list