8000 Rewrite parser using LALRPOP by brendanzab · Pull Request #103 · gluon-lang/gluon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Rewrite parser using LALRPOP #103

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

Merged
merged 41 commits into from
Nov 30, 2016
Merged

Conversation

brendanzab
Copy link
Member

Fixes #69

@brendanzab
Copy link
Member Author

Very half done right now, but thought I'd post my progress anyway...

@@ -0,0 +1,233 @@
use std::iter;
Copy link
Member Author
@brendanzab brendanzab Aug 8, 2016

Choose a reason for hiding this comment

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

This file as broken - was trying to see if I could adapt the one from parser2 to work with the current lexer and AST.

@brendanzab
Copy link
Member Author

The most interesting part is probably the grammar definition: https://github.com/Marwes/gluon/pull/103/files#diff-1dbca9e85701699d5fce975a5912be7dR1

Still doesn't handle everything though.

OpenParen,
CloseParen,
OpenBracket,
CloseBracket,
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change these definitions?

@Marwes
Copy link
Member
Marwes commented Aug 8, 2016

Left a bunch of comments, not all of them immediately important so feel free to ignore those for the moment. Looks like you are on the right track for the most part but if you want to do some refactorings on the current code then maybe split that into a separate commit (though it can be in the same PR), makes it a bit easier to review.

@brendanzab
Copy link
Member Author

Sorry for the massiveness - still pretty explaratory. Just wanted to check I wasn't strying too far off the deep-end. I'm thinking I might try to keep heading towards adapting the old lexer. What do you think? Is the rewrite a decent enough improvement to push forward, considering the pain of adapting the old lexer?

@brendanzab
Copy link
Member Author

I can start off by making PRs to the current data structures to make it easier to integrate it with LALRPOP, now that I know what is needed.

@Marwes
Copy link
Member
Marwes commented Aug 8, 2016

What do you think?

Looks good 👍

Is the rewrite a decent enough improvement to push forward, considering the pain of adapting the old lexer?

The only truly tricky part of the lexer is the layout function which I think should be kept (at least for the moment). If you want to rewrite the rest (and it looks like you have done maybe 80% of that?) that's great but just doe whatever is easier there. I'd expect the rewrite of those parts to be a nice speed improvement as well.

@Marwes
8000 Copy link
Member
Marwes commented Aug 10, 2016

Something you may not have noticed is that the current parser have a bit of functionality built in to allow it to recover from errors and still produce an AST (even if its incomplete). It is currently only used to accept empty field accesses like record. which is necessary for completion to work for that case.

Is it possible have that work with LALRPOP as well? Taking it more generally, is it possible to recover from errors in LALRPOP (for the purposes of detecting multiple errors and/or to do completion or other analysis on an incomplete AST)?

cc @nikomatsakis

@brendanzab
Copy link
Member Author

Not sure - I assumed that was why we had Option<Result<...>> at least for the tokeniser...

@brendanzab
Copy link
Member Author

Still haven't really run the parser yet to see what it produces.

@Marwes
Copy link
Member
Marwes commented Aug 11, 2016

Option<Result<...>> is just to detect EOF and is only in the lexer anyway, no? The errors I want to recover from is on the parser.

@Marwes
Copy link
Member
Marwes commented Aug 28, 2016

Looks like there is a concept of fallible rules in LALRPOP though it is currently undocumented https://github.com/nikomatsakis/lalrpop/issues/40.

Looks like =>? is the syntax for it but I am unsure how to actually use it. Hopefully Niko can respond and give an example.

@brendanzab
Copy link
Member Author

I think I'm going to try to get back to this one now!

@Marwes
Copy link
Member
Marwes commented Aug 28, 2016

Good luck! Hopefully there are no other refactoring sidetracks needed!

@brendanzab brendanzab force-pushed the lalrpop_parser branch 2 times, most recently from d69725d to a9cc210 Compare November 29, 2016 11:16
@brendanzab
Copy link
Member Author

Would it be possible to merge this with the token unwrap? We could make an issue to fix it before the next release.

@Marwes
Copy link
Member
Marwes commented Nov 30, 2016 via email

@brendanzab brendanzab merged commit cc3d326 into gluon-lang:master Nov 30, 2016
@brendanzab brendanzab deleted the lalrpop_parser branch November 30, 2016 11:20
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.

3 participants
0