-
Notifications
You must be signed in to change notification settings - Fork 47
Added a default value for VersionSpecifier and some documentation
#1500
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
base: main
Are you sure you want to change the base?
Conversation
|
VersionSpecifierVersionSpecifier and some documentation
de31e98 to
eff04aa
Compare
ggiraldez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some questions and suggestions.
crates/language-v2/definition/src/model/nonterminals/struct_.rs
Outdated
Show resolved
Hide resolved
crates/language-v2/definition/src/model/nonterminals/struct_.rs
Outdated
Show resolved
Hide resolved
crates/language-v2/definition/src/model/nonterminals/struct_.rs
Outdated
Show resolved
Hide resolved
268fd86 to
2745ec0
Compare
ggiraldez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any more particular observations, but a more general question: do we need to differentiate between absent version specifier and Always? I don't see a reason to keep both possible states, and in that case we should change all other instances (eg. in StructItem, EnumItem, etc) of VersionSpecifier to remove the Option<>.
crates/language-v2/definition/src/model/utils/version_specifier.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Gustavo Giráldez <[email protected]>
Co-authored-by: Gustavo Giráldez <[email protected]>
Co-authored-by: Gustavo Giráldez <[email protected]>
Co-authored-by: Gustavo Giráldez <[email protected]>
Co-authored-by: Gustavo Giráldez <[email protected]>
Co-authored-by: Gustavo Giráldez <[email protected]>
2745ec0 to
8961b0d
Compare
The main reason is for the code generation engine, we expect most items of a parsed AST (of a language definition) to always have a span, most of the logic to derive spanned types works that way. So a As far as I could see we treat What this change does allow is that further down the stream, for example when building a lexer, we can simply use I agree it'd be a bigger win in ergonomics if we could get rid of the |
I see. I wasn't considering the model generation layer (partly because I haven't explored that part of the code sufficiently) and was thinking in terms of the model as a result, but they are tightly coupled. Thanks for the explanation! |
| language_v2_macros::compile!(Language( | ||
| name = Solidity, | ||
| binding_rules_file = "crates/solidity/inputs/language/bindings/rules.msgb", | ||
| root_item = SourceUnit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing crates/solidity-v2/inputs/language/bindings/rules.msgb as well.
Originally I wanted to stop wrapping
VersionSpecifierin anOption, and parse it asAlwaysif it's not present, but that brings some issues with the span information, and we'd need to differentiate between anAlwayswith span (explicit) and one without (implicit).However, I think having the default value representable is good to simplify some algorithms, in particular, the information of what a missing field on the language definition means is now explicit.
I also added some documentation here and there.