-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add parsing (only) support for class prefix and 'extends' #1880
Add parsing (only) support for class prefix and 'extends' #1880
Conversation
explorer/syntax/parser.ypp
Outdated
@@ -1059,14 +1064,28 @@ type_params: | |||
| tuple_pattern | |||
{ $$ = $1; } | |||
; | |||
class_declaration_prefix: |
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.
Seems to get the job done (tests passing), but I may be missing some subtleties of the parser.
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.
No, this approach seems reasonable to me. I'm pretty sure these are mutually exclusive.
Parsing only support, gracefully fails at compilation indicating that 'base', 'abstract', and 'extends' are not yet supported.
6b4cc14
to
5d9a669
Compare
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.
Thanks! I think it's good to put in an error like this, and the change looks correct structurally. I'd just like to think about better names for the ClassPrefix enum, because I think the name doesn't quite capture the choice being made.
explorer/syntax/parser.ypp
Outdated
@@ -1059,14 +1064,28 @@ type_params: | |||
| tuple_pattern | |||
{ $$ = $1; } | |||
; | |||
class_declaration_prefix: |
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.
No, this approach seems reasonable to me. I'm pretty sure these are mutually exclusive.
explorer/ast/declaration.h
Outdated
@@ -179,31 +180,40 @@ class SelfDeclaration : public Declaration { | |||
auto value_category() const -> ValueCategory { return ValueCategory::Let; } | |||
}; | |||
|
|||
enum class ClassPrefix { StandardClass, BaseClass, AbstractClass }; |
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.
enum class ClassPrefix { StandardClass, BaseClass, AbstractClass }; | |
enum class ClassExtensibility { None, Base, Abstract }; |
I think this should probably be "None, Base, Abstract" because (with enum class
) the "Class" suffix feels a little repetitive. But I also think "Prefix" isn't quite capturing the state: looking at the design wording, maybe "Extensibility" capture this better?
Suggestion is merging these two thoughts, though will obviously require more code edits.
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 agree with that. By merging these two thoughts
I understand renaming the enum plus updating its values, is that what you meant? Because it doesn't look like a lot of code edits too me, still super quick :)
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.
And done.
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.
Yes, that's what I meant, thanks. :)
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.
(just explicitly requesting changes)
Thanks for the contribution! And merged. |
Provides a first implementation iteration towards class prefix and extension, along with user-friendly error regarding missing implementation for #1881
Explorer behavior
For class prefix
base
andabstract
:For extension with
extends
:Motivation