Adjust the parser a bit.

This commit is contained in:
Danila Fedorin 2019-02-02 00:44:21 -08:00
parent 55edae65cb
commit 1b00b22f55

View File

@ -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