Skip to content

Conversation

@b-studios
Copy link
Collaborator

@b-studios b-studios commented Jul 24, 2025

This PR reorganizes parsing of modifiers on declaraionts, which are now grouped in Info. It also adds one new modifier private, which is parsed, but then ignored.

@b-studios b-studios changed the title Start by slightly refactoring parser Visibility Modifiers Jul 24, 2025
@b-studios
Copy link
Collaborator Author

@marvinborner I slightly refactored the parser w.r.t. to doc. My goal is to get rid of all usages of documentedKind and maybeDocumentation, since this will help me to generalize Doc to arbitrary meta data about a definition.

Could you check whether my changes so far make sense or whether you can construct an example which either:

  1. does not parse
  2. has different spans

@b-studios
Copy link
Collaborator Author

Sidenote: I removed a couple of nonterminal calls since the corresponding function was always called immediately under another nonterminal call.

@marvinborner
Copy link
Member

I'll have to try more later, but it looks good so far.

@b-studios
Copy link
Collaborator Author

There are two very annoying things:

  1. featureFlagFromCapture, this is necessary since parsing the info already consumed the feature flag. This will automatically be better if we drop parsing captures at the front of a definition.
  2. documented takes a flag parseCaptures: Boolean. This is necessary to avoid eating the name of a constructor or operation as a capture set. Again, this will be automatically better once we drop parsing captures at the front of a definition.

Comment on lines +126 to +133
case class Info(
doc: Doc,
// we use Maybe[Unit] instead of Boolean to have position info for validation errors
isPrivate: Maybe[Unit],
isExtern: Maybe[Unit],
// TODO this should be moved from the Info to extern functions, once we changed the syntax
externCapture: Option[CaptureSet]
) {
Copy link
Collaborator Author

@b-studios b-studios Jul 24, 2025

Choose a reason for hiding this comment

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

I am also very open to changing the design of this info object. In order to report some errors on the flags, they are positioned (using Maybe[Unit] is a hack). However, an empty Info object still contains a lot of position info and thus complicates the tests etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could be more precise by having a type hierarchy of Info. This way certain modifiers could be excluded by construction.

@b-studios b-studios marked this pull request as ready for review July 31, 2025 13:50
@b-studios
Copy link
Collaborator Author

I'm fine with merging this now in order to avoid conflicts with other PRs (especially #1097). Merging it now will parse private and then simply ignore it. We can later decide what to do with this info :)

@b-studios
Copy link
Collaborator Author

@timsueberkrueb what do you think?

@b-studios
Copy link
Collaborator Author

@jiribenes is it possible to run this on the community build before merging?

@timsueberkrueb
Copy link
Contributor

@b-studios I'm happy with this being merged and rebasing my changes.

@b-studios b-studios merged commit 2d012a3 into master Jul 31, 2025
2 checks passed
@b-studios b-studios deleted the feature/modifiers branch July 31, 2025 15:01
@b-studios
Copy link
Collaborator Author

Merging since its not (yet) Friday :)

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.

4 participants