-
Notifications
You must be signed in to change notification settings - Fork 21
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
Parse error for functions with arguments in next line #1
Comments
Tried to fix it with changing: application : OpTable -> Parser Expression
application ops =
rec <| \() ->
term ops `chainl` (Application <$ spaces') to application : OpTable -> Parser Expression
application ops =
rec <| \() ->
term ops `chainl` (Application <$ choise [spaces', whitespace]) but failed. (multiple functions and module fixity scanning tests fail in this case, but the example passes) |
I made an attempt here: Warry@fa8bba8 So it works (seems as permissive as elm itself), but obviously not where indentation matters ( |
I tried out what the Elm compiler does to some pathological cases. It seems pretty complicated: it allows reducing indentation after a function name, but it struggles when keywords like I believe that a perfectly valid way to parse Elm would be to only care about whether there is indentation at all. If there is no indentation, parse it as the beginning of a statement. |
I think that some expressions that require indentation (i.e. case expressions) need to have all bindings on separate lines. I believe that is why shamansir's solution won't work (at least in part). This currently works: z = case Just 1 of Nothing -> 0
Just y -> y However, this should fail because This will require a change to the parser to track newline and indentation state. |
It seems that if there's only 1 binding for the case expression it can be on the same line as the z = case Just 1 of _ -> 12 |
@joeandaverde Yup. But given that current parser is totally whitespace agnostic it looks like a major change to entire project |
@joeandaverde I have thought about this a lot and made some experiments. Based on that I think that if it is ok to be less strict than the elm compiler, we do not need to track indentation. It seems that lines containing I don't know what the best way to code this would be. Any suggestions? First thing I can think of is to just do a lookahead of the next line. |
Maybe I misunderstand your suggestion. Would this still align with your thinking?
|
@joonazan Yes. You're right. I even wrote a regex that tracks these lines but for some reason it doesn't want to work in Elm (only Regex 101)
I tried to recognize these lines using |
Hi All, https://github.com/tunguski/elm-ast I've worked basing on test page parsing all core and http modules. I've got to the point where all these modules are parsed correctly. You may check results here: https://tunguski.github.io/elm-ast/example/ I assume that most of the issues created in the fork are still open for this project: https://github.com/tunguski/elm-ast/issues?utf8=%E2%9C%93&q=is%3Aissue%20 Still fork is drastically changed because I have merged Statements and Expressions modules. That was required to fix parsing of Let bindings if I remember correctly. Unfortunately on that stage I did not create issues for all problems found. Hope this comment will help a bit. Thanks for all your work! |
@tunguski Making comments parse as whitespace is ingenious! This repository has some advantages over yours, but it lacks in functionality. By incorporating your solutions to some issues we will arrive at a great result. Keep up the good work! |
@tunguski Great work. I went through your issues and here is the outline of them in this repository: |
Plus I noticed that your version also doesn't parse characters with escaped sequences like |
@wende You're right! I've checked what is actual parsing status using this library and it is 19/27 files parsed correctly (tested on core and http). That's a fundamental change! I would be really happy to switch back to this library when it will be able to parse all core libraries. I'll keep my fingers crossed! Edit (removed list of code examples): I've created two issues that seem to be only problems (beside proper comments parsing). |
Attempt to complete location information for expressions
While testing your great library I've found this case:
that compiles on http://elm-lang.org/try, but does not parse on http://bogdanp.github.io/elm-ast/example/.
After modifying to
div [] [ text "Hello, World!" ]
(one line) code parses correctly.Not sure do you work on full compatibility, but wanted to report you this issue.
The text was updated successfully, but these errors were encountered: