From cda3cefeb9b4b1950c5f9ab51bb1f21528a1c8a0 Mon Sep 17 00:00:00 2001 From: Yang Xiufeng Date: Thu, 26 Sep 2024 08:43:20 +0800 Subject: [PATCH] extract plain_ident. --- src/query/ast/src/parser/common.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/query/ast/src/parser/common.rs b/src/query/ast/src/parser/common.rs index 34876a9e67f0..6a19063e7516 100644 --- a/src/query/ast/src/parser/common.rs +++ b/src/query/ast/src/parser/common.rs @@ -88,6 +88,10 @@ pub fn ident(i: Input) -> IResult { non_reserved_identifier(|token| token.is_reserved_ident(false))(i) } +pub fn plain_ident(i: Input) -> IResult { + plain_identifier(|token| token.is_reserved_ident(false))(i) +} + pub fn ident_after_as(i: Input) -> IResult { non_reserved_identifier(|token| token.is_reserved_ident(true))(i) } @@ -97,13 +101,12 @@ pub fn function_name(i: Input) -> IResult { } pub fn stage_name(i: Input) -> IResult { - let named_stage = rule! { #plain_identifier(|token| token.is_reserved_ident(false)) }; let anonymous_stage = map(consumed(rule! { "~" }), |(span, _)| { Identifier::from_name(transform_span(span.tokens), "~") }); rule!( - #named_stage + #plain_ident | #anonymous_stage )(i) } @@ -291,10 +294,7 @@ pub fn column_id(i: Input) -> IResult { } pub fn variable_ident(i: Input) -> IResult { - map( - rule! { "$" ~ ^#plain_identifier(|token| token.is_reserved_ident(false)) }, - |(_, name)| name.name, - )(i) + map(rule! { "$" ~ ^#plain_ident }, |(_, name)| name.name)(i) } /// Parse one to two idents separated by a dot, fulfilling from the right. @@ -587,7 +587,7 @@ where F: nom::Parser, O, Error<'a>> { pub fn template_hole(i: Input) -> IResult { check_template_mode(map( rule! { - ":" ~ ^#plain_identifier(|token| token.is_reserved_ident(false)) + ":" ~ ^#plain_ident }, |(_, name)| name.name, ))(i)