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:
@@ -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![],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user