Enum grammar

This commit is contained in:
2026-05-07 20:59:15 +02:00
parent a9fdfe4100
commit 5eeaf8c35d
2 changed files with 17 additions and 1 deletions
+11 -1
View File
@@ -37,7 +37,17 @@ class_decl = {
// ================= TOP LEVEL =================
top_level = { (attributes ~ (import | function_decl | struct_decl | class_decl | mod_package)) | mod_attribute }
enum_named = { identifier }
enum_tuple = { identifier ~ tuple_type }
enum_struct = { identifier ~ "{" ~ field_list ~ "}" }
enum_field = _{ enum_tuple | enum_struct | enum_named }
enum_fields = _{ enum_field ~ ("," ~ enum_field)* ~ ","? }
enum_decl = { export? ~ "enum" ~ identifier ~ "{" ~ enum_fields ~ "}" }
top_level = { (attributes ~ (import | function_decl | struct_decl | enum_decl | class_decl | mod_package)) | mod_attribute }
attribute = {
"#" ~ "[" ~ meta ~ "]"