Updated grammar and AST

This commit is contained in:
2026-05-05 14:30:24 +02:00
parent 1d00667b18
commit ce7dc2b9ba
3 changed files with 19 additions and 57 deletions
+2 -33
View File
@@ -128,42 +128,11 @@ impl From<pest::iterators::Pair<'_, Rule>> for Attribute {
}
let mut inner = pair.into_inner();
// Every style starts with an identifier (the path)
let path = StaticPath::from(inner.next().expect("Path identifier expected"));
let path = StaticPath::from(inner.next().unwrap());
let kind = match rule {
Rule::simple_style => MetaItemKind::Word,
Rule::key_value_style | Rule::pair => {
let lit = Literal::from(inner.next().unwrap());
MetaItemKind::NameValue(lit)
}
Rule::list_style => {
// derive(Debug, Clone) -> NestedMetaItem::MetaItem(Attribute { path: "Debug", kind: Word })
let items = inner
.map(|p| {
NestedMetaItem::MetaItem(Attribute {
path: StaticPath::from(p),
kind: MetaItemKind::Word,
})
})
.collect();
MetaItemKind::List(items)
}
Rule::structured_style => {
// link(name = "readline") -> NestedMetaItem::MetaItem(Attribute { path: "name", kind: NameValue(...) })
let items = inner
.map(|p| NestedMetaItem::MetaItem(Attribute::from(p)))
.collect();
MetaItemKind::List(items)
}
_ => unreachable!("Unexpected rule: {:?}", rule),
_ => unimplemented!("{:?}", rule),
};
Attribute { path, kind }
}
}