BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
586 stars 165 forks source link

Question: Using functor to store position information #176

Closed Centril closed 3 years ago

Centril commented 8 years ago

According to bnfc --help: --functor Make the AST a functor and use it to store the position of the nodes

How would you go about storing the position of the nodes? The type that

parseProgram = pProgram . myLexer

yields is:

parseProgram :: String -> Err (Program ())

I.e: no position information is added... So does that mean that you have to use something else than happy, or can you get it to add that position information for you?

pascalh commented 8 years ago

If I read the bnfc sources correctly source positions are not supported by the happy backend of bnfc. Actually the lexer generated by alex yields a list of tokens which are annotated with their source positions, but the happy parser ignores them.

gdetrez commented 8 years ago

@pascalh is correct, the help comment describe the intended behavior but I still need to find time to complete the feature. The functor part works but not the position part...

Sorry for the inconsistent documentation :confused:.

Centril commented 8 years ago

Any updates on this @gdetrez ?

gdetrez commented 7 years ago

@Centril partly: I have done some work on this but I was interrupted by other things...

I'll try to rebase and push what I already have this week and see if I can finish it soon-ish. Would you be able to provide some feedback?

Centril commented 7 years ago

@gdetrez Sure, what type of feedback do you want? Peer review or testing (or both)?

Just give me a link to the commit at which point to test it

woehr commented 6 years ago

Is there any chance of getting this merged? Can I help somehow?

JKTKops commented 5 years ago

Any news on this? This would be a very useful feature!

andreasabel commented 5 years ago

Seems like this feature sits on an unmerged branch https://github.com/BNFC/bnfc/compare/176-source-position which my predecessor left behind. After three years of course it does not merge cleanly any more. I don't know if there was a reason this was not finished.

I'd be happy for someone to pick it up and integrate it with the current source of BNFC.

andreasabel commented 3 years ago

This has been implemented by @Commelina in #327 and will be released with 2.9.1.

andreasabel commented 3 years ago

Released in 2.9.1.