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

Decouple parse & resolve steps #148

Merged
merged 58 commits into from
Sep 14, 2022
Merged

Conversation

xonixx
Copy link
Contributor

@xonixx xonixx commented Aug 30, 2022

This PR is prepared in context of #144.

It implements the part

However, that would require separating out the resolver to a separate pass ... which is probably good to do anyway, but a bit of work.

Since the change is reasonably big I would add couple clarifications.

  1. I tried to do only minimal work to get the task in question done, though I could not resist some (hopefully) minor refactorings and restructuring.
  2. It appears that resolving step needs some positions information, but not for all nodes. So at this point to keep the things simple and limited I wired the position only through very few of AST nodes. If need be we can equip all AST nodes with positions in generic way later but no need at this point.
  3. I decided that we don't need to move ALL things that were in resolve.go to separate step. To me some things logically belong more to parsing than resolution. Example: multiExprs thing.
  4. Since the parsing & resolving needed the same approach to errors with positions I generified this a bit by introducing the PositionError which is now panic-thrown internally by both parser & resolver. However I kept the external parser interface intact to return documented ParseError.
  5. I checked the test suite - seems to work fine.

# Conflicts:
#	parser/parser.go
@xonixx
Copy link
Contributor Author

xonixx commented Aug 31, 2022

Note that I just merged another change, so there's a small conflict in parser.go which needs fixing.

Merged master.

@xonixx
Copy link
Contributor Author

xonixx commented Sep 8, 2022

@benhoyt Any update?

@benhoyt
Copy link
Owner

benhoyt commented Sep 8, 2022 via email

@xonixx
Copy link
Contributor Author

xonixx commented Sep 8, 2022

Sure no problem. Have a pleasant trip!

Copy link
Owner

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Thanks for your work here. I think it's really good work overall. I've left a bunch of comments, mostly minor and hopefully easy enough to address.

internal/ast/ast.go Outdated Show resolved Hide resolved
internal/ast/ast.go Outdated Show resolved Hide resolved
internal/ast/walk.go Show resolved Hide resolved
internal/ast/walk.go Outdated Show resolved Hide resolved
internal/ast/walk.go Outdated Show resolved Hide resolved
parser/parser.go Outdated Show resolved Hide resolved
parser/parser.go Outdated Show resolved Hide resolved
parser/parser.go Show resolved Hide resolved
internal/resolver/resolve.go Outdated Show resolved Hide resolved
parser/parser.go Show resolved Hide resolved
@xonixx
Copy link
Contributor Author

xonixx commented Sep 13, 2022

Hey @benhoyt! Hopefully, I've resolved all items except for the one with WalkExprList/WalkStmtList - please see my comment there. What do you think?

Copy link
Owner

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Great! Let's just fix these few comment nits and I'll squash and merge this!

internal/ast/ast.go Show resolved Hide resolved
internal/ast/ast.go Show resolved Hide resolved
internal/ast/ast.go Show resolved Hide resolved
internal/ast/ast.go Outdated Show resolved Hide resolved
internal/ast/walk.go Outdated Show resolved Hide resolved
internal/resolver/resolve.go Outdated Show resolved Hide resolved
parser/parser.go Show resolved Hide resolved
@xonixx
Copy link
Contributor Author

xonixx commented Sep 13, 2022

Done.

@benhoyt benhoyt merged commit 0a84980 into benhoyt:master Sep 14, 2022
@benhoyt
Copy link
Owner

benhoyt commented Sep 14, 2022

Thanks, merged!

@xonixx xonixx mentioned this pull request Oct 6, 2022
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