Attribute grammar

This commit is contained in:
2026-05-05 02:18:52 +02:00
parent 7fe7fddea5
commit 7b6638d274
+12 -1
View File
@@ -19,7 +19,18 @@ var_decl = { type_expr ~ mutable? ~ identifier }
// ================= TOP LEVEL =================
top_level = _{ import | function_decl | struct_decl }
attribute_list = { sharp ~ "[" ~ attribute ~ ("," ~ attribute)* ~ "]" }
attribute = { static_path ~ attribute_args? }
attribute_args = { "(" ~ (attr_expr ~ ("," ~ attr_expr)*)? ~ ")" }
attr_expr = {
(identifier ~ "=" ~ primary)
| primary
}
top_level = _{ attribute_list* ~ (import | function_decl | struct_decl) }
import = { sharp ~ "include" ~ "<" ~ static_path ~ ">" }