Skip to content

Commit

Permalink
extract plain_ident.
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsofun committed Sep 26, 2024
1 parent b1debde commit cda3cef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/query/ast/src/parser/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ pub fn ident(i: Input) -> IResult<Identifier> {
non_reserved_identifier(|token| token.is_reserved_ident(false))(i)
}

pub fn plain_ident(i: Input) -> IResult<Identifier> {
plain_identifier(|token| token.is_reserved_ident(false))(i)
}

pub fn ident_after_as(i: Input) -> IResult<Identifier> {
non_reserved_identifier(|token| token.is_reserved_ident(true))(i)
}
Expand All @@ -97,13 +101,12 @@ pub fn function_name(i: Input) -> IResult<Identifier> {
}

pub fn stage_name(i: Input) -> IResult<Identifier> {
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)
}
Expand Down Expand Up @@ -291,10 +294,7 @@ pub fn column_id(i: Input) -> IResult<ColumnID> {
}

pub fn variable_ident(i: Input) -> IResult<String> {
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.
Expand Down Expand Up @@ -587,7 +587,7 @@ where F: nom::Parser<Input<'a>, O, Error<'a>> {
pub fn template_hole(i: Input) -> IResult<String> {
check_template_mode(map(
rule! {
":" ~ ^#plain_identifier(|token| token.is_reserved_ident(false))
":" ~ ^#plain_ident
},
|(_, name)| name.name,
))(i)
Expand Down

0 comments on commit cda3cef

Please sign in to comment.