Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
andylokandy committed May 14, 2022
1 parent 20271a8 commit 340e214
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions common/ast/src/parser/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ fn non_reserved_identifier(
),
move |i| {
match_token(QuotedString)(i).and_then(|(i2, token)| {
if token.kind == QuotedString && !token.text().starts_with('\'') {
if token.text().starts_with('\'') {
Err(nom::Err::Error(Error::from_error_kind(
i,
ErrorKind::ExpectToken(Ident),
)))
} else {
Ok((i2, Identifier {
span: token.clone(),
name: token.text()[1..token.text().len() - 1].to_string(),
quote: Some(token.text().chars().next().unwrap()),
}))
} else {
Err(nom::Err::Error(Error::from_error_kind(
i,
ErrorKind::ExpectToken(Ident),
)))
}
})
},
Expand All @@ -131,13 +131,13 @@ fn non_reserved_keyword(

pub fn literal_string(i: Input) -> IResult<String> {
match_token(QuotedString)(i).and_then(|(i2, token)| {
if token.kind == QuotedString && !token.text().starts_with('`') {
Ok((i2, token.text()[1..token.text().len() - 1].to_string()))
} else {
if token.text().starts_with('`') {
Err(nom::Err::Error(Error::from_error_kind(
i,
ErrorKind::ExpectToken(QuotedString),
)))
} else {
Ok((i2, token.text()[1..token.text().len() - 1].to_string()))
}
})
}
Expand Down

0 comments on commit 340e214

Please sign in to comment.