-
Notifications
You must be signed in to change notification settings - Fork 52
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 support for leading |
and &
in types
#306
Conversation
) -> ParserResult<ast::TypeInfo> { | ||
let mut is_union = false; | ||
let mut is_intersection = false; | ||
|
||
let mut types = Punctuated::new(); | ||
|
||
let leading = if simple_type.is_some() { |
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.
or_else
probably better
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'm not sure what I would use or_else
on here
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.
Ah I see--it is inverted
full-moon/src/ast/parsers.rs
Outdated
let mut current_type = simple_type; | ||
|
||
loop { | ||
let Ok(current_token) = state.current() else { | ||
return ParserResult::NotFound; | ||
let ty = if current_type.is_some() { |
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.
.take().unwrap_or_else(
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.
this doesn't work because of the return
Co-authored-by: Chris Chang <[email protected]>
This PR changes
TypeInfo::Union
andTypeInfo::Intersection
to both use a separate struct:TypeUnion
andTypeIntersection
. It also changes the structure of these types from being linked lists intoVec
s (usingPunctuated
). This also results in some new visitor methods:visit_type_union
,visit_type_union_end
,visit_type_intersection
, andvisit_type_intersection_end
.This PR also adds the ability to parse leading
|
and&
in types, such as:This involved adding a
leading
field to theTypeUnion
andTypeIntersection
structs, which contains an optionalTokenReference
.Tests were updated to accommodate the changes, and leading
|
and&
was added to thetypes
test.