Skip to content

Commit

Permalink
Fix incorrect comment parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Jun 27, 2024
1 parent 8e3b1a4 commit 4825ef5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions asm/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ fn instr<'a>(
let comment = comment();

let args = instr_arg(stmt)
.padded_by(comment.clone().repeated())
.separated_by(just(',').padded().recover_with(skip_then_retry_until(
any().ignored(),
choice((just(',').ignored(), text::newline())),
)))
.separated_by(
just(',')
.padded_by(comment.clone().repeated())
.padded()
.recover_with(skip_then_retry_until(
any().ignored(),
choice((just(',').ignored(), text::newline())),
)),
)
.collect::<Vec<_>>();

instr_ident()
Expand Down Expand Up @@ -148,7 +152,7 @@ fn instr_arg<'a>(

fn comment<'a>() -> impl Parser<'a, &'a str, (), extra::Err<ParserError>> + Clone {
just("//")
.then(any().and_is(just('\n').not()).repeated())
.then(any().and_is(text::newline().not()).repeated())
.padded()
.ignored()
}
Expand Down

0 comments on commit 4825ef5

Please sign in to comment.