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

Token locations #666

Merged
merged 3 commits into from
Apr 13, 2021
Merged

Token locations #666

merged 3 commits into from
Apr 13, 2021

Conversation

soutaro
Copy link
Member

@soutaro soutaro commented Apr 12, 2021

This PR is to store token-level locations in AST locations. It introduces Location::WithChildren class which saves child locations inside a location.

loc = Location::WithChildren.new(buffer: buffer, start_pos: 0, end_pos: 13)
loc = loc.merge_required({ name: 1...5 })
loc = loc.merge_optional({ args: 5...13 })

loc[:name]      # => Location instance for `Array`
loc[:args]      # => Location instance for `[String]`

AST now stores locations for its name tokens and some of the keyword tokens.

@soutaro soutaro merged commit e5c6901 into master Apr 13, 2021
@soutaro soutaro deleted the location branch April 13, 2021 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant