Refactor UntypedKind::Parameter to Identifier

The `Parameter` kind in `UntypedKind` was only used for identifiers that
were being declared or referenced. This commit renames it to
`Identifier` and updates all the necessary code to reflect this change.
This simplifies the AST and makes it more consistent.

Additionally, a new macro `repeat` has been added to
`src/ast/system.myc`.
This commit is contained in:
Michael Schimmel
2026-03-09 11:08:30 +01:00
parent cb4507b2da
commit fa23a4c125
12 changed files with 34 additions and 105 deletions
+4 -5
View File
@@ -381,7 +381,7 @@ impl Environment {
fn discover_globals(&self, node: &Node<UntypedKind>) {
match &node.kind {
UntypedKind::Def { target, .. } => {
if let UntypedKind::Parameter(sym) = &target.kind {
if let UntypedKind::Identifier(sym) = &target.kind {
let mut names = self.global_names.borrow_mut();
if !names.contains_key(sym) {
let idx = GlobalIdx(names.len() as u32);
@@ -391,12 +391,11 @@ impl Environment {
}
UntypedKind::MacroDecl { name, params, body } => {
let mut registry = self.macro_registry.borrow_mut();
fn extract_names(node: &Node<UntypedKind>) -> Vec<Rc<str>> {
match &node.kind {
UntypedKind::Parameter(sym) => vec![sym.name.clone()],
UntypedKind::Tuple { elements } => {
elements.iter().flat_map(extract_names).collect()
UntypedKind::Identifier(sym) => vec![sym.name.clone()],
UntypedKind::Tuple { elements } => { elements.iter().flat_map(extract_names).collect()
}
_ => vec![],
}