From 1b00b22f557efe20242ffce178773b14286b983d Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 2 Feb 2019 00:44:21 -0800 Subject: [PATCH] Adjust the parser a bit. --- src/Main.elm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Main.elm b/src/Main.elm index d02d9cf..4e05b5d 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -72,16 +72,19 @@ parseVarName = variable parseVar : Parser LogoExpr parseVar = map Variable parseVarName +parseTerm : Parser LogoExpr +parseTerm = oneOf [ parseInt, parseVar ] + parseSum : Parser LogoExpr parseSum = succeed Sum - |= oneOf [ backtrackable parseVar, backtrackable parseInt ] + |= parseTerm |. spaces |. symbol "+" |. spaces |= parseExpr parseExpr : Parser LogoExpr -parseExpr = oneOf [ lazy (\_ -> backtrackable parseSum), backtrackable parseInt, backtrackable parseVar ] +parseExpr = oneOf [ lazy (\_ -> backtrackable parseSum), parseTerm ] parseProg : Parser LogoProg parseProg = sequence