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