macros/writer: relax syntax
This commit is contained in:
parent
4853c12054
commit
32394a4905
|
@ -811,11 +811,11 @@ impl Ins {
|
|||
{
|
||||
write_asm!(out, self => {
|
||||
(op.mnemonic, rc, oe) -> mnemonic;
|
||||
(d) -> fpr;
|
||||
(ps_d) -> offset_unsigned;
|
||||
(a) -> gpr;
|
||||
(w) -> mode;
|
||||
(ps_l) -> qr;
|
||||
d -> fpr;
|
||||
ps_d -> offset_unsigned;
|
||||
a -> gpr;
|
||||
w -> mode;
|
||||
ps_l -> qr;
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use syn::parse::{Parse, ParseStream};
|
|||
use syn::punctuated::Punctuated;
|
||||
use syn::spanned::Spanned;
|
||||
use syn::token::Semi;
|
||||
use syn::{Expr, Ident};
|
||||
use syn::{Expr, ExprPath, Ident};
|
||||
|
||||
struct Arguments {
|
||||
formatter: Expr,
|
||||
|
@ -33,16 +33,35 @@ impl Parse for Arguments {
|
|||
}
|
||||
}
|
||||
|
||||
/// A single part of an instruction.
|
||||
///
|
||||
/// Examples:
|
||||
/// ```ignore
|
||||
/// (op.mnemonic, rc, oe) -> mnemonic;
|
||||
/// d -> fpr;
|
||||
/// ```
|
||||
struct Argument {
|
||||
sources: Punctuated<Expr, syn::token::Comma>,
|
||||
sources: Vec<Expr>,
|
||||
target: Ident,
|
||||
}
|
||||
|
||||
impl Parse for Argument {
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let content;
|
||||
syn::parenthesized!(content in input);
|
||||
let sources = content.parse_terminated(Expr::parse)?;
|
||||
// Parse source part.
|
||||
let lookahead = input.lookahead1();
|
||||
let sources;
|
||||
if lookahead.peek(syn::token::Paren) {
|
||||
// Parse multiple if we found a parenthesis.
|
||||
let content;
|
||||
syn::parenthesized!(content in input);
|
||||
sources = content
|
||||
.parse_terminated::<Expr, syn::token::Comma>(Expr::parse)?
|
||||
.into_iter()
|
||||
.collect();
|
||||
} else {
|
||||
let expr = input.parse::<ExprPath>()?.into();
|
||||
sources = vec![expr];
|
||||
}
|
||||
input.parse::<syn::token::RArrow>()?;
|
||||
let target = input.parse()?;
|
||||
Ok(Self { sources, target })
|
||||
|
|
Loading…
Reference in New Issue