Struct init grammar

This commit is contained in:
2026-04-23 19:04:01 +02:00
parent 02c40d7f90
commit 488b985992
2 changed files with 16 additions and 10 deletions
+3
View File
@@ -105,15 +105,18 @@ primary = {
postfix = { postfix = {
field_px field_px
| call_px | call_px
| struct_px
| index_px | index_px
| binary_px | binary_px
} }
field_px = { "." ~ identifier } field_px = { "." ~ identifier }
call_px = { "(" ~ (expr ~ ("," ~ expr)*)? ~ ")" } call_px = { "(" ~ (expr ~ ("," ~ expr)*)? ~ ")" }
struct_px = { "{" ~ (struct_field_decl ~ ("," ~ struct_field_decl)*)? ~ "}" }
index_px = { "[" ~ expr ~ "]" } index_px = { "[" ~ expr ~ "]" }
binary_px = { bin_op ~ expr } binary_px = { bin_op ~ expr }
bin_op = { "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" } bin_op = { "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" }
struct_field_decl = { identifier ~ ":" ~ expr }
expr = { expr = {
primary ~ postfix* primary ~ postfix*
+3
View File
@@ -105,15 +105,18 @@ primary = {
postfix = { postfix = {
field_px field_px
| call_px | call_px
| struct_px
| index_px | index_px
| binary_px | binary_px
} }
field_px = { "." ~ identifier } field_px = { "." ~ identifier }
call_px = { "(" ~ (expr ~ ("," ~ expr)*)? ~ ")" } call_px = { "(" ~ (expr ~ ("," ~ expr)*)? ~ ")" }
struct_px = { "{" ~ (struct_field_decl ~ ("," ~ struct_field_decl)*)? ~ "}" }
index_px = { "[" ~ expr ~ "]" } index_px = { "[" ~ expr ~ "]" }
binary_px = { bin_op ~ expr } binary_px = { bin_op ~ expr }
bin_op = { "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" } bin_op = { "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" }
struct_field_decl = { identifier ~ ":" ~ expr }
expr = { expr = {
primary ~ postfix* primary ~ postfix*