Skip to content

Commit 66e004e

Browse files
committed
feat: migrate ml.zyn grammar to modern TypedAST action format for Grammar2
- Update program, import, module rules to use named bindings and direct TypedAST actions - Migrate function definitions (all 10 variants) to TypedDeclaration::Function - Update statements (let, if, while, for, return, break, continue, try/catch, match) to TypedStatement variants - Convert expressions to use passthrough actions (simplified for initial migration) - Update literals (int, float, string, bool) to TypedExpression variants - Add Module and Impl declaration support to GrammarInterpreter Note: This breaks LanguageGrammar compatibility (pest-based parser doesn't support named bindings). Grammar2.parse() now works for simple functions. Remaining rules (structs, traits, enums, impls) still use legacy JSON format and need migration.
1 parent e4f1283 commit 66e004e

2 files changed

Lines changed: 271 additions & 482 deletions

File tree

crates/zyn_peg/src/runtime2/interpreter.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,30 @@ impl<'g> GrammarInterpreter<'g> {
642642
span,
643643
})
644644
}
645+
"Module" => {
646+
let name = self.get_field_as_interned("name", fields, state)?;
647+
648+
TypedDeclaration::Module(zyntax_typed_ast::TypedModule {
649+
name,
650+
declarations: vec![],
651+
visibility: Visibility::Public,
652+
span,
653+
})
654+
}
655+
"Impl" => {
656+
let trait_name = self.get_field_as_interned("trait_name", fields, state)?;
657+
let for_type_name = self.get_field_as_interned("for_type", fields, state)?;
658+
let for_type = Type::Unresolved(for_type_name);
659+
660+
TypedDeclaration::Impl(zyntax_typed_ast::TypedTraitImpl {
661+
trait_name,
662+
trait_type_args: vec![],
663+
for_type,
664+
methods: vec![],
665+
associated_types: vec![],
666+
span,
667+
})
668+
}
645669
_ => return Err(format!("unknown TypedDeclaration variant: {}", variant)),
646670
};
647671

0 commit comments

Comments
 (0)