Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API to read source position #234

Closed
re-xyr opened this issue Jun 3, 2021 · 3 comments · May be fixed by #238
Closed

API to read source position #234

re-xyr opened this issue Jun 3, 2021 · 3 comments · May be fixed by #238

Comments

@re-xyr
Copy link

re-xyr commented Jun 3, 2021

As title. ANTLR allows to read the source interval (start offset, end offset, start row, end row, start col, end col) of any node. Trifecta has DeltaParsing. I did not find such an API here and I think this is a crucial feature for any further error reporting after parsing.

@johnynek
Copy link
Collaborator

johnynek commented Jun 3, 2021

There is Parser.index which gives the current offset, which can be used to get the range: get index, parse, get the index. If you want line and column numbers see LocationMap which can convert offsets into rows and columns.

@re-xyr
Copy link
Author

re-xyr commented Jun 4, 2021

I see. Do we want to provide Carets and Spans like Trifecta? If so maybe I can make a pr.

@johnynek
Copy link
Collaborator

johnynek commented Jun 4, 2021

Yeah, that could be nice, especially if we can do it without breaking compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants