microcad_lang/parse/
identifier.rs1use crate::{parse::*, parser::*, syntax::*};
5use microcad_lang_base::Refer;
6use microcad_syntax::ast;
7
8impl FromAst for Identifier {
9 type AstNode = ast::Identifier;
10
11 fn from_ast(node: &Self::AstNode, context: &ParseContext) -> Result<Self, ParseError> {
12 Ok(Self(Refer::new(
13 node.name.clone(),
14 context.src_ref(&node.span),
15 )))
16 }
17}
18
19impl FromAst for QualifiedName {
20 type AstNode = ast::QualifiedName;
21
22 fn from_ast(node: &Self::AstNode, context: &ParseContext) -> Result<Self, ParseError> {
23 let parts = node
24 .parts
25 .iter()
26 .map(|ident| Identifier::from_ast(ident, context))
27 .collect::<Result<Vec<_>, _>>()?;
28 Ok(Self::new(parts, context.src_ref(&node.span)))
29 }
30}