JavaScript

fjs/js holds JavaScript's own facts, each written once: which words are keywords, what an identifier is, how a string is escaped, which built-in functions and prototype members exist, and how JavaScript text is cut into tokens. They cover the part of JavaScript the repository reads and writes, not all of it: identifier admits ASCII names only, and the tokenizer does not read every string escape, such as \x41. FunctionalScript is a subset of JavaScript, so every part of the repository that reads, checks or writes JavaScript asks these modules instead of keeping its own copy. A list kept in two places drifts, and then the compiler and the RTTI printer disagree about whether enum is a keyword.

None of this is the FunctionalScript language itself. The rules of the subset live in fjs/compiler and the language reference in spec; this directory is the JavaScript those are a subset of.

How text becomes a program

JavaScript text
  --tokenizer-->            JsToken stream                 (js/tokenizer)
  --compiler/tokenizer-->   the compiler's tokens          (compiler)
  --compiler/parser-->      a resolved source module       (compiler)
  --js/ast/sugar-->         Foundation AST                 (js/ast)
  --edag/from_fast-->       the expression graph           (edag)

The first and fourth stages are here, and compiler/edag runs the last two. The token stream is shared: the compiler folds it once more into its own tokens, and marked reads it as it is to find the runs the website colours source text by.

The modules

ModuleHoldsUsed by
tokenizertokenize: text to a stream of JsTokens, or the first lexical errorcompiler, website demos
markedspansOf: the runs of JavaScript or TypeScript text, and disagreementwebsite, compiler and media/json proofs
keywordsthe reserved words, literal words and reserved globals, and isKeywordcompiler, ebnf, rtti, website
identifierisIdentifier and its start and part classescompiler, rtti, emergent_testing, text/marked
string_escapethe escape sequences, and stringLiteral, the one writer of a quoted stringcompiler, media/json, types/ts, ci
array_indexarrayIndex: whether a property key names an array elementrtti, edag
prototypethe own property names of the seven built-in prototypescompiler, edag, nanvm
staticthe static functions a module may call, such as Object.iscompiler, edag, nanvm
membersthe member functions of the built-in types, as one tablenone yet; executors will be generated from it
intrinsicthe primitives no function body can define: slice, charCodeAtcompiler, edag
runtimethe built-in functions, defined once for every executorcompiler, edag, nanvm, effects/node
astthe Foundation AST, the compiler's intermediate representationcompiler, edag, nanvm, rust

Emergent Testing

Idle. Press Run to start the suite.

  • ./array_index/proof.f.mjs
  • ./ast/control/proof.f.mjs
  • ./ast/invocation/proof.f.mjs
  • ./ast/invocation/tail/proof.f.mjs
  • ./ast/loop/invariant/proof.f.mjs
  • ./ast/loop/plain/proof.f.mjs
  • ./ast/loop/proof.f.mjs
  • ./ast/loop/terminal/proof.f.mjs
  • ./ast/memo/cells/proof.f.mjs
  • ./ast/memo/proof.f.mjs
  • ./ast/memo/self_alias_loops.proof.f.mjs
  • ./ast/memo/tail.proof.f.mjs
  • ./ast/prepare/joins/proof.f.mjs
  • ./ast/prepare/one_pass/proof.f.mjs
  • ./ast/prepare/proof.f.mjs
  • ./ast/prepare/source_results.proof.f.mjs
  • ./ast/prepare/terminal_loops.proof.f.mjs
  • ./ast/proof.f.mjs
  • ./ast/results/proof.f.mjs
  • ./ast/returns/integration/proof.f.mjs
  • ./ast/returns/proof.f.mjs
  • ./ast/serializer/intrinsic/proof.f.mjs
  • ./ast/serializer/member_present/proof.f.mjs
  • ./ast/serializer/primitive_captures.proof.f.mjs
  • ./ast/serializer/proof.f.mjs
  • ./ast/sugar/compound_blocks.proof.f.mjs
  • ./ast/sugar/effects/proof.f.mjs
  • ./ast/sugar/invocation_assignments.proof.f.mjs
  • ./ast/sugar/logical/proof.f.mjs
  • ./ast/sugar/pattern/proof.f.mjs
  • ./ast/sugar/proof.f.mjs
  • ./ast/task/proof.f.mjs
  • ./identifier/proof.f.mjs
  • ./intrinsic/proof.f.mjs
  • ./keywords/proof.f.mjs
  • ./marked/proof.f.mjs
  • ./members/proof.f.mjs
  • ./prototype/proof.f.mjs
  • ./runtime/proof.f.mjs
  • ./static/proof.f.mjs
  • ./string_escape/proof.f.mjs
  • ./tokenizer/proof.f.mjs