Adjust the parser a bit.
This commit is contained in:
parent
55edae65cb
commit
1b00b22f55
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user