microcad_lang/parse/
workbench.rs1use crate::{parse::*, parser::*, rc::*, syntax::*};
5
6impl Parse for Refer<WorkbenchKind> {
7 fn parse(pair: Pair) -> ParseResult<Self> {
8 match pair.as_str() {
9 "part" => Ok(Refer::new(WorkbenchKind::Part, pair.into())),
10 "sketch" => Ok(Refer::new(WorkbenchKind::Sketch, pair.into())),
11 "op" => Ok(Refer::new(WorkbenchKind::Operation, pair.into())),
12 _ => Err(ParseError::UnexpectedToken(pair.into())),
13 }
14 }
15}
16
17impl Parse for Rc<WorkbenchDefinition> {
18 fn parse(pair: Pair) -> ParseResult<Self> {
19 Ok(WorkbenchDefinition {
20 doc: crate::find_rule_opt!(pair, doc_block),
21 visibility: crate::find_rule!(pair, visibility)?,
22 attribute_list: crate::find_rule!(pair, attribute_list)?,
23 kind: crate::find_rule_exact!(pair, workbench_kind)?,
24 id: crate::find_rule!(pair, identifier)?,
25 plan: crate::find_rule!(pair, parameter_list)?,
26 body: crate::find_rule!(pair, body)?,
27 }
28 .into())
29 }
30}