Skip to content

Commit

Permalink
[New Lexer] dummy skip and retry recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
floatshadow committed Mar 2, 2024
1 parent babf313 commit 4beecce
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/frontend/new_lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ pub fn lexer<'a>() -> impl Parser<'a, &'a str, Vec<Spanned<Token<'a>>>, ParserEr

let comment = single_comment.or(multi_comment);

let recovery =
// filter current unknown token
none_of::<&str, &str, ParserError<'a, char>>(" \t\n\r").repeated();

// tokens
let token = choice((
keywords,
Expand All @@ -144,8 +140,7 @@ pub fn lexer<'a>() -> impl Parser<'a, &'a str, Vec<Spanned<Token<'a>>>, ParserEr
.map_with(| tok, extra| Spanned(tok, extra.span()))
.padded_by(comment.repeated())
.padded()
.recover_with(skip_then_retry_until(recovery.ignored(), end()))
.map(| tok | { println!("{:?}", tok); tok})
.recover_with(skip_then_retry_until(any().ignored(), end()))
.repeated()
.collect::<Vec<Spanned<Token<'a>>>>()
}

0 comments on commit 4beecce

Please sign in to comment.