Compare commits
2 Commits
f3d37076ee
...
d4303606df
Author | SHA1 | Date | |
---|---|---|---|
d4303606df | |||
d742cc9d88 |
|
@ -9,18 +9,17 @@
|
||||||
<div id="elm-container">
|
<div id="elm-container">
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var program = `
|
var program = `move(0, 0);
|
||||||
move(0, 0);
|
|
||||||
define line(x1, y1, x2, y2) {
|
define line(x1, y1, x2, y2) {
|
||||||
pen up;
|
pen up;
|
||||||
move(x1, y1);
|
move(x1, y1);
|
||||||
pen down;
|
pen down;
|
||||||
move(x2, y2);
|
move(x2, y2);
|
||||||
};
|
}
|
||||||
define nix(x, y, width, height) {
|
define nix(x, y, width, height) {
|
||||||
call line (x, y, x + width, y + height);
|
call line (x, y, x + width, y + height);
|
||||||
call line (x + width, y, x, y + height);
|
call line (x + width, y, x, y + height);
|
||||||
};
|
}
|
||||||
call nix(0, 0, 20, 20);
|
call nix(0, 0, 20, 20);
|
||||||
`
|
`
|
||||||
var container = document.getElementById("elm-container");
|
var container = document.getElementById("elm-container");
|
||||||
|
|
|
@ -90,7 +90,7 @@ parseExpr = oneOf [ lazy (\_ -> backtrackable parseSum), parseTerm ]
|
||||||
parseProg : Parser LogoProg
|
parseProg : Parser LogoProg
|
||||||
parseProg = sequence
|
parseProg = sequence
|
||||||
{ start = ""
|
{ start = ""
|
||||||
, separator = ";"
|
, separator = ""
|
||||||
, end = ""
|
, end = ""
|
||||||
, spaces = spaces
|
, spaces = spaces
|
||||||
, item = lazy (\_ -> parseCmd)
|
, item = lazy (\_ -> parseCmd)
|
||||||
|
@ -135,6 +135,8 @@ parseCall = succeed Call
|
||||||
, item = parseExpr
|
, item = parseExpr
|
||||||
, trailing = Forbidden
|
, trailing = Forbidden
|
||||||
}
|
}
|
||||||
|
|. spaces
|
||||||
|
|. symbol ";"
|
||||||
|
|
||||||
parsePenMode : Parser LogoPenMode
|
parsePenMode : Parser LogoPenMode
|
||||||
parsePenMode = oneOf
|
parsePenMode = oneOf
|
||||||
|
@ -147,6 +149,8 @@ parsePen = succeed Pen
|
||||||
|. keyword "pen"
|
|. keyword "pen"
|
||||||
|. spaces
|
|. spaces
|
||||||
|= parsePenMode
|
|= parsePenMode
|
||||||
|
|. spaces
|
||||||
|
|. symbol ";"
|
||||||
|
|
||||||
parseMove : Parser LogoCmd
|
parseMove : Parser LogoCmd
|
||||||
parseMove = succeed Move
|
parseMove = succeed Move
|
||||||
|
@ -158,7 +162,10 @@ parseMove = succeed Move
|
||||||
|. symbol ","
|
|. symbol ","
|
||||||
|. spaces
|
|. spaces
|
||||||
|= parseExpr
|
|= parseExpr
|
||||||
|
|. spaces
|
||||||
|. symbol ")"
|
|. symbol ")"
|
||||||
|
|. spaces
|
||||||
|
|. symbol ";"
|
||||||
|
|
||||||
{-
|
{-
|
||||||
======= Semantics Code =======
|
======= Semantics Code =======
|
||||||
|
|
Loading…
Reference in New Issue
Block a user