This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Parser (toplevel, parse, previewError) where | |
import Control.Applicative | |
import Control.Monad (guard) | |
import Data.List (intercalate) | |
import Text.Parsec.Error | |
import Text.Parsec.Pos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<pre id="canvas"> | |
<font caption="inconsolata"> | |
Press 'space' to start. | |
'WASD' to move. | |
</font> | |
</pre> | |
<script type="text/javascript" src="./frp.js"></script> | |
<script type="text/javascript" src="./game.js"></script> | |
<script type="text/javascript" src="./logic.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Dict exposing (Dict) | |
import Graphics.Collage as Collage exposing (Form) | |
import Graphics.Element as Element exposing (Element) | |
import Keyboard | |
import Signal | |
import Time | |
import String | |
import Text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is a Lazy Abstract Machine (LAM). | |
This code is meant to be glued before output of the compilator | |
(or `let {Node, func, call, etc...} = require('runtime.js')`) | |
- it depends on how will I implement a compiler. | |
It allows representing lazy programs for the lazy language with: | |
1) Push { elem: 1, to: Empty } - Algebraic datatypes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert') | |
/* | |
LAM - Lazy Abstract Machine. | |
It evaluates the tree built from AST descendants lazily. | |
No optimization is performed (and minded - it should be done in compile-phase). | |
Call `run(ast)` to reduce it to Weak-Head Normal Form (go google it). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load(File, SExp) | |
:- read_file_to_string(File, Text, []) | |
, string_chars(Text, Atoms) | |
, phrase(entry(SExp), Atoms, []) | |
, ! | |
. | |
entry(Res) --> spaces, many(sexp, Res). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Iter = Iter | |
{ pos, col, line :: Int | |
} | |
data SExp = Block [SExp] | Atom String | |
deriving Show | |
parseSexp text = | |
let |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var { Parser: P } = require("./parser-combinators.js") | |
var t = (s) => P.string(s).and_(spaces) | |
var nameChar = P.oneOf("qwertyuiopasdfghjklzxcvbnm1234567890-=+~:<>.,?/\\*#$%^!@|&{}[]") | |
var nameChar1 = P.oneOf("qwertyuiopasdfghjklzxcvbnm-=+~:<>.,?/\\*#$%^!@|&{}[]") | |
var comment = P.string(";")._and(P.anyChar().butNot(P.string("\n")).many())._and(P.string("\n")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set :: string -> (char -> bool) | |
var set = (items) => { | |
var arr = Array.prototype.slice.apply(items) | |
var carrier = {} | |
arr.forEach(x => { carrier[x] = true }) | |
return (x) => carrier[x] | |
} | |
var reserved = set("module object end => let in \\ open ---".split(" ")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 111.11 | |
// 'hello '' world' | |
class Parser { | |
static of(parser) { | |
return new Parser(parser) | |
} | |
constructor(runParser) { | |
this.runParser = runParser |