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 : Parser LogoExpr
parseVar = map Variable parseVarName parseVar = map Variable parseVarName
parseTerm : Parser LogoExpr
parseTerm = oneOf [ parseInt, parseVar ]
parseSum : Parser LogoExpr parseSum : Parser LogoExpr
parseSum = succeed Sum parseSum = succeed Sum
|= oneOf [ backtrackable parseVar, backtrackable parseInt ] |= parseTerm
|. spaces |. spaces
|. symbol "+" |. symbol "+"
|. spaces |. spaces
|= parseExpr |= parseExpr
parseExpr : Parser LogoExpr parseExpr : Parser LogoExpr
parseExpr = oneOf [ lazy (\_ -> backtrackable parseSum), backtrackable parseInt, backtrackable parseVar ] parseExpr = oneOf [ lazy (\_ -> backtrackable parseSum), parseTerm ]
parseProg : Parser LogoProg parseProg : Parser LogoProg
parseProg = sequence parseProg = sequence