Skip to content

Commit

Permalink
refactor: fixed string tokenizer using somen v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
watcol committed Jun 26, 2022
1 parent 299e002 commit 77f8566
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions drake-lexer/src/literal/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@ where
I: Input<Ok = char> + 'a,
{
choice((
token('"')
.times(3)
.discard()
.fail()
.prefix(normal_string())
.map(|s| (s, StringKind::Normal)),
raw_string().map(|(s, n)| (s, StringKind::Raw(n))),
normal_string().map(|s| (s, StringKind::Normal)),
))
}

Expand All @@ -58,15 +53,12 @@ where
token('"')
.repeat(3..)
.count()
.spanned()
.then(|n| {
token('"')
.times(n)
.discard()
.fail()
.prefix(newline().or(any()))
newline()
.or(any())
.expect("raw character")
.repeat(..)
.skip(token('"').times(n).discard())
.until(token('"').times(n).discard().spanned())
.collect()
.map(move |s| (s, n as u8))
})
Expand Down

0 comments on commit 77f8566

Please sign in to comment.