use crate::complex::prelude::*; use cflp::Parser; #[derive(Debug, Clone, Parser)] #[parser(Token<'a>, TokenType<'a>; ([@Statement<'a>])*)] pub struct Root<'a>(Vec>); #[derive(Debug, Clone, Parser)] #[parser(Token<'a>, TokenType<'a>)] pub enum Statement<'a> { #[parser(TokenType::Kwd(Kwd::If), TokenType::OP, [@Expr<'a>], TokenType::CP, TokenType::OB, ([@Statement<'a>])*, TokenType::CB)] Var1(Expr<'a>, Vec>), #[parser(TokenType::Kwd(Kwd::Let), [TokenType::Ident(t)], TokenType::Punc(Punc::Eq), [@Expr<'a>], TokenType::Punc(Punc::SCol))] Var2(&'a str, Expr<'a>), #[parser([TokenType::Ident(t)], TokenType::Punc(Punc::Eq), [@Expr<'a>], TokenType::Punc(Punc::SCol))] Var3(&'a str, Expr<'a>), } #[derive(Debug, Clone, Parser)] #[parser(Token<'a>, TokenType<'a>)] pub enum Expr<'a> { #[parser([TokenType::Ident(t)])] Var1(&'a str), #[parser([TokenType::Literal(t)])] Var2(u8), #[parser([[@Expr<'a>]], [TokenType::Punc(p)], [[@Expr<'a>]])] Var3(Box>, Punc, Box>), }