diff --git a/parser/src/grammar.pest b/parser/src/grammar.pest index f2da105..49a3421 100644 --- a/parser/src/grammar.pest +++ b/parser/src/grammar.pest @@ -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 ~ ">" }