syn_solidity/yul/ident/
path.rs

1use crate::{Spanned, YulIdent};
2use proc_macro2::Span;
3use std::fmt;
4use syn::{
5    parse::{Parse, ParseStream},
6    punctuated::Punctuated,
7    Result, Token,
8};
9
10/// In inline assembly, only dot-less identifiers can be declared, but dotted
11/// paths can reference declarations made outside the assembly block.
12///
13/// Solidity Reference:
14/// <https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.yulPath>
15#[derive(Clone)]
16pub struct YulPath(Punctuated<YulIdent, Token![.]>);
17
18impl Parse for YulPath {
19    fn parse(input: ParseStream<'_>) -> Result<Self> {
20        Ok(Self(Punctuated::parse_separated_nonempty(input)?))
21    }
22}
23
24impl Spanned for YulPath {
25    fn span(&self) -> Span {
26        self.0.span()
27    }
28
29    fn set_span(&mut self, span: Span) {
30        self.0.set_span(span);
31    }
32}
33
34impl fmt::Debug for YulPath {
35    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36        f.debug_tuple("YulPath").field(&self.0).finish()
37    }
38}