Skip to content

Commit

Permalink
trivial cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
s-arash committed Jan 19, 2025
1 parent e67e322 commit 3d7330a
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions ascent_macro/src/ascent_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ use crate::utils::{
// example: https://gitlab.gnome.org/federico/gnome-class/-/blob/master/src/parser/mod.rs

mod kw {
use derive_syn_parse::Parse;
use syn::Token;

syn::custom_keyword!(relation);
syn::custom_keyword!(lattice);
syn::custom_punctuation!(LongLeftArrow, <--);
#[allow(dead_code)] // for unused fields of LongLeftArrow
#[derive(Parse)]
pub struct LongLeftArrow(Token![<], Token![-], Token![-]);
syn::custom_keyword!(agg);
syn::custom_keyword!(ident);
syn::custom_keyword!(expr);
Expand Down Expand Up @@ -451,16 +456,10 @@ impl Parse for RuleNode {
};

if input.peek(Token![;]) {
// println!("fact rule!!!");
input.parse::<Token![;]>()?;
Ok(RuleNode { head_clauses, body_items: vec![] /*Punctuated::default()*/ })
} else {
input.parse::<Token![<]>()?;
input.parse::<Token![-]>()?;
input.parse::<Token![-]>()?;
// NOTE this does not work with quote!
// input.parse::<kw::LongLeftArrow>()?;

input.parse::<kw::LongLeftArrow>()?;
let body_items = Punctuated::<BodyItemNode, Token![,]>::parse_separated_nonempty(input)?;
input.parse::<Token![;]>()?;
Ok(RuleNode { head_clauses, body_items: body_items.into_iter().collect() })
Expand Down Expand Up @@ -599,13 +598,10 @@ pub(crate) struct DsAttributeContents {

impl Parse for DsAttributeContents {
fn parse(input: ParseStream) -> Result<Self> {
let content = input;
// parenthesized!(content in input);

let path = syn::Path::parse_mod_style(&content)?;
let args = if content.peek(Token![:]) {
content.parse::<Token![:]>()?;
TokenStream::parse(&content)?
let path = syn::Path::parse_mod_style(&input)?;
let args = if input.peek(Token![:]) {
input.parse::<Token![:]>()?;
TokenStream::parse(&input)?
} else {
TokenStream::default()
};
Expand Down

0 comments on commit 3d7330a

Please sign in to comment.