Skip to content

Commit

Permalink
Refactor pass macro
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed Dec 4, 2023
1 parent db45fe9 commit 7410514
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion macro/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use syn::{
bracketed,
parse::{Parse, ParseStream},
punctuated::Punctuated,
Result, Token,
Lit, Result, Token,
};

pub struct IdentifierList {
Expand Down Expand Up @@ -56,3 +56,34 @@ impl Parse for DialectOperationSet {
})
}
}

pub struct PassSet {
prefix: Lit,
identifiers: IdentifierList,
}

impl PassSet {
pub const fn dialect(&self) -> &Ident {
&self.dialect
}

pub fn identifiers(&self) -> &[Ident] {
self.identifiers.identifiers()
}
}

impl Parse for PassSet {
fn parse(input: ParseStream) -> Result<Self> {
let dialect = Ident::parse(input)?;
<Token![,]>::parse(input)?;

Ok(Self {
dialect,
identifiers: {
let content;
bracketed!(content in input);
content.parse::<IdentifierList>()?
},
})
}
}

0 comments on commit 7410514

Please sign in to comment.