microcad_lang/syntax/statement/
expression_statement.rs1use crate::{src_ref::*, syntax::*};
7
8#[derive(Debug, Clone)]
10pub struct ExpressionStatement {
11 pub attribute_list: AttributeList,
13 pub expression: Expression,
15 pub src_ref: SrcRef,
17}
18
19impl SrcReferrer for ExpressionStatement {
20 fn src_ref(&self) -> SrcRef {
21 self.src_ref.clone()
22 }
23}
24
25impl TreeDisplay for ExpressionStatement {
26 fn tree_print(&self, f: &mut std::fmt::Formatter, depth: TreeState) -> std::fmt::Result {
27 self.expression.tree_print(f, depth)
28 }
29}
30
31impl std::fmt::Display for ExpressionStatement {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 if !self.attribute_list.is_empty() {
34 write!(f, "{} ", self.attribute_list)?;
35 }
36 write!(f, "{};", self.expression)
37 }
38}