The expression graph

Status: implemented

The compiler's intermediate form is declared as a schema: edag is its grammar, and edag/value its evaluated values. The compiler's output is checked against the grammar, and nanvm checks its operator cases against edag's op1Id and op3Id with validate.

Every tuple in the grammar is closed, and that is load-bearing: the grammar claims each JavaScript chain has exactly one spelling, and an open tuple would let a node carry a trailing element nothing reads (structs and tuples are closed). edag/value/metadata checks an evaluated value's metadata with rtti's error helpers after edag/value's shape check, and declares no schema of its own.

Examples

The demo on this page offers two schemas: the unary operators, a union of strings, and an evaluated value, which is recursive. They are defined in sample.f.mjs, and the module page's demo lists them among all the others.

Where it is implemented

The modules linked above.

Demo

The unary operators of the expression graph, as a union of strings. The VM's operator cases check membership with validate, the one project use that keeps the value.

import { op1Id } from 'functionalscript/fjs/edag/module.f.mjs'
or"String""Number""BigInt""!""~""typeof""throw"

TypeScript:

"!"|"BigInt"|"Number"|"String"|"throw"|"typeof"|"~"

JSON Schema:

{"anyOf":[{"const":"!"},{"const":"BigInt"},{"const":"Number"},{"const":"String"},{"const":"throw"},{"const":"typeof"},{"const":"~"}]}
Canonical form (toData)
export default [{},{"string":["!","BigInt","Number","String","throw","typeof","~"]}];

parse · ok

export default "typeof";

validate · ok

export default "typeof";

Emergent Testing

Idle. Press Run to start the suite.

  • ./proof.f.mjs