syn_solidity/yul/stmt/
block.rs1use crate::{Spanned, YulStmt};
2use proc_macro2::Span;
3use std::fmt;
4use syn::{
5 braced,
6 parse::{Parse, ParseStream},
7 token::Brace,
8 Result,
9};
10
11#[derive(Clone)]
16pub struct YulBlock {
17 pub brace_token: Brace,
18 pub stmts: Vec<YulStmt>,
19}
20
21impl Parse for YulBlock {
22 fn parse(input: ParseStream<'_>) -> Result<Self> {
23 let content;
24 Ok(Self {
25 brace_token: braced!(content in input),
26 stmts: {
27 let mut stmts = Vec::new();
28 while !content.is_empty() {
29 let stmt: YulStmt = content.parse()?;
30 stmts.push(stmt);
31 }
32 stmts
33 },
34 })
35 }
36}
37
38impl Spanned for YulBlock {
39 fn span(&self) -> Span {
40 self.brace_token.span.join()
41 }
42
43 fn set_span(&mut self, span: Span) {
44 self.brace_token = Brace(span);
45 }
46}
47
48impl fmt::Debug for YulBlock {
49 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50 f.debug_struct("YulBlock").field("stmt", &self.stmts).finish()
51 }
52}