Skip to content

Conversation

@ltratt
Copy link
Member

@ltratt ltratt commented Dec 21, 2024

This PR first fixes #477 and then goes further and gives the other currently-pub fields accessor functions, and marks the fields as deprecated. This will allow us -- one day! -- to remove pub from the fields. Right now, this change doesn't require a major release.

These are properties that users sometimes want to access, but it's
better if we don't directly expose the underlying fields.
This will allow us to, eventually, de-`pub` it.
/// If `Some`, this specifies the ID that lexemes resulting from this rule will have. If
/// `None`, then this rule specifies lexemes which should not appear in the user's input.
pub fn tok_id(&self) -> Option<StorageT> {
self.tok_id
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is possible I'm missing something obvious, but I'm wondering if there is a reason that this doesn't return a cfgrammar::TIdx or some such?

Copy link
Member Author

Choose a reason for hiding this comment

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

I also wondered that, but it's currently storing a StorageT. I can't fully remember what I might expect this to be, to be honest...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like it is also exposed publicly as StorageT via the lrpar::Lexeme trait here. So it doesn't seem to be unprecedented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be better as TIdx? If so, we might as well make the API as unsucky as we can reasonably make it!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking further into it, I don't think TIdx would actually the right thing it should correspond to. For example, this usage in token_name isn't referring to one of these tok_id values at all, but an index into a Grammar specific array.

So, I'm leaning towards it being okay as is, at the very least nothing is ringing any bells for it being any of the other opaque type wrappers, and it certainly doesn't appear that TIdx would be right.

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent detective work! OK I feel adequately comfortable with this PR now then.

@ratmice
Copy link
Collaborator

ratmice commented Dec 21, 2024

Besides that one question I had (which it seems we can disregard) it looked good to me.
I didn't notice anything that appeared to need squashing, but if you would like to, please do.

@ratmice ratmice added this pull request to the merge queue Dec 21, 2024
Merged via the queue into softdevteam:master with commit 9a2ef04 Dec 21, 2024
2 checks passed
@ltratt ltratt deleted the pub_fns branch February 3, 2025 18:33
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.

Make Rule::re_str public again.

2 participants