Fix parsing

This commit is contained in:
Danila Fedorin 2019-02-03 22:36:06 -08:00
parent 05ce812ff1
commit d742cc9d88
2 changed files with 11 additions and 5 deletions

View File

@ -9,18 +9,17 @@
<div id="elm-container">
</div>
<script>
var program = `
move(0, 0);
var program = `move(0, 0);
define line(x1, y1, x2, y2) {
pen up;
move(x1, y1);
pen down;
move(x2, y2);
};
}
define nix(x, y, width, height) {
call line (x, y, x + width, y + height);
call line (x + width, y, x, y + height);
};
}
call nix(0, 0, 20, 20);
`
var container = document.getElementById("elm-container");

View File

@ -90,7 +90,7 @@ parseExpr = oneOf [ lazy (\_ -> backtrackable parseSum), parseTerm ]
parseProg : Parser LogoProg
parseProg = sequence
{ start = ""
, separator = ";"
, separator = ""
, end = ""
, spaces = spaces
, item = lazy (\_ -> parseCmd)
@ -135,6 +135,8 @@ parseCall = succeed Call
, item = parseExpr
, trailing = Forbidden
}
|. spaces
|. symbol ";"
parsePenMode : Parser LogoPenMode
parsePenMode = oneOf
@ -147,6 +149,8 @@ parsePen = succeed Pen
|. keyword "pen"
|. spaces
|= parsePenMode
|. spaces
|. symbol ";"
parseMove : Parser LogoCmd
parseMove = succeed Move
@ -158,7 +162,10 @@ parseMove = succeed Move
|. symbol ","
|. spaces
|= parseExpr
|. spaces
|. symbol ")"
|. spaces
|. symbol ";"
{-
======= Semantics Code =======