From 13413702ed8673fb60367c422996b6fe7caf2d88 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 18 Nov 2022 14:11:50 +0100 Subject: [PATCH] Parse basic expressions --- src/parser.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 567d7b5..3fd16f6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -194,7 +194,15 @@ fn table_constr( }) } -pub fn parser() -> impl Parser { - let expr = recursive(|expr| lit(expr).map(Expr::Lit)); - table_constr(expr).padded().then_ignore(end()) +fn expr( + expr: impl Parser + Clone, +) -> impl Parser { + let lit = lit(expr.clone()).map(Expr::Lit); + let table_constr = table_constr(expr.clone()).map(Expr::TableConstr); + + lit.or(table_constr) +} + +pub fn parser() -> impl Parser { + recursive(expr).padded().then_ignore(end()) }