summaryrefslogtreecommitdiffstats
path: root/crates/rebel-parse
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-05-05 18:04:42 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-05-05 18:04:42 +0200
commit92b225a98de252c8f71e5823ba2c790fecd155b9 (patch)
tree603639e40de2fc21e367a6061addb04589bd7ba8 /crates/rebel-parse
parent9657feb70daa3bcb3cbd5438be61d61922e4647a (diff)
downloadrebel-92b225a98de252c8f71e5823ba2c790fecd155b9.tar
rebel-92b225a98de252c8f71e5823ba2c790fecd155b9.zip
rebel-parse, rebel-lang: allow specifying explicit map types
Diffstat (limited to 'crates/rebel-parse')
-rw-r--r--crates/rebel-parse/src/ast/typ.rs1
-rw-r--r--crates/rebel-parse/src/grammar/recipe.rs3
2 files changed, 4 insertions, 0 deletions
diff --git a/crates/rebel-parse/src/ast/typ.rs b/crates/rebel-parse/src/ast/typ.rs
index 939b67d..b193de2 100644
--- a/crates/rebel-parse/src/ast/typ.rs
+++ b/crates/rebel-parse/src/ast/typ.rs
@@ -12,6 +12,7 @@ pub enum Literal<'a> {
Unit,
Tuple(Vec<Type<'a>>),
Array(Box<Type<'a>>),
+ Map(Box<Type<'a>>, Box<Type<'a>>),
Struct(Vec<StructField<'a>>),
}
diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs
index ac3f90b..9ede9ff 100644
--- a/crates/rebel-parse/src/grammar/recipe.rs
+++ b/crates/rebel-parse/src/grammar/recipe.rs
@@ -75,6 +75,9 @@ peg::parser! {
/ p('[') typ:typ() p(']') {
typ::Literal::Array(Box::new(typ))
}
+ / [Token::Keyword(Keyword::Map)] p('{') key:typ() p2('=', '>') value:typ() p('}') {
+ typ::Literal::Map(Box::new(key), Box::new(value))
+ }
/ [Token::Keyword(Keyword::Struct)] p('{') entries:delimited(<struct_field_typ()>, <p(',')>) p('}') {
typ::Literal::Struct(entries)
}