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
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
104e125
Initial work on fleshing out type system
belph ab5a5fa
Initial work on fleshing out type system
belph 8e0b90e
Type checking working except for tuples.
ospencer ee98d9a
Merge branch 'types' of github.com:grain-lang/grain into types
ospencer fe00a37
Types mostly working
ospencer 8914f65
Initial work on adding ADTs.
belph 53223f5
50/50 this'll fix the makefile
belph dd936d7
Migrate to Dypgen-based GLR parser
belph e0424ed
More work on ADTs. In theory, they should ANF to a sensible (but very…
belph b8fb16b
Add workspace file (to make sure build environment is consistent)
belph f2d994e
Update .gitignore to ignore scratch programs written in project root
belph 6882de1
Started work on migrating frontend to a new location
belph ad104a6
Parser compiles again
belph 22505c4
Add basic match syntax
belph fd0f16c
Operator precedence
belph c247ef2
Add position-using wrapper to parser
belph 2987ed9
Add basic well-formedness checks
belph 62521be
Initial work on typed AST
belph 5d8b8e2
Add previously-omitted Asttypes module
belph 7cabd06
Fix typedtree definition
belph 545f334
Almost to a point where we can start translating to the typed AST
belph 5a8e748
More work on getting the typed AST up in running (not too far off now!).
belph ac8455b
On the home stretch with the typed module
belph e1a1c36
Typed module now compiles. Things still on the to-do list:
belph c1dae21
'make' builds again
belph 370cb51
Tests run again. They all fail, but they run.
belph e76fd6e
More tests passing (though still a ways to go)
belph a2dc9bc
More kinks worked out, but there are still lingering parser issues
belph 7dd27e7
Fix app_expr and binop_expr parsing
belph c857335
Updated more tests
belph 79e2cd5
normalize_types_rec was ported incorrectly
belph 7f87897
Uncomment typetexp errors
belph eb57659
More bugfixes
belph 82f3792
Add support for showing parse tree in debugging output
belph 69c085b
Argument typing and more test fixes
belph d5a1134
Add typed AST to debugging output
belph 75d9722
Clean up parsing interface and lexer errors. Additionally, fix enviro…
belph 2a2c2aa
Fix applications
belph 71ca5ba
Wire up future slots for or patterns and aliases (this also enables t…
belph a064e2c
More work on (temporarily) wiring up modules and data types
belph ad91be9
Update test to use proper root
belph ec2fe21
Fix gitignore and grainc GRAIN_ROOT resolution
belph 901d4cb
Many updates; aside from some bugfixes, the totality checker has been…
belph ddbfa06
Save progress
belph db83863
Add grain cli tool
ospencer f197fe8
First pass at match almost working
belph ddccdde
First attempt at match compilation is working
belph 967946a
Remove obsolete tuple tests
belph c42c7ca
More things are passing. There appears to still be some issue with ma…
belph ff6eef3
Add new IR between ANF and codegen which handles allocations and lamb…
belph 5905128
Remove a bunch of stale code
belph 805e682
First pass at separate compilation (codegen has yet to be implemented…
belph aa559b6
More prep work for separate compilation and FFI
belph 683a2b0
Fix `let' parsing
belph d8929db
Add .mli for Grain_parsing.Driver
belph 2c36512
Automatically install missing dependencies, plus add version constraints
belph 1056435
More work on separate compilation
belph 31bb4d2
Foreign imports work, and separate compilation is coming together
belph 46bbcec
More passing tests
belph 6ed7f50
Reenable stdlib tests and disable optimization/mutation tests
belph e311196
Correct short-circuiting, plus fix stdlib modules' pointers being clo…
belph 55b8621
Fix final failing test (modulo TODOs)
belph 46faba5
Merge branch 'glr-parser' of github.com:grain-lang/grain into add-gra…
ospencer 48477bf
tweak cli
ospencer 5e14ed4
Use optimized Webassembly.instantiateStreaming
ospencer c25a515
Fix Node WASM module instantiation
belph d4cf6e3
Prefix Grain modules in WASM-land
belph 028691b
Dual runtimes for browser and commonjs.
ospencer 0e89c49
Update scripts to point to new runtime.
ospencer 45bbf09
Don't commit compiled assets.
ospencer 9c04941
Update JS runtime to latest Grain module format
belph c98fdf8
Support application/wasm
ospencer 14c7784
Update JS runtime to latest Grain module format
belph 696a22f
Merge branch 'add-grain-cmdline-tool' of github.com:grain-lang/grain …
ospencer 4c68410
Fix the node runtime.
ospencer 7e4fa89
Merge branch 'add-grain-cmdline-tool' of github.com:grain-lang/grain …
ospencer 60f7388
Merge pull request #16 from grain-lang/add-grain-cmdline-tool
belph 449f2c4
Fix pervasives typing
ospencer a528c85
Ignore the browser runtime.
ospencer eb3cff9
Refactor the runtime to be a little more clear. Fixed running in a br…
ospencer a461ac5
Update locator comment
ospencer 20b96d9
Merge pull request #17 from grain-lang/fix-browser-runtime
ospencer daa7b2d
Fix runtime for node.
ospencer 2e81adf
Force type variables to be uppercase
ospencer f4474a9
Require parens around match argument
ospencer 6200e6a
Fix comparisons
ospencer 0f6989e
Bump jbuilder dependency
belph aa8c510
Fixed type printing
ospencer 7298fac
Update lists stdlib to use new data types syntax.
ospencer 5548ccd
Update test files to conform to the new datatypes syntax.
ospencer 334b4a0
Update grammar to only allow variant constructors with capitalized na…
ospencer a798077
Update tests to use new syntax for type variants.
ospencer ba62617
Removed unused tokens from the parser.
ospencer e1d41bf
Fix type annotations
ospencer 2b1c93f
Merge pull request #19 from grain-lang/update-data-types-grammar
ospencer 6ebe97b
Use Batteries instead of Extlib, since Extlib breaks on macOS
ospencer 79883af
Make tests run on macOS
ospencer a6249af
Fix Makefile for macOS
ospencer bbba293
Merge branch 'master' of github.com:grain-lang/grain into glr-parser
ospencer
Jump to file or symbol
Failed to load files and symbols.
Diff settings
| @@ -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); | ||
| } | ||
| } |
| @@ -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); |
| @@ -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}`); | ||
| } |
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
| @@ -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" | ||
| } | ||
| } |
| @@ -0,0 +1,3 @@ | ||
| (lang dune 0.1) | ||
| (name grain) | ||
| (version 0.0.1) |
29
grain.opam
| @@ -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" | ||
| ] |
| @@ -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" | ||
| ] |
| @@ -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" | ||
| ] |
| @@ -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" | ||
| ] |
| @@ -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" } | ||
| ] |
30
grainc.opam
| @@ -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.