jsjavaparser icon indicating copy to clipboard operation
jsjavaparser copied to clipboard

Line numbers

Open tomitrescak opened this issue 8 years ago • 5 comments

How difficult would it be to include line numbers in the generated AST? Without line numbers it's not possible to generate source maps. Do you know of any other technique on how those source maps can be generated? Thanks!

tomitrescak avatar May 31 '16 10:05 tomitrescak

I don't see easy way to do it - maybe using location() function inside each parser action. I would also try to implement custom PEG plugin which appends location() info to each node automatically.

mazko avatar May 31 '16 17:05 mazko

Yes, I solved it by adding location into each function and then recompiled grammar with pegjs, was not that much work. Would you consider PR?

tomitrescak avatar May 31 '16 20:05 tomitrescak

Currently I have no much time to support this project, but any pull requests are welcome of course.

mazko avatar Jun 02 '16 16:06 mazko

@tomitrescak Is there any fork / PR yet? Where exactly did you do your changes to support output of Line numbers?

gorootde avatar Mar 14 '17 21:03 gorootde

Here you go: https://gist.github.com/tomitrescak/6c18bfb437c123ebcb8bd694a062cad7 But it's probably way behind any changes done since June/2016 in the official package.

tomitrescak avatar Mar 16 '17 02:03 tomitrescak