valkyrie-parser 0.2.5

The hand write parser of valkyrie language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::*;

impl TupleNode {
    #[allow(clippy::wrong_self_convention)]
    pub fn as_table(self) -> TupleNode {
        TupleNode { kind: TupleKind::Tuple, terms: self.terms, span: self.span }
    }
}

impl ThisParser for TupleNode {
    /// `(` ~ `)` | `(` ~ term ~ , ~ `)` | `(` ~ term ~ , ~ term ( ~ , ~ term)* ~ `)`
    fn parse(input: ParseState) -> ParseResult<Self> {
        let pat = BracketPattern::new("(", ")").with_one_tailing(true);
        let (state, terms) = pat.consume(input, ignore, TupleTermNode::parse)?;
        state.finish(TupleNode { terms: terms.body, span: get_span(input, state) })
    }
}