asm: Unify pseudo-keyword parsing using eat
, rather than a final expect
Currently, `asm!` parsing uses an `expect` for the last parsed pseudo-keyword (`sym`), which makes it difficult to extend without simultaneously refactoring. Use `eat` for the last pseudo-keyword, and then add an `else` that fails parsing. No change to error output.
This commit is contained in:
parent
4fb54ed484
commit
840176ab6f
1 changed files with 3 additions and 2 deletions
|
@ -135,8 +135,7 @@ fn parse_args<'a>(
|
||||||
} else if p.eat(&token::Ident(kw::Const, false)) {
|
} else if p.eat(&token::Ident(kw::Const, false)) {
|
||||||
let expr = p.parse_expr()?;
|
let expr = p.parse_expr()?;
|
||||||
ast::InlineAsmOperand::Const { expr }
|
ast::InlineAsmOperand::Const { expr }
|
||||||
} else {
|
} else if p.eat(&token::Ident(sym::sym, false)) {
|
||||||
p.expect(&token::Ident(sym::sym, false))?;
|
|
||||||
let expr = p.parse_expr()?;
|
let expr = p.parse_expr()?;
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ast::ExprKind::Path(..) => {}
|
ast::ExprKind::Path(..) => {}
|
||||||
|
@ -147,6 +146,8 @@ fn parse_args<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::InlineAsmOperand::Sym { expr }
|
ast::InlineAsmOperand::Sym { expr }
|
||||||
|
} else {
|
||||||
|
return Err(p.expect_one_of(&[], &[]).unwrap_err());
|
||||||
};
|
};
|
||||||
|
|
||||||
let span = span_start.to(p.prev_token.span);
|
let span = span_start.to(p.prev_token.span);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue