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

WIP: Annotate expressions with their location #35

Merged
merged 12 commits into from
Jun 28, 2016

Conversation

expipiplus1
Copy link
Collaborator

Some initial work towards fixing #33

This is far from complete, Some functions need implementing, and there's some tidying up to do in the parser. Annotation.hs could also use a little more organisation.

It typechecks though :)

@jwiegley
Copy link
Member

@expipiplus1 Nice! If this is a work in progress, shouldn't I wait until you're done?

@expipiplus1
Copy link
Collaborator Author

Yes! Please don't merge now!

@expipiplus1
Copy link
Collaborator Author

expipiplus1 commented Jun 25, 2016

@jwiegley How would you suggest dealing with whitespace in the expression annotations?

It's not possible to eat the whitespace before recording the start of the span as some parsers are whitespace sensitive (the tests fail for select).

There isn't any opportunity to record trailing whitespace, as token eats any trailing whitespace.

The best option I can think of is to postprocess the source spans to remove leading and trailing whitespace.

Another option would be to split the parser and the lexer, but that'd probably be a much larger job.

Another option would be to leave it as is, and let the user deal with it :)

@jwiegley
Copy link
Member

For now we can let the user deal with it, but I like the idea of splitting parser and lexer.

@expipiplus1
Copy link
Collaborator Author

The annoying thing is that I'm the user at the moment :)

If I find a tidy way of stripping whitespace I think I'll do that.

@expipiplus1
Copy link
Collaborator Author

Another possibility would be to modify the definition of whitespace so that it maintains some kind of beforeWhitespacePos + afterWhitespacePos state. I'm not sure if this is possible in a Trifecta parser though. Does this idea makes sense?

@expipiplus1
Copy link
Collaborator Author

This is working well enough now for me to have made this little utility to automatically update fetchgit values in nix expressions to the latest versions.

https://github.com/expipiplus1/update-nix-fetchgit

@expipiplus1
Copy link
Collaborator Author

@jwiegley aside from some tests and documentation, is there anything major preventing this from being merged

@jwiegley jwiegley merged commit e5f64d5 into haskell-nix:master Jun 28, 2016
Anton-Latukha pushed a commit that referenced this pull request Jul 31, 2020
WIP: Annotate expressions with their location
@expipiplus1 expipiplus1 deleted the annotate branch October 29, 2020 02:13
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 this pull request may close these issues.

2 participants