summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-05-05 20:24:06 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-05-05 21:42:10 +0200
commit1f0894a45be2ba1bd2d17fef771cf41ecf46309d (patch)
tree7b0a028cb15bbd71523383b19213b23b216dd68d
parent7fc1c7fee52bce6ca5c59069a4a66bdb99e24998 (diff)
downloadrebel-1f0894a45be2ba1bd2d17fef771cf41ecf46309d.tar
rebel-1f0894a45be2ba1bd2d17fef771cf41ecf46309d.zip
rebel-parse, rebel-lang: switch to use ':' for fields in struct literals
Match Rust and make struct literals and block expressions easily distinguishable even without a struct keyword.
-rw-r--r--crates/rebel-lang/src/value.rs2
-rw-r--r--crates/rebel-parse/src/grammar/recipe.rs2
-rw-r--r--examples/recipes/gmp/build.recipe2
3 files changed, 3 insertions, 3 deletions
diff --git a/crates/rebel-lang/src/value.rs b/crates/rebel-lang/src/value.rs
index 8434dff..3e364ed 100644
--- a/crates/rebel-lang/src/value.rs
+++ b/crates/rebel-lang/src/value.rs
@@ -590,7 +590,7 @@ impl Display for Value {
f.write_str(", ")?;
}
first = false;
- write!(f, "{key} = {value}")?;
+ write!(f, "{key}: {value}")?;
}
f.write_str("}")
}
diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs
index 9ede9ff..85a6d8d 100644
--- a/crates/rebel-parse/src/grammar/recipe.rs
+++ b/crates/rebel-parse/src/grammar/recipe.rs
@@ -194,7 +194,7 @@ peg::parser! {
}
rule struct_field() -> expr::StructField<'a>
- = field:field() p('=') value:expr() {
+ = field:field() p(':') value:expr() {
expr::StructField { name: field.name, value }
}
diff --git a/examples/recipes/gmp/build.recipe b/examples/recipes/gmp/build.recipe
index c63fddd..9a1ae45 100644
--- a/examples/recipes/gmp/build.recipe
+++ b/examples/recipes/gmp/build.recipe
@@ -55,7 +55,7 @@ task install(host: Platform) {
task.parent = compile(host);
task.output["default"] = struct {
- runtime_depends = [host_depend(toolchain::depends)],
+ runtime_depends: [host_depend(toolchain::depends)],
};
```