sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

add node location / position

Open gustavomick opened this issue 4 years ago • 1 comments

wondering if you can add node position, and or if there is any reason for not to have it. similar to this https://github.com/redotjs/redot/blob/b5abff784e9952d12d3713f27839bed12ee173df/packages/redot-parse/dot.pegjs#L13 thanks!

gustavomick avatar Jan 21 '21 20:01 gustavomick

I think pegjs does this automatically (see documentation)

The code inside an action can also invoke the error function, which also makes the parser throw an exception. The function takes two parameters — an error message and optional location information (the default is what location would return — see below). The message will be used by the thrown exception.

What are the advantages of adding the location function manually to each rule?

mbaumgartl avatar Feb 10 '21 16:02 mbaumgartl