Open tgjones opened 11 years ago
Thanks for reporting a possible improvement!
Sure, this can be done. It will require a bit of thought but it's doable.
I'll see if I can get some time with this in the coming week, unless you want to take a stab at it yourself.
Thanks! I did have a go at implementing it, but I didn't get very far. It was a little while ago now, but from what I remember I could maybe get the line number, but not the column number of the current token. Ideally both would be available to the callback.
I will try to find time to take another stab at it.
There's been a lot of life between me and programming in my spare time unfortunately. :) It's a great feature, and I should implement it, but there is not likely to be time to do so currently for (starting) a family reasons :-)
I am building a compiler in which semantic analysis will be done a separate pass, after the AST has been built. But in order to report line numbers for semantic errors, I need to associate AST nodes with their corresponding token position.
The token position is currently only provided (to SetErrorFunction) if a parse error occurs. But perhaps there could be another overload of SetReduceFunction, where the callback is given the lexer state as well as the list of objects to reduce?