-
Notifications
You must be signed in to change notification settings - Fork 592
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
refactor(parser): introduce a compactible layer for parser v2 to call v1 #17036
refactor(parser): introduce a compactible layer for parser v2 to call v1 #17036
Conversation
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.
👀 May I know the relationship versus #17019?
The PR is based on that. #17019 replace the underlying input stream of parser v2 from The PR introduce a compatible trait, to allow Based on the PR, we can refactor the recursive terms step by step. E.g., we create a fake v2 |
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.
Rest LGTM!
pub fn expr_case<S>(input: &mut S) -> PResult<Expr> | ||
where | ||
S: TokenStream, | ||
{ | ||
let parse = ( | ||
opt(expr), |
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.
In terms of semantics, this function should start parsing from CASE
and the caller should not consume CASE
before calling it.
pub fn expr_case<S>(input: &mut S) -> PResult<Expr> | |
where | |
S: TokenStream, | |
{ | |
let parse = ( | |
opt(expr), | |
pub fn expr_case<S>(input: &mut S) -> PResult<Expr> | |
where | |
S: TokenStream, | |
{ | |
let parse = ( | |
Keyword::CASE, | |
opt(expr), |
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.
Unfortunately we have to following the v1's behavior.
Another problem is dispatch!
is much more efficient than alt
, even in v2, using the style can achieve best performance.
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 only thing I can do is rename it to expr_case_suffix
or expr_case_rest
, but seems too verbose.
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.
Okay let's correct this later.
dispatch!
can also be used with peek(keyword)
which doesn't consume the token. 😄
a86c6ac
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
ParseV1
as a compatible trait for parser v2expr_case
as an exampleChecklist
./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.