-
Notifications
You must be signed in to change notification settings - Fork 589
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
feat(parser): the 1st version of a new combinator style parser #16876
Conversation
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
parser_test and planner_test passed |
Can we have a better error display with this new parser framework? if it provides span in some way. 🤔 taken from #15091 |
It's possible, but must after we finish the whole refactor. |
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
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.
The attempt in this PR is truly exciting. The combinator style makes the code more readable and maintainable (although cut_err
could be a bit subtle 🤯). Looking forward to seeing the user-facing benefits (like better error reporting) after the refactoring.
|
||
delimited( | ||
Token::LParen, | ||
cut_err(literal_uint.try_map(move |v| { |
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.
Do we need cut_err
here, or shall we add cut_err
to all callers?
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.
float
is a valid data type, while float(
not. So we must cut
here.
let msg = if let Some(e) = e.into_inner() | ||
&& let Some(cause) = e.cause() | ||
{ | ||
format!(": {}", cause) | ||
} else { | ||
"".to_string() | ||
}; | ||
ParserError::ParserError(format!( | ||
"Unexpected {}{}", | ||
if self.index + token_stream.location() >= self.tokens.len() { | ||
&"EOF" as &dyn std::fmt::Display | ||
} else { | ||
&self.tokens[self.index + token_stream.location()] as &dyn std::fmt::Display | ||
}, | ||
msg | ||
)) |
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.
Can we use ParseError
here for better error reporting?
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.
Which ParserError
? If you mean v2, I'd prefer give user a consistent user experience now.
Signed-off-by: TennyZhuang <[email protected]>
Co-authored-by: Bugen Zhao <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Signed-off-by: TennyZhuang <[email protected]>
Why do you think the combinator is more maintainable? I think now everyone can work with the parser without learning, but not afterwards. |
Let's use Golang to rewrite RisingWave 😄 |
Signed-off-by: TennyZhuang <[email protected]>
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.
rubber stamp
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Introducing a new parser with winnow.
This is the first version of the new parser, with only the datatype parsing. However, it's also the most complicated part of our Parser. Due to our wrong design previously, we use
<
and>
to define struct type, then introduce a necessary stateangle_number
during parsing. Fortunately, the new framework handle it perfectly.winnow-rs is a parser-combinator crate, and it's forked by me for a simple patch winnow-rs/winnow#525.
The new framework can progressively replace the original parser, see
Parser::parse_v2
for detail.Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.