microcad_lang/parse/
identifier.rs1use crate::{parse::*, parser::*, src_ref::*, syntax::*};
5
6impl Parse for IdentifierList {
7 fn parse(pair: Pair) -> ParseResult<Self> {
8 let mut vec = Vec::new();
9 for pair in pair.inner() {
10 if pair.as_rule() == Rule::identifier {
11 vec.push(Identifier::parse(pair)?);
12 }
13 }
14 Ok(Self(Refer::new(vec, pair.into())))
15 }
16}
17
18impl Parse for Identifier {
19 fn parse(pair: Pair) -> ParseResult<Self> {
20 Parser::ensure_rule(&pair, Rule::identifier);
21 Ok(Self(Refer::new(pair.as_str().into(), pair.into())))
22 }
23}
24
25impl Parse for QualifiedName {
26 fn parse(pair: Pair) -> ParseResult<Self> {
27 Ok(Self::new(
28 pair.inner()
29 .map(|pair| Identifier::parse(pair).expect("Expected identifier"))
30 .collect(),
31 pair.into(),
32 ))
33 }
34}