refactoring the grammar

This commit is contained in:
2026-05-05 14:12:49 +02:00
parent f4a14789c3
commit 1d00667b18
2 changed files with 17 additions and 12 deletions
+5 -8
View File
@@ -20,22 +20,19 @@ var_decl = { type_expr ~ mutable? ~ identifier }
// ================= TOP LEVEL =================
attribute = {
"#" ~ "[" ~ (structured_style | list_style | key_value_style | simple_style) ~ "]"
"#" ~ "[" ~ (structured_style | list_style | pair_attr | simple_style) ~ "]"
}
// Simple: #[test]
simple_style = { identifier }
// Key-Value: #[crate_type = "lib"]
key_value_style = { identifier ~ "=" ~ primary }
simple_style = { static_path }
// #[derive(PartialEq, PartialOrd)]
list_style = { identifier ~ "(" ~ identifier ~ ("," ~ identifier)* ~ ","? ~ ")" }
list_style = { static_path ~ "(" ~ identifier ~ ("," ~ identifier)* ~ ","? ~ ")" }
// #[link(name = "readline")]
structured_style = { identifier ~ "(" ~ pair ~ ("," ~ pair)* ~ ","? ~ ")" }
structured_style = { static_path ~ "(" ~ pair_attr ~ ("," ~ pair_attr)* ~ ","? ~ ")" }
pair = { identifier ~ "=" ~ primary }
pair_attr = { identifier ~ "=" ~ primary }
top_level = { attribute* ~ (import | function_decl | struct_decl) }