Merge pull request #97 from mist-go/tidy-grammar

VC: Tidy up the grammar/parser #94
This commit is contained in:
2026-06-28 07:31:26 +02:00
committed by GitHub
5 changed files with 3 additions and 20 deletions
-5
View File
@@ -256,11 +256,6 @@ impl GenRust for Postfix {
Postfix::Try => cg.add("?"), Postfix::Try => cg.add("?"),
Postfix::Assign(cmp, expr) => {
cg.add(" ");
cg.add(cmp);
expr.gen_rust(ctx, cg);
}
Postfix::Increment => cg.add("+=1"), Postfix::Increment => cg.add("+=1"),
Postfix::Decrement => cg.add("-=1"), Postfix::Decrement => cg.add("-=1"),
} }
-6
View File
@@ -164,12 +164,6 @@ impl GenMist for Postfix {
cg.add(&ty.get_mist()); cg.add(&ty.get_mist());
} }
Postfix::Try => cg.add("?"), Postfix::Try => cg.add("?"),
Postfix::Assign(cmp, expr) => {
cg.add(" ");
cg.add(cmp);
cg.add(" ");
expr.gen_mist(ctx, cg);
}
Postfix::Increment => cg.add("++"), Postfix::Increment => cg.add("++"),
Postfix::Decrement => cg.add("--"), Postfix::Decrement => cg.add("--"),
} }
-1
View File
@@ -62,7 +62,6 @@ pub enum Postfix {
delimiter: MacroDelimiter, delimiter: MacroDelimiter,
}, },
StructCall(Vec<(Identifier, Option<Expression>)>), StructCall(Vec<(Identifier, Option<Expression>)>),
Assign(String, Box<Expression>),
Index(Expression), Index(Expression),
As(TypeExpr), As(TypeExpr),
Increment, Increment,
+3 -2
View File
@@ -12,6 +12,7 @@ COMMENT = _{ "//" ~ (!"\n" ~ ANY)* }
keyword = { keyword = {
"if" "if"
| "else" | "else"
| "fn"
| "for" | "for"
| "while" | "while"
| "match" | "match"
@@ -163,7 +164,7 @@ literal = {
etc_pattern = { ".." } etc_pattern = { ".." }
multi_pat_template = _{ multi_pat_template = _{
((pattern | etc_pattern) ~ ("," ~ (pattern | etc_pattern))*)? ((pattern | etc_pattern) ~ ("," ~ (pattern | etc_pattern))* ~ ","?)?
} }
tuple_pattern = { tuple_pattern = {
@@ -290,7 +291,7 @@ enum_fields = _{
} }
enum_decl = { enum_decl = {
visibility? ~ "enum" ~ identifier ~ generics_decl? ~ "{" ~ enum_fields ~ "}" visibility? ~ "enum" ~ identifier ~ generics_decl? ~ "{" ~ enum_fields? ~ "}"
} }
// ====================================================== // ======================================================
-6
View File
@@ -317,12 +317,6 @@ impl GetMutability for Expression {
// Recurse into all postfix sub-expressions // Recurse into all postfix sub-expressions
for postfix in postfixes { for postfix in postfixes {
match postfix { match postfix {
Postfix::Assign(_, rhs) => {
if let Some(self_ref) = get_self_ref(initial, postfixes) {
result.push(self_ref);
}
result.append(&mut rhs.get_mutability());
}
Postfix::Call(args) => { Postfix::Call(args) => {
for arg in args { for arg in args {
result.append(&mut arg.get_mutability()); result.append(&mut arg.get_mutability());