From 4f3966d8d806e13f0d77a2e3e1548670c59bc526 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 4 Jul 2026 09:38:13 +0200 Subject: [PATCH] Allman struct and enum field style --- crates/parser/src/grammar.pest | 6 +----- mist-test/src/items/attribute_test.mist | 2 +- mist-test/src/items/enum_test.mist | 19 ++++++++++++------- mist-test/src/items/impl_test.mist | 4 ++-- mist-test/src/items/struct_test.mist | 8 ++++---- mist-test/src/items/trait_test.mist | 2 +- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/crates/parser/src/grammar.pest b/crates/parser/src/grammar.pest index 147aa62..28e5187 100644 --- a/crates/parser/src/grammar.pest +++ b/crates/parser/src/grammar.pest @@ -289,12 +289,8 @@ enum_field = _{ | enum_named } -enum_fields = _{ - enum_field ~ ";" -} - enum_decl = { - visibility? ~ "enum" ~ identifier ~ generics_decl? ~ "{" ~ enum_fields? ~ "}" + visibility? ~ "enum" ~ identifier ~ generics_decl? ~ "{" ~ (enum_field ~ ";")* ~ "}" } // ====================================================== diff --git a/mist-test/src/items/attribute_test.mist b/mist-test/src/items/attribute_test.mist index eea1b62..d841170 100644 --- a/mist-test/src/items/attribute_test.mist +++ b/mist-test/src/items/attribute_test.mist @@ -4,7 +4,7 @@ pub module attribute_test; #[derive(Debug)] pub struct Debuggable { - i32 value, + i32 value; } pub void test_derive_attribute() diff --git a/mist-test/src/items/enum_test.mist b/mist-test/src/items/enum_test.mist index 0d3afff..b2fcef8 100644 --- a/mist-test/src/items/enum_test.mist +++ b/mist-test/src/items/enum_test.mist @@ -3,8 +3,8 @@ pub module enum_test; enum OptionInt { - None, - Some(i32), + None; + Some(i32); } pub void test_enum_named() @@ -35,8 +35,13 @@ pub void test_enum_tuple() enum Shape { - Circle {i32 radius}, - Rect {i32 w, i32 h}, + Circle { + i32 radius; + }; + Rect { + i32 w; + i32 h; + }; } pub void test_enum_struct() @@ -68,9 +73,9 @@ pub void test_enum_struct() enum Color { - Red, - Green, - Blue, + Red; + Green; + Blue; } pub void test_enum_eq() diff --git a/mist-test/src/items/impl_test.mist b/mist-test/src/items/impl_test.mist index 01e71f4..5dbd4be 100644 --- a/mist-test/src/items/impl_test.mist +++ b/mist-test/src/items/impl_test.mist @@ -3,8 +3,8 @@ pub module impl_test; struct Vector2 { - i32 x, - i32 y, + i32 x; + i32 y; } impl Vector2 diff --git a/mist-test/src/items/struct_test.mist b/mist-test/src/items/struct_test.mist index f6ef6c3..a7c73d5 100644 --- a/mist-test/src/items/struct_test.mist +++ b/mist-test/src/items/struct_test.mist @@ -3,8 +3,8 @@ pub module struct_test; struct Point { - i32 x, - i32 y, + i32 x; + i32 y; } pub void test_struct_create_access() @@ -40,8 +40,8 @@ pub void test_struct_destructure() struct Line { - Point start, - Point end, + Point start; + Point end; } pub void test_struct_nested() diff --git a/mist-test/src/items/trait_test.mist b/mist-test/src/items/trait_test.mist index 032b6a1..4fb4663 100644 --- a/mist-test/src/items/trait_test.mist +++ b/mist-test/src/items/trait_test.mist @@ -13,7 +13,7 @@ trait Greet : Speak struct Dog { - String name, + String name; } impl Speak for Dog