-
Notifications
You must be signed in to change notification settings - Fork 38
Replace ct_token_map with CTTokenMapBuilder
#588
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
Conversation
|
I haven't yet really had the need to use a custom lexer (though I've thought about doing so for implementing rusts raw strings), so I don't really have much of an opinion on the API. One thing I'll note is that in I don't remember/couldn't find where this would be tested, I wonder then if it isn't worth doing something similar here, I don't know if that is better than specifying a boolean flag or not, but perhaps it might help future proofing the case where some new clippy lint starts complaining. Then users wouldn't necessarily have to wait until we add an |
I don't have a strong opinion here, either approach is fine. I'll try to make a builder interface, though. This will be cleaner than passing booleans around 😄 |
Just for the record, I don't either it was just a thought. |
I tried the builder pattern, and it was clunky and not that useful in this situation. I propose leaving things as is. |
|
I would think that something as simple as |
ct_token_map that doesn't insert #[allow(unused)]ct_token_map with CTTokenMapBuilder
fc2f935 to
091115f
Compare
|
I believe everything is fixed 👌🏻 |
|
One minor comment, and then I think we're good to go. |
This commit adds `CTTokenMapBuilder` that replaces `ct_token_map`. It provides a few new features: - generated module is no longer `#[allow(dead_code)]` unless manually enabled. This helps to spot errors in custom lexers where some of the tokens are never emitted; - if generated module contains invalid identifiers, the generation will fail and suggest using `CTTokenMapBuilder::rename_map`; - `CTTokenMapBuilder::rename_map` accepts any iterable that yields pairs of strings, eliminating the need to convert static arrays of pairs of strings before passing them to builder. The `ct_token_map` function is deprecated since the next minor release (`0.14`).
|
Thanks! |
This commit adds
CTTokenMapBuilderthat replacesct_token_map. It provides a few new features:generated module is no longer
#[allow(dead_code)]unless manually enabled. This helps to spot errors in custom lexers where some of the tokens are never emitted;if generated module contains invalid identifiers, the generation will fail and suggest using
CTTokenMapBuilder::rename_map;CTTokenMapBuilder::rename_mapaccepts any iterable that yields pairs of strings, eliminating the need to convert static arrays of pairs of strings before passing them to builder.The
ct_token_mapfunction is deprecated since the next minor release (0.14).