summaryrefslogtreecommitdiffstats
path: root/crates/rebel-parse
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-05-05 20:57:34 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-05-05 21:42:40 +0200
commit6718f07f55b742c66b1ab0ed2d8e32d05b2a6f22 (patch)
tree56bcec8afd482ce9ce30f354469afe01916e4d55 /crates/rebel-parse
parent29ad178117be9f7e3a659c860aafe21525d906dd (diff)
downloadrebel-6718f07f55b742c66b1ab0ed2d8e32d05b2a6f22.tar
rebel-6718f07f55b742c66b1ab0ed2d8e32d05b2a6f22.zip
rebel-parse, rebel-lang: remove struct keyword again
In addition, the order of match rules is adjusted to check structs before blocks for improved performance in common cases - structs are likely more frequent than block expressions in most code, and the struct rule can be rejected quickly.
Diffstat (limited to 'crates/rebel-parse')
-rw-r--r--crates/rebel-parse/src/grammar/recipe.rs6
-rw-r--r--crates/rebel-parse/src/grammar/tokenize.rs1
-rw-r--r--crates/rebel-parse/src/token.rs1
3 files changed, 3 insertions, 5 deletions
diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs
index 96ef61d..1c417d3 100644
--- a/crates/rebel-parse/src/grammar/recipe.rs
+++ b/crates/rebel-parse/src/grammar/recipe.rs
@@ -78,7 +78,7 @@ peg::parser! {
/ [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('}') {
+ / p('{') entries:delimited(<struct_field_typ()>, <p(',')>) p('}') {
typ::Literal::Struct(entries)
}
@@ -147,8 +147,8 @@ peg::parser! {
{
Expr::IfElse { if_blocks, else_block }
}
- / p('{') block:block() p('}') { Expr::Block(block) }
/ lit:literal() { Expr::Literal(lit) }
+ / p('{') block:block() p('}') { Expr::Block(block) }
/ path:path() { Expr::Path(path) }
rule cond_block() -> (Expr<'a>, ast::Block<'a>)
@@ -184,7 +184,7 @@ peg::parser! {
/ [Token::Keyword(Keyword::Map)] p('{') entries:delimited(<map_entry()>, <p(',')>) p('}') {
expr::Literal::Map(entries)
}
- / [Token::Keyword(Keyword::Struct)] p('{') entries:delimited(<struct_field()>, <p(',')>) p('}') {
+ / p('{') entries:delimited(<struct_field()>, <p(',')>) p('}') {
expr::Literal::Struct(entries)
}
diff --git a/crates/rebel-parse/src/grammar/tokenize.rs b/crates/rebel-parse/src/grammar/tokenize.rs
index a4e25b5..551f157 100644
--- a/crates/rebel-parse/src/grammar/tokenize.rs
+++ b/crates/rebel-parse/src/grammar/tokenize.rs
@@ -13,7 +13,6 @@ static KEYWORDS: phf::Map<&'static str, Keyword> = phf::phf_map! {
"mut" => Keyword::Mut,
"recipe" => Keyword::Recipe,
"set" => Keyword::Set,
- "struct" => Keyword::Struct,
"task" => Keyword::Task,
"true" => Keyword::True,
};
diff --git a/crates/rebel-parse/src/token.rs b/crates/rebel-parse/src/token.rs
index 59582c3..c86d13e 100644
--- a/crates/rebel-parse/src/token.rs
+++ b/crates/rebel-parse/src/token.rs
@@ -19,7 +19,6 @@ pub enum Keyword {
Mut,
Recipe,
Set,
- Struct,
Task,
True,
}