microcad_lang/syntax/expression/
marker.rs1use microcad_lang_base::{SrcRef, SrcReferrer, TreeDisplay, TreeState};
7
8use crate::syntax::*;
9
10#[derive(Clone)]
12pub struct Marker {
13 pub(crate) id: Identifier,
15 pub src_ref: SrcRef,
17}
18
19impl Marker {
20 pub fn is_input_placeholder(&self) -> bool {
22 &self.id == "input"
23 }
24}
25
26impl Identifiable for Marker {
27 fn id_ref(&self) -> &Identifier {
28 &self.id
29 }
30}
31
32impl SrcReferrer for Marker {
33 fn src_ref(&self) -> SrcRef {
34 self.src_ref.clone()
35 }
36}
37
38impl std::fmt::Display for Marker {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 write!(f, "@{}", self.id)
41 }
42}
43
44impl std::fmt::Debug for Marker {
45 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 write!(f, "@{:?}", self.id)
47 }
48}
49
50impl TreeDisplay for Marker {
51 fn tree_print(&self, f: &mut std::fmt::Formatter, depth: TreeState) -> std::fmt::Result {
52 writeln!(f, "{:depth$}Marker '{}'", "", self.id)
53 }
54}