conlang: Import items into scope with use!
grammar: - Improve specification of `Path` - Add `Use` and `UseTree` rules - Add `Use` as a variant of ItemKind cl-token: - Add new keywords `use` and `as` cl-ast: - Add nodes for Use and UseTree - Add new ItemKind for Use - Implement traversal in Visit and Fold cl-interpret: - Mark ItemKind::Use with a todo cl-parser: - Update to match grammar cl-typeck: - Update to match changes in AST - Mark UseTrees as NameCollectable and TypeResolvable, but leave as todos
This commit is contained in:
@@ -207,6 +207,7 @@ pub mod yamlify {
|
||||
ItemKind::Struct(f) => y.yaml(f),
|
||||
ItemKind::Enum(f) => y.yaml(f),
|
||||
ItemKind::Impl(f) => y.yaml(f),
|
||||
ItemKind::Use(f) => y.yaml(f),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -322,6 +323,22 @@ pub mod yamlify {
|
||||
};
|
||||
}
|
||||
}
|
||||
impl Yamlify for Use {
|
||||
fn yaml(&self, y: &mut Yamler) {
|
||||
let Self { tree } = self;
|
||||
y.key("Use").yaml(tree);
|
||||
}
|
||||
}
|
||||
impl Yamlify for UseTree {
|
||||
fn yaml(&self, y: &mut Yamler) {
|
||||
match self {
|
||||
UseTree::Tree(path, tree) => y.pair("path", path).pair("tree", tree),
|
||||
UseTree::Alias(path, name) => y.pair("path", path).pair("name", name),
|
||||
UseTree::Path(path) => y.pair("path", path),
|
||||
UseTree::Glob => y.value("Glob"),
|
||||
};
|
||||
}
|
||||
}
|
||||
impl Yamlify for Block {
|
||||
fn yaml(&self, y: &mut Yamler) {
|
||||
let Self { stmts } = self;
|
||||
|
||||
Reference in New Issue
Block a user