keens / webml Goto Github PK
View Code? Open in Web Editor NEWA Standard ML Compiler for the Web
License: MIT License
A Standard ML Compiler for the Web
License: MIT License
ml!(let val x = 1 in x end)
=> Expr::{ ty: (),inner: ExprKind::Let { ... }}
open problem: how to embed Rust values?
nom is hard to handle parse error
this needs #21
Thougn WASM doesn't have function local stack-like storage, you can make it by allocating some space on the heap. This encourages for garbage collection to scan function local values.
related to #3. writing GC requires pointer apis as well as intrinsics
each pass may have error and warnings.
Gather symbol table and ID generator to call it compiler context.
It requires to calculate position in parser
it should accept 1 statement
Allocate JSValue buffer (assoc array) in JS and refer it via index(pointer).
pass indices of JSValue (direct passing of i32, f32, f64 will be future work)
JS Value <-> ML record via JSON?
document "what this module (pass) do", "what is precondition, invariant, postcondition" for each items.
primitive != prelude. See #14
say, _import "module" "function" (args)
.
Aims to replace print
with this feature for now
val x = inc 1
fun inc x = x + 1
Perform some easy reductions to simplify intermediate representations. It helps debugging.
(fn x => body) arg
-> let val x = arg in body end
let val y = x ... in ... end
-> x -> y
let val (var1, ..., varn) = (expr1, .., exprn) in arm end
-> let val var1 = expr1 ... val varn = exprn in arm end
let val Constructor pat = Constructor arg => arm
-> let val pat = arg in arm end
case expr of pattern => arm
-> let val pattern = expr in arm end
currently we have only AST, HIR, MIR, LIR. However, AST have non typed phase and typed phase, and HIR has renamed (alpha converted) phase, flat_expr (K Normal) phase, flat_let (A Normal) phase.
Each phases should have its own representations
implement generic Traverse
trait and use it
Write GC
easy to implement closure calls, ops
At present, each captured variables are passed via argument, but it's hard to to compile so let it receive a pointer to the captured variables
transparent webassembly api will be usefull
ast2hir fails to resolve types.
it may require μ operator, or symbol table in hir.
decl ; decl
)(expr; expr)
let
(let ... in expr; ...; expr end
)possible envrironments:
desugared to val it = expr
Idea:
separate function-like, closure and function in type.
Then type driven closure conversion
val f: function-like = if xx then g: function else h: closure
↓
val f: closure = if xx then force-closure(g): closure else h: closure
,
val f: function-like = if xx then g: function else h: function
↓
val f: function = if xx then g: closure else h: function
need to settle the direction of implementation.
void *
stylevoid *
style is flexible, but may be buggy.
correct: 0.7
3.32E5
3E~7
incorrect: 23
.3
4.E5
1E2.5
recursive functions cannot be inferred
Current symbol is pub struct Symbol(pub String);
. It is sufficient for representing AST, but after HIR, as they are renamed (alpha converted), they should contain versions too like pub struct Symbol(pub String, pub u64);
For debugging, testing and more.
lucet would be a good runtime.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.