New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type system, totality checking, abstract data types, and pattern matching. #20

Merged
merged 99 commits into from Jun 21, 2018
Commits
Jump to file or symbol
Failed to load files and symbols.
+29,304 −4,464
Diff settings

Always

Just for now

View
@@ -1,6 +1,5 @@
main
grainc
grain.install
*.install
output/*.o
output/*.run
output/*.s
@@ -17,10 +16,13 @@ notes.org
**/node_modules/**/*
*.wasm
*.wasm.wast
*.wasm.modsig
.tern-port
setup.data
setup.ml
myocamlbuild.ml
.merlin
runtime/dist
script/public/javascripts/grain-runtime.js
script/public/javascripts/grain-runtime-browser.js
/*.gr
View
@@ -1,20 +1,20 @@
JBUILDER := $(shell command -v jbuilder &> /dev/null)
JBUILDER := $(shell command -v jbuilder 2> /dev/null)
default: check-libs
jbuilder build
ifndef JBUILDER
$(error "jbuilder not found on your PATH. Please install jbuilder before building: opam install jbuilder")
endif
default: check-libs
jbuilder build
tests:
jbuilder runtest
install:
jbuilder install
check-libs:
jbuilder external-lib-deps --missing @install
./tools/get-deps.sh
clean:
jbuilder clean
View
@@ -0,0 +1,11 @@
const { execSync } = require('child_process');
module.exports = (file) => {
try {
execSync(`grainc -I _build/install/default/lib/grain/stdlib ${file}`);
return file.replace(/\.gr$/, '.wasm')
} catch (e) {
console.log(e.stdout.toString());
process.exit(-1);
}
}
View
@@ -0,0 +1,31 @@
#!node --harmony
let program = require('commander');
let compile = require('./compile.js');
let run = require('./run.js');
let file;
program
.version('Grain compiler 0.0.0\nGrain cli 0.0.0', '-v, --version')
.arguments('<file>')
.action((givenFile) => {
file = givenFile || '';
});
program.on('--help', () => {
console.log('\n\n File can be either a Grain (.gr) or WebAssembly (.wasm) file.\n');
});
program.parse(process.argv);
let wasmFile;
if (file.endsWith('gr')) {
wasmFile = compile(file);
} else if (file.endsWith('wasm')) {
wasmFile = file;
} else {
program.help();
}
run(wasmFile);
View
@@ -0,0 +1,8 @@
let runtime = require('../../runtime/dist/grain-runtime.js');
let locator = runtime.defaultFileLocator('_build/install/default/lib/grain/stdlib');
let GrainRunner = runtime.buildGrainRunner(locator);
module.exports = async function run(path) {
let res = await GrainRunner.runFile(path);
//console.log(`result: ${res}`);
}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,29 @@
{
"name": "@grain/cli",
"version": "0.0.0",
"description": "A command line tool for the Grain language.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"grain": "bin/grain.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/grain-lang/grain.git"
},
"keywords": [
"grain",
"cli"
],
"author": "Oscar Spencer",
"license": "MIT",
"bugs": {
"url": "https://github.com/grain-lang/grain/issues"
},
"homepage": "https://github.com/grain-lang/grain#readme",
"dependencies": {
"commander": "^2.14.1"
}
}
View
@@ -0,0 +1,3 @@
(lang dune 0.1)
(name grain)
(version 0.0.1)
View
@@ -12,14 +12,23 @@ build: [
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"ocamlfind" {build}
"ocamlbuild" {build}
"jbuilder" {build}
"ounit"
"extlib"
"batteries"
"cmdliner"
"ocamlgraph"
"wasm"
"stdint"
"ocamlfind" {build & >= "1.7.3" }
"ocamlbuild" {build & >= "0.12.0" }
"jbuilder" {build & >= "1.0+beta20" }
"ppx_deriving"
"ppx_sexp_conv"
"sexplib"
"dypgen"
"ounit" { >= "2.0.0" }
"extlib" { >= "1.7.2" }
"batteries" { >= "2.8.0" }
"cmdliner" { >= "1.0.2" }
"ocamlgraph" {>= "1.8.8" }
"wasm" { = "1.0" }
"stdint" { >= "0.5.0" }
"grain_utils"
"grain_parsing"
"grain_typed"
"grain_middle_end"
"grain_codegen"
]
View
@@ -0,0 +1,31 @@
opam-version: "1.2"
maintainer: "philip@pblair.org"
authors: ["Philip Blair" "Oscar Spencer"]
license: "MIT"
homepage: "https://github.com/grain-lang/grain"
dev-repo: "git+https://github.com/grain-lang/grain.git"
bug-reports: "https://github.com/grain-lang/grain/issues"
doc: "Experimental language targeting WebAssembly"
build: [
[ "jbuilder" "subst" ] {pinned}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"ocamlfind" {build & >= "1.7.3" }
"ocamlbuild" {build & >= "0.12.0" }
"jbuilder" {build & >= "1.0+beta20" }
"ppx_deriving"
"ppx_sexp_conv"
"sexplib"
"dypgen"
"ounit" { >= "2.0.0" }
"extlib" { >= "1.7.2" }
"batteries" { >= "2.8.0" }
"cmdliner" { >= "1.0.2" }
"ocamlgraph" {>= "1.8.8" }
"wasm" { = "1.0" }
"stdint" { >= "0.5.0" }
"grain_utils"
"grain_middle_end"
]
View
@@ -0,0 +1,32 @@
opam-version: "1.2"
maintainer: "philip@pblair.org"
authors: ["Philip Blair" "Oscar Spencer"]
license: "MIT"
homepage: "https://github.com/grain-lang/grain"
dev-repo: "git+https://github.com/grain-lang/grain.git"
bug-reports: "https://github.com/grain-lang/grain/issues"
doc: "Experimental language targeting WebAssembly"
build: [
[ "jbuilder" "subst" ] {pinned}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"ocamlfind" {build & >= "1.7.3" }
"ocamlbuild" {build & >= "0.12.0" }
"jbuilder" {build & >= "1.0+beta20" }
"ppx_deriving"
"ppx_sexp_conv"
"sexplib"
"dypgen"
"ounit" { >= "2.0.0" }
"extlib" { >= "1.7.2" }
"batteries" { >= "2.8.0" }
"cmdliner" { >= "1.0.2" }
"ocamlgraph" {>= "1.8.8" }
"wasm" { = "1.0" }
"stdint" { >= "0.5.0" }
"grain_utils"
"grain_parsing"
"grain_typed"
]
View
@@ -0,0 +1,30 @@
opam-version: "1.2"
maintainer: "philip@pblair.org"
authors: ["Philip Blair" "Oscar Spencer"]
license: "MIT"
homepage: "https://github.com/grain-lang/grain"
dev-repo: "git+https://github.com/grain-lang/grain.git"
bug-reports: "https://github.com/grain-lang/grain/issues"
doc: "Experimental language targeting WebAssembly"
build: [
[ "jbuilder" "subst" ] {pinned}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"ocamlfind" {build & >= "1.7.3" }
"ocamlbuild" {build & >= "0.12.0" }
"jbuilder" {build & >= "1.0+beta20" }
"ppx_deriving"
"ppx_sexp_conv"
"sexplib"
"dypgen"
"ounit" { >= "2.0.0" }
"extlib" { >= "1.7.2" }
"batteries" { >= "2.8.0" }
"cmdliner" { >= "1.0.2" }
"ocamlgraph" {>= "1.8.8" }
"wasm" { = "1.0" }
"stdint" { >= "0.5.0" }
"grain_utils"
]
View
@@ -0,0 +1,31 @@
opam-version: "1.2"
maintainer: "philip@pblair.org"
authors: ["Philip Blair" "Oscar Spencer"]
license: "MIT"
homepage: "https://github.com/grain-lang/grain"
dev-repo: "git+https://github.com/grain-lang/grain.git"
bug-reports: "https://github.com/grain-lang/grain/issues"
doc: "Experimental language targeting WebAssembly"
build: [
[ "jbuilder" "subst" ] {pinned}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"ocamlfind" {build & >= "1.7.3" }
"ocamlbuild" {build & >= "0.12.0" }
"jbuilder" {build & >= "1.0+beta20" }
"ppx_deriving"
"ppx_sexp_conv"
"sexplib"
"dypgen"
"ounit" { >= "2.0.0" }
"extlib" { >= "1.7.2" }
"batteries" { >= "2.8.0" }
"cmdliner" { >= "1.0.2" }
"ocamlgraph" {>= "1.8.8" }
"wasm" { = "1.0" }
"stdint" { >= "0.5.0" }
"grain_utils"
"grain_parsing"
]
View
@@ -0,0 +1,29 @@
opam-version: "1.2"
maintainer: "philip@pblair.org"
authors: ["Philip Blair" "Oscar Spencer"]
license: "MIT"
homepage: "https://github.com/grain-lang/grain"
dev-repo: "git+https://github.com/grain-lang/grain.git"
bug-reports: "https://github.com/grain-lang/grain/issues"
doc: "Experimental language targeting WebAssembly"
build: [
[ "jbuilder" "subst" ] {pinned}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"ocamlfind" {build & >= "1.7.3" }
"ocamlbuild" {build & >= "0.12.0" }
"jbuilder" {build & >= "1.0+beta20" }
"ppx_deriving"
"ppx_sexp_conv"
"sexplib"
"dypgen"
"ounit" { >= "2.0.0" }
"extlib" { >= "1.7.2" }
"batteries" { >= "2.8.0" }
"cmdliner" { >= "1.0.2" }
"ocamlgraph" {>= "1.8.8" }
"wasm" { = "1.0" }
"stdint" { >= "0.5.0" }
]
View
@@ -0,0 +1,30 @@
opam-version: "1.2"
maintainer: "philip@pblair.org"
authors: ["Philip Blair" "Oscar Spencer"]
license: "MIT"
homepage: "https://github.com/grain-lang/grain"
dev-repo: "git+https://github.com/grain-lang/grain.git"
bug-reports: "https://github.com/grain-lang/grain/issues"
doc: "Experimental language targeting WebAssembly"
build: [
[ "jbuilder" "subst" ] {pinned}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"ocamlfind" {build & >= "1.7.3" }
"ocamlbuild" {build & >= "0.12.0" }
"jbuilder" {build & >= "1.0+beta20" }
"ppx_deriving"
"ppx_sexp_conv"
"sexplib"
"dypgen"
"ounit" { >= "2.0.0" }
"extlib" { >= "1.7.2" }
"batteries" { >= "2.8.0" }
"cmdliner" { >= "1.0.2" }
"ocamlgraph" {>= "1.8.8" }
"wasm" { = "1.0" }
"stdint" { >= "0.5.0" }
"grain"
]
Oops, something went wrong.