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

Add positional information #84

Closed
wants to merge 12 commits into from
Closed

Conversation

baransu
Copy link
Contributor

@baransu baransu commented Aug 29, 2017

Huge thanks to @joeandaverde for creating most of what is implemented in this PR in the first place. Also shoutout to the @laslowh who helped with rest of the types. You're the best!!! 🎉

All Expressions and Statements now have Meta as last argument { line: Int, column: Int }.
Positional information are not perfect. There as some cases where whitespaces are omitted in column count but besides everything works as expected.

This is big breaking change and I'm counting on your feedback.

Fixes: #13


Almost all types are converted contain meta information except:

  • TypeApplication
  • Application
  • BinOp
  • Variable

They are advanced because of

  • partial application in case of TypeApplication and Application
  • creating in place Variable and BinOp types

~I was trying implement Meta for those as well but I've failed lacking knowledge and full understanding of parser-combinators as well as advanced Elm. That why I'm creating this WIP PR, counting on your support.~~

@wende wende self-requested a review September 4, 2017 16:20
@@ -1,42 +1,34 @@
module Expression exposing (all)
module Expression
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be a part of this PR. It solves different issue

@@ -0,0 +1,64 @@
module Helpers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@@ -0,0 +1,29 @@
module Multiline exposing (application)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@baransu
Copy link
Contributor Author

baransu commented Sep 27, 2017

Support for all types has arrived!!! 🎉

Huge shoutout to @joeandaverde and @laslowh for their work on making this changes possible.
This is huge breaking change and I'm looking forward on any feedback.

@baransu baransu changed the title [WIP] Add positional information dd positional information Sep 27, 2017
@baransu baransu changed the title dd positional information Add positional information Sep 27, 2017
Copy link
Collaborator

@wende wende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outstanding work!
Few styling comments on my end. We also need to consider some [half]measure to solve the line numbering bug in application before releasing it in next major version

Record
<$> braces
(commaSeparated
((,)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to avoid splitting arguments to next line
Backpipe (<|) twice could do the job here

(withMeta
((\a -> (\m -> ( a, Variable [ a ] m )))
<$> loName
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Could rewritten to something similar to

withMeta <|
  Record <$> braces <| comaSeparated <| withMeta <| (\a m -> (a, Variable [a], m) <$> loName)

\() ->
chainl
(withMeta ((\m -> flippedApp m) <$ spacesOrIndentedNewline ops))
(term ops)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

)
:: remE
)
remO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh god 😮 Ditto

a
e
m
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

)
(var "k" { line = 12, column = 1 })
{ line = 12, column = 0 }
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the bug of line numbers (Every argument's line being 1 too small apart from the last one) that I assume is coming from Combine dependency rather then this codebase, the isApplication` could be slightly modified to produce this output

@collosi
Copy link

collosi commented Dec 19, 2017

Just checking in on this. Has any progress on the line numbering bug been made?

@wende
Copy link
Collaborator

wende commented Dec 19, 2017

@laslowh So the issue is with lines starting from index 0 (rather than 1) then jumping straight to 2, and treating the last line in the expression as the same as one before. So essentially instead of getting 1,2,3,4,5, we're getting 0,2,3,4,4. No idea what's the cause
Could use a little work on that. I might try to take a look this weekend

CC. @baransu

@dynajoe
Copy link

dynajoe commented Dec 19, 2017

Looks like the line numbering issues were addressed:

https://github.com/elm-community/parser-combinators/blob/master/CHANGELOG.md

I've started work on fixing the tests and upgrading the package. baransu#2

@paulsonnentag
Copy link

Is this PR still active? If not could I help getting this feature merged?

@wende
Copy link
Collaborator

wende commented Jul 19, 2018

@paulsonnentag there's nobody actively working on this. It'd be great if you tried your shot

@paulsonnentag
Copy link

@joeandaverde I've checked out your latest commit, but it seems like there are still a lot of cases where the line/column number is not correct. Do you have any tips on what the problem could be? Otherwise, I'll have to dig deeper into the code.

@wende wende assigned wende and unassigned baransu Oct 27, 2018
@wende
Copy link
Collaborator

wende commented Oct 27, 2018

I've started working on this issue this weekend and it looks like it will see a closure soon

@baransu
Copy link
Contributor Author

baransu commented Oct 27, 2018

@wende If you need any help, let me know 😃

@wende
Copy link
Collaborator

wende commented Apr 25, 2019

Closed in favour of #99

@wende wende closed this Apr 25, 2019
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.

add positional information to AST
5 participants