Repository navigation
Command line
As of v1.0.0
The reader is one executable, typify. The examples on this page call it typify. In an unpacked release it is typify/bin/typify, or typify/bin/typify.exe on Windows; see Install.
typify check DECLARATIONS
typify check DECLARATIONS --bounds
typify check DECLARATIONS LANGUAGE PROGRAM [--facts FILE]
typify tree DECLARATIONS ROOT [--facts FILE]
typify plan DECLARATIONS ROOT [--facts FILE]
typify plan DECLARATIONS LANGUAGE PROGRAM [--facts FILE]
typify facts ROOT
typify ask DECLARATIONS LANGUAGE WORD
typify emit DECLARATIONS LANGUAGE
typify emit DECLARATIONS LANGUAGE --gbnf
typify emit Typify
typify --versionSquare brackets mark a flag that may be left out. An operand may follow --, so that ask can be given a declared word spelled like an option. A declaration reads a fact when it holds a guard line, a reads line, or a fact call inside (if ...) in a rule. tree needs facts for a guard or a reads line only, and plan for all three. tree and plan over a root read the facts they need from --facts FILE, or without it run the facts collector themselves. The one-program forms of check and plan take --facts FILE as well, but check never reads a fact: it accepts a --facts FILE and ignores it, without opening the file. When the declaration reads a fact and no --facts is given, the one-program plan is E_USAGE, with --facts as actual, since there is no root to collect from; that usage error is plan's alone. A tree or plan that needs no fact accepts a --facts FILE and ignores it, without opening the file. Each of the commands check, tree, plan, ask and emit also takes --json, as in typify check languages.typify Catalog catalog.typify --json.
| Argument | What it names |
|---|---|
DECLARATIONS |
A declaration file. It opens with #lang typify and holds bodies. |
LANGUAGE |
The name of a body in that file, as written after declare :. |
PROGRAM |
A program file in that language. A program file has no header. |
ROOT |
A directory in which the languages' file lines locate programs; see Trees. |
FILE |
A facts file, as typify facts writes it. |
WORD |
The word asked about; see Questions. |
A relative path given as DECLARATIONS, PROGRAM, ROOT or FILE is joined to the current directory as the operating system reports it, never to the PWD environment variable; the reader then normalizes a root lexically, and no symbolic link in the joined path is resolved. Wherever facts are collected (typify facts ROOT, and tree or plan over a root whose declaration needs a fact), a root that is not a canonical-path after that normalization is E_USAGE, with the root as supplied as actual (nothing is stripped, and no other root is invented), and a symbolic-link root is E_FILE; a tree or plan that reads no fact does not run the collector.
The examples use two languages. The Catalog language's declaration file is languages.typify:
#lang typify
declare : Catalog
version : 1
file : catalog.typify
required!
is : category = "book" | "journal"
is : title = /[^=]+/
term : item : category title
form : item : <category> = <title>
does : item <category> <title>
example : item : book = Algebra
count : item = 1..*
end!
Its program file is catalog.typify. The name agrees with the declaration's file line, and the declaration file is named differently, so that tree never reads it as a program:
item : journal = Market Research
Catalog declares no primitive, so item is a fact and its does builds data.
The Mounts language's declaration file is mounts.typify. Its path class is the built-in class canonical-path, since the last component of a stacking cell's key, here its only one, must be of class canonical-path or a class the reader can show is a subset of it; see Classes and Primitives and state:
#lang typify
declare : Mounts
version : 1
is : path = canonical-path
is : mode = "rw" | "ro"
cell : mounts = shadow stacking
primitive : mask : path
writes : mask : mounts = put 1
primitive : bind : path mode
writes : bind : mounts = put 1
term : share : path mode
rule : share <p> <m> -> mask (parent <p>) ; bind <p> <m>
ensure : share : child-visible = (visible mounts <1>)
form : share : <path>
does : share <path> rw
example : share : /shares/research
form : share-read : <path>
does : share <path> ro
example : share-read : /shares/archive
end!
Its program file is shares.typify:
share : /shares/research
Mounts has no file line, so it is planned one program at a time. In its ensure line, <1> is the first argument of share, the path: an ensure binds its variables by position to its constructor's arguments, <1> to <n>, and the predicate (visible mounts <1>) names the cell it reads, mounts.
Checks a declaration file: the shape of every line, every body, its classes and forms, and the checks made at declaration time (see Classes, Terms and counts, Primitives and state and Rules and plans). Every example line is run: the reader checks that it matches the form above it and builds its term, library calls included, each capture of its class and each template placeholder taking the shortest witness of its class; only a (context ...) or (inherited ...) call is not evaluated at an example. An example whose library call fails carries the library's own code, E_LIBRARY_DOMAIN or E_LIBRARY_PARENT, covering the library call in the form's does line. The formation of such a call is checked here whole: the constructor it names exists, an undeclared one being E_DECLARATION of kind reference; the call's sort is a list under each and a string elsewhere, and E_TERM_CLASS of kind sort otherwise; and a constructor whose rules carry an each has its fuel cap, while a context outside any each requires none. Only its values are read when a located program is planned, against its enclosing programs. The declaration is read whole, and every error the reader finds in it is reported as a diagnostic, ordered by position.
In text mode, check prints diagnostics only, and nothing when there is no diagnostic (a note is printed although the exit status stays 0):
typify check languages.typifychecks the Catalog declaration, its example item : book = Algebra included, prints nothing and exits with status 0.
With --json, check DECLARATIONS prints one object in every outcome, of the shape {"ok": true | false, "terms": [], "diagnostics": [...]}. The member bound, {"c": C, "k": K}, is present only in the program form (typify check DECLARATIONS LANGUAGE PROGRAM --json) and only when the language's declaration has rules: typify check mounts.typify Mounts shares.typify --json carries it, while typify check mounts.typify --json and typify check languages.typify Catalog catalog.typify --json do not (typify check mounts.typify --bounds --json carries c and k inside bounds).
Exit status: 0 when the file is clean, 1 when anything in it fails, 2 on a usage error or an unreadable file. A note, such as N_CLASS_EMPTY, never changes the exit status.
Reports the derived work bounds of two declaration-time checks: the emptiness test of the delimiter check, and the check that a body's forms do not overlap. Both may run the product of a class's automaton and its length counter symbolically; see Caps. In text mode the report is one entry per line. With --json it is one object, {"ok": true | false, "bounds": {...}, "diagnostics": [...]}, whose bounds member is an object: each declared cap of each body, keyed Language.cap even when the file holds one body, such as Catalog.length, the effective caps a body leaves at their defaults included, each constructor's fuel cap, keyed Language.constructor.fuel, and each host guard, by its own name, each with {"limit": n}; and, when any body has rules, c and k, as in the bound member of check --json, each a plain integer and the maximum over all the bodies:
typify check languages.typify --bounds
typify check languages.typify --bounds --jsonThe report stands apart from the normal check response and from the emitted grammar: neither carries these bounds, and the derived work bounds are not the bound member of check --json, which bounds a plan and its state and whose c and k the report repeats when the declaration has rules. The bounds are host-dependent. The corpus never compares them, and the report claims neither CPU steps nor a representation that another host must copy; see Test your own host.
The report also lists the host's own guards, by the host's own names, such as temporary-states or reference-nodes. A guard that trips is reported as E_CAP, with the guard's name as cap, its configured limit as limit and the attempted count as actual; see Codes and the registry. No corpus case depends on a host's guard.
Checks a program against a language. The reader builds the program's meaning, the list of its lines' terms in order followed by its defaulted terms, checks each term against its constructor's signature, and checks every count. When the program holds no term of a constructor, by any form, every default line of that constructor's forms is added, in declaration order, after the program's own terms, with an origin of kind default; one present line of the constructor suppresses them all. Defaults are added before the count check, so a default satisfies count = 1. See Terms and counts.
This form accepts --facts FILE and ignores it, without opening the file: check never reads a fact, and the E_USAGE for a missing --facts is the one-program plan's alone; see Synopsis. When the language has a file line, the reader binds its template placeholders by matching the program's path, as given on the command line, against the template; a path that does not match is E_USAGE, with the path as actual.
In text mode, check prints diagnostics only, and nothing when there is no diagnostic; a note is printed although the exit status stays 0. typify check languages.typify Catalog catalog.typify prints nothing and exits with status 0. With --json:
typify check languages.typify Catalog catalog.typify --jsonprints:
{"ok": true, "terms": [["item", "journal", "Market Research"]], "diagnostics": []}| Member | What it holds |
|---|---|
ok |
true for a clean result. |
terms |
The program's meaning: the list of its lines' terms, in order, followed by its defaulted terms. See Terms and counts. |
diagnostics |
The diagnostics, each as its JSON document; an empty array when nothing is reported. |
bound |
Present only when the declaration has rules. c is c_D, the per-line constant the reader computes from the declaration, with every for-each at its declared fuel cap; c_D bounds every folded event, the executed terms of plan and the terms of recorded alike; k bounds the predicted state: its size is at most k times the sum of the lengths of plan and recorded. See Rules and plans. |
Catalog has no rules, so its object has no bound. Mounts has a rule, so typify check mounts.typify Mounts shares.typify --json carries bound, and its terms member is the program's meaning before any rule rewrites it:
[["share", "/shares/research", "rw"]]A line that fails is an error. With item : magazine = Weekly as the program's line, the capture magazine fails the class category. With item : book Algebra, no form matches the line. Each error is a diagnostic that names the file and the range of the failure (and when no other line supplies an item term, check also reports E_PROGRAM_COUNT for count : item = 1..*). The reader reports every error it finds, ordered by position, and does not stop at the first.
The program is read only when its declaration has no diagnostic of error severity. When the declaration has one, check reports the declaration's diagnostics, exits with status 1 and does not read the program.
Exit status: 0 when the declaration and the program are clean, 1 when the declaration has an error or any line, term or count of the program fails, 2 on a usage error or an unreadable file.
Walks the directory ROOT. For each language with a file line, the reader fills the template wherever its placeholders match existing directories, or, for a template whose file name introduces a placeholder, existing files only, and reads every program that exists against its language. A missing required! program is an error; a missing optional! program is its default lines, or no terms. A required! template whose file name introduces a placeholder and that locates nothing is E_REQUIRED, with the template as its data.path and the declaring file as its file; no program is invented. See Trees.
Programs come in tree order: by directory depth, then by portable path, the path written with / as the separator on every platform (see Paths), then by the declaration order of their languages.
In text mode, tree prints one line per program: its status, then its path.
With --json, tree prints one object, {"ok": true | false, "programs": [...], "diagnostics": [...], "facts": "none" | "sha256:...", "inputs": {...}}: under programs the model, one entry per program in tree order; under diagnostics every diagnostic, notes included; under facts the accepted facts document's sha256: digest or "none"; and under inputs the observations made during discovery (root, factsRoot, declarations, paths, directories, programs and facts; see docs/inputs.md in the repository). It prints this object in every outcome, and diagnostics is an empty array when nothing is reported; when a declaration has an error or an input cannot be read, ok is false, programs is empty and diagnostics holds the diagnostics. Like check and plan, tree prints its own object; no command prints a bare array. Each entry of programs has these members.
| Member | What it holds |
|---|---|
path |
The program's path. |
language |
The language that located the program. The pair of path and language is the entry's identity: one file that two languages locate gives two entries, next to each other. |
placeholders |
The values of the template's placeholders for this program. |
status |
present, defaulted, absent-empty, missing or guarded; see The five statuses. A program whose file exists is present, even when defaults supply some of its terms. An absent optional! program with no default lines is absent-empty, and no count is checked for it; an absent program with default lines is defaulted, and its counts are checked. A guarded program's terms are empty. |
terms |
The program's terms: its own terms first, then its defaulted terms, in the order of the default lines. See Terms and counts. |
origins |
Where its terms come from: each origin is {"kind": "program", "path": ..., "line": ...} for a program line, or kind default with the declaration file and the line of the default line. |
A guard : <constructor> = <fact> line plans a program that holds a term of that constructor only when the fact holds. When it does not, the program's terms are skipped, its terms are empty, and tree reports the program guarded; plan records the skip in the program's skips member. See Rules and plans.
When the declarations carry a guard or a reads line, tree reads the facts from a facts file:
typify tree DECLARATIONS ROOT --facts FILEor, without --facts, runs the facts collector as plan does. For declarations with neither line tree needs no fact, even when a rule calls a fact inside (if ...): it accepts a --facts FILE and ignores it, without opening the file. Catalog has neither, so its tree is read without facts:
typify tree languages.typify .
typify tree languages.typify . --jsonRun in the directory that holds both Catalog files, each command prints one program, catalog.typify, with the status present: in text mode as one line, the status then the path; with --json as the one entry of programs, which also holds its terms.
Exit status: 0 when every program is clean, 1 when a declaration has an error, a program fails its language or a required! program is missing, 2 on a usage error or an unreadable file.
Runs tree, then normalizes: rules rewrite each program's terms into primitive terms. Over a root the plan is one list: the primitive terms of every program, sorted by stage, and within a stage in tree order and then in term order. The predicted final state is the fold of that list, in that order. plan gives the ordered primitive terms per program; beside them it prints the predicted final state, whose entries each carry their own origin, the plan's bound (with --json only; text mode prints no bound line), the origin of every executed term, how many primitives are modelled, the plan's status, the evaluated ensure invariants and the skipped terms. A primitive declared effect : <primitive> = external has no model: plan counts it unmodelled and prints it unchecked, never ok, and no plan that holds one reads green. Such a plan is not an error: a term of an external primitive carries "unchecked": true, and when no diagnostic of error severity exists, the plan's status is unchecked and plan exits with status 0. A primitive with neither a writes line nor that declaration is refused by check with E_DECLARATION of kind effect. A primitive declared effect : <primitive> = state has its writes lines and no host action: plan lists its terms under recorded, in plan order with their origins, apart from the executed terms under plan, and modelled counts the executed terms only. Every ensure invariant is evaluated once per term that carries it, against the final state after the whole fold. See Rules and plans and Primitives and state.
A plan is a pure function of the declarations and the facts. With --facts FILE, a plan that needs a fact reads the facts from FILE:
typify plan DECLARATIONS ROOT --facts FILEWithout --facts, a plan that needs a fact runs the facts collector itself. Under --json, plan carries the facts file's hash in its facts member (text mode prints no hash line); when plan runs the collector, the hash is the digest of the collector's output exactly as typify facts ROOT writes it. The hash is the string sha256: followed by sixty-four lowercase hex digits and names the bytes read: plan --json carries it whenever the declaration reads a fact and the facts file was read and accepted, in every outcome, a failed plan included, and carries none in its place only when the declaration reads no fact or when no facts document was read and accepted. A facts file that cannot be read, or that does not follow the facts wire, is E_FILE, and the hash is none for a file that does not follow the wire although its bytes were read. A plan that needs no fact accepts a --facts FILE and ignores it, without opening the file: nothing in the file is validated, and the hash is still none. A case of the public corpus that is planned over a root whose declaration reads a fact carries its own facts.json, and the runner plans it with --facts, so that no result depends on the machine; the runner may pass --facts to every case over a root, since a plan that needs no fact ignores it; see Test your own host.
In text mode, when the fold completes (ok, unchecked, or E_ENSURE), plan prints the plan's status, failed, ok or unchecked, on its first line, then one primitive term per line, each prefixed by the path of its program; a recorded term is prefixed by its program's path and the word recorded, and a term of an external primitive ends with the word unchecked, while diagnostics print on standard error. When nothing could be planned (because a declaration has an error, an input or required program cannot be read, the expansion fails, or E_FACT_REJECT stops the fold), standard output is empty and only the diagnostics' text projections are printed.
With --json, plan over a root prints one object of the shape {"programs": [{"path": ..., "language": ..., "status": ..., "plan": [...], "recorded": [...], "ensure": [...], "skips": [...]}, ...], "schedule": [...], "inputs": {...}, "state": ..., "bound": ..., "modelled": ..., "status": ..., "facts": ..., "origins": [...], "ensure": [...], "diagnostics": [...]}. Each program's entry holds its own plan; the stage-sorted merge of those plans appears in schedule, and the fold that gives state runs in that order. A program's status is its status in the model tree prints; the top-level status is the plan's, failed, ok or unchecked.
| Member | What it holds |
|---|---|
programs |
One entry per program: its path, its language and its status, as in the model tree prints, the pair of path and language being the entry's identity; its plan, the ordered primitive terms, each written as in the single-program form below; its recorded, the terms of its state primitives, apart from plan, as an array of {"term": [...], "origin": {"kind": ..., "path": ..., "line": ...}} objects in plan order; its ensure, one entry per evaluated ensure invariant of its terms, each evaluated once per term that carries it, against the final state; and its skips, its skipped terms. |
schedule |
The ordered operations across the root, sorted by stage and preserving tree and term order at equal stages: each entry carries program, stage, sequence (zero-based), term, origin, modelled and kind ("host" or "recorded"). See docs/plan-wire.md in the repository. |
inputs |
The observations made during the root walk and evaluation, in the same shape as tree --json (docs/inputs.md). |
state |
The predicted final state after the whole fold over the stage-sorted merge of the programs' plans: one list per cell, in key order. |
bound |
The plan's bound; see Rules and plans. |
modelled |
How many primitives are modelled, as a string "k of n", counted over the executed terms only, never over recorded. |
status |
"failed" when a diagnostic of error severity exists; otherwise "ok" when the two numbers of modelled are equal and "unchecked" when the first is less than the second. |
facts |
The hash of the facts file: the string sha256: followed by sixty-four lowercase hex digits whenever the declaration reads a fact and the facts file was read and accepted, in every outcome, status failed included; none only when the declaration reads no fact or when no facts document was read and accepted, which E_FILE reports. |
origins |
The origin of every executed term of plan, and of executed terms only: a term of recorded carries its own, and each state entry carries its own origin. |
ensure |
The ensure entries at the top level, in the shape given below. |
diagnostics |
Every diagnostic, each as its JSON document; an empty array when nothing is reported. |
Every evaluated ensure invariant produces one entry of the shape {"ensure": NAME, "ok": true | false, "origin": {"kind": ..., "path": ..., "line": ...}}, where NAME is the invariant's name and origin is an origin object, as in origins; ensure arrays stand per program and at the top level. An invariant that fails has "ok": false and also raises E_ENSURE, whose data carries ensure and key, the key an array of decoded strings in key order, as a state entry's key; see Codes and the registry.
A failing invariant does not replace the report. plan --json still prints its arrays whole, ensure holding every evaluated entry; its diagnostics holds one E_ENSURE for each entry whose ok is false and any other diagnostic; its status is failed; and plan exits with status 1. A complete expansion can fail only at the fold, with E_FACT_REJECT, or after it, with E_ENSURE; on E_ENSURE the fold is complete, and plan prints its arrays, state and ensure whole, as above. On E_FACT_REJECT the fold stops at the rejected read. state is {} and ensure is []: every invariant is evaluated against the final state after the whole fold, which does not exist. skips holds the skips decided before the rejection. plan and origins hold the expanded plan as a successful plan would print it up to the rejected read, then the rejected term itself, then every term after the rejected read as expanded, undecided; a term that a reads line saying skip left out before the rejected read is in skips and out of plan, origins, recorded and modelled. recorded and modelled describe the expanded plan, whether or not the fold reached a term: recorded holds the terms of state primitives in plan order, before and after the rejected read, all but those skipped before it, and modelled counts every term of plan, the undecided ones included. Such a plan's status is failed, and plan exits with status 1. So of two expanded terms, the first skipped by its reads line and the second rejected with E_FACT_REJECT, plan holds the rejected term alone, skips carries the first, origins and modelled count the rejected term alone, state is {} and ensure is []. E_CONTEXT, E_LIBRARY_DOMAIN, E_LIBRARY_PARENT, E_RULE_FUEL and every other diagnostic raised while a plan is expanded or normalized are failures within expansion: lookups, inherited lists and library calls are evaluated as a rule's right side is rewritten. Such a failure prints the object of a plan where nothing was planned: plan, origins, recorded and skips empty, state {}, over a root programs [], modelled "0 of 0" and status failed; plan exits with status 1. Its bound is still printed, computed from the declaration and the input. The failing term is named by the diagnostic's range and data alone, never by the arrays, and nothing of a partial rewrite is printed. A rule cycle is not a failure within expansion: E_RULE_CYCLE is found when the declaration is read, and a rewrite that runs away ends as E_RULE_FUEL. When nothing was planned, because a declaration has an error, an input cannot be read, or, for plan, the expansion fails, tree prints its object with ok false and plan its object with status failed, modelled "0 of 0" and state {}, their arrays empty, programs included, and diagnostics holding the diagnostics. plan's bound is still a member of its JSON object whenever the declaration and the input were read, a failed plan included: it is computed from them, and zeros are never printed in its place. When the declaration has an error and nothing could be computed, bound is null, so the object keeps its shape. bound is a member of the JSON objects only: in text mode plan keeps its contract, the status on its first line and one primitive term per line prefixed by its program's path when the fold completes (recorded terms marked recorded, external terms ending with unchecked), and only the diagnostics' projections when nothing could be planned, with no bound line in either outcome.
A skipped term is recorded in its program's skips, which over a root stands in the program's entry only, as recorded does, and in the one-program form at the top level, as that program's own, in the shape {"constructor": ..., "fact": ..., "args": [...], "reason": "if" | "read" | "guard", "origin": {"kind": ..., "path": ..., "line": ...}}. Its reason is if for a term that an (if ...) left out, read for one that a reads line saying skip left out, and guard for one that a guard line left out. For a term that a false (if ...) left out, constructor is the suppressed term's constructor, never the constructor of the rule that carries the (if ...). args holds the fact's arguments; it is always present, and empty when the fact took none. A lookup, (context ...) or (inherited ...), that crossed a guarded program adds to the reading program's skips an entry of its own shape, {"reason": "guard", "fact": ..., "args": [...], "program": ...}, fact and args being the guarded program's guard fact and its evaluated arguments, and program the guarded program's portable path.
Plans compare as ordered argument lists, never as sets.
Exit status: 0 unless a diagnostic of error severity exists, so a plan whose status is unchecked alone exits with 0; 1 on errors, among them a program that fails its language and an ensure invariant that fails; 2 on a usage error or an unreadable file.
Plans one program, as check checks one. This is the form for a language without a file line, which tree never reaches. It takes --facts FILE, from which a plan that needs a fact reads the facts; when the declaration reads a fact and no --facts is given, it is E_USAGE, with --facts as actual, since there is no root to collect from. A language with a file line binds its template placeholders here as in the one-program check, from the program's path as given on the command line; a path that does not match the template is E_USAGE, with the path as actual. In text mode, when the fold completes, it prints the plan's status, failed, ok or unchecked, on its first line, then one primitive term per line, each prefixed by the program's path, a recorded term by the path and the word recorded, and an external term ending with unchecked, as over a root (when nothing could be planned, standard output is empty and only the diagnostics print). With --json it prints one object of the shape {"plan": [...], "recorded": [...], "state": {...}, "bound": {"c": C, "n": N, "limit": L}, "modelled": "k of n", "status": "ok" | "unchecked" | "failed", "facts": "HASH", "origins": [...], "ensure": [...], "skips": [...], "diagnostics": [...]} (except on a usage error, which prints {"ok": false, "diagnostics": [...]} with exit status 2).
| Member | What it holds |
|---|---|
plan |
The ordered primitive terms. A term of a modelled primitive is an array, such as ["mask", "/shares"]; a term of an external primitive is the object {"term": [...], "unchecked": true}. A term of a state primitive is not here but under recorded. |
recorded |
The terms of state primitives, declared effect : <primitive> = state, apart from plan: an array of {"term": [...], "origin": {"kind": ..., "path": ..., "line": ...}} objects, in plan order. No host executes them. |
state |
The predicted final state: one list per cell, in key order. |
bound |
c is c_D, n the number of terms the program holds (blank, comment and question lines build no term; defaulted terms count), and limit is c_D times n: the folded events, the terms of plan and of recorded together, number at most limit. |
modelled |
How many primitives are modelled, as a string such as "2 of 2", counted over the executed terms only, never over recorded. |
status |
"failed" when a diagnostic of error severity exists; otherwise "ok" when the two numbers of modelled are equal and "unchecked" when the first is less than the second. |
facts |
The hash of the facts file: the string sha256: followed by sixty-four lowercase hex digits whenever the declaration reads a fact and the facts file was read and accepted, in every outcome, status failed included; none only when the declaration reads no fact or when no facts document was read and accepted, which E_FILE reports. |
origins |
The origin of every executed term of plan, and of executed terms only: a term of recorded carries its own, and each state entry carries its own origin. |
ensure |
One entry per evaluated ensure invariant, evaluated over the predicted state, in the shape given over a root. |
skips |
The skipped terms, in the shape given over a root. |
diagnostics |
Every diagnostic, each as its JSON document; an empty array when nothing is reported. |
Mounts has no file line:
typify plan mounts.typify Mounts shares.typify --jsonIts plan member is:
[["mask", "/shares"], ["bind", "/shares/research", "rw"]]and its modelled member is "2 of 2" and its diagnostics member is [], so its status member is "ok". Its state member holds the predicted state, one list per cell, in key order, the order of the decoded key tuples compared component by component by code point, never of their JSON text (see The predicted state):
{"mounts": [{"key": ["/shares"], "value": [], "masked": true, "sequence": 0, "origin": {"kind": "program", "path": "shares.typify", "line": 1}}, {"key": ["/shares/research"], "value": ["rw"], "masked": false, "sequence": 1, "origin": {"kind": "program", "path": "shares.typify", "line": 1}}]}An entry's key holds the arguments that form the key and its value the rest; on a stacking cell each surviving entry also carries sequence, the zero-based position of the write that established it (entries of non-stacking cells carry no sequence). In the stacking cell mounts, /shares maps to a masked entry, since mask puts its key with no value, and /shares/research maps to rw; each entry's origin is line 1 of the program. (visible mounts "/shares/research") holds because the put at the ancestor /shares came before the put at the child, so child-visible passes. The reverse order (bind, then mask the parent) puts at the ancestor after the child, which makes the child not visible: the rules alone accept it, and the invariant rejects it. In that order the child's entry keeps "masked": false, the flag of its own put, which carried a value; its hiding is visibility, judged by (visible ...) when the invariant is evaluated, and is serialized nowhere: a state entry has no visibility field.
Its ensure member holds the one evaluation of child-visible, for the share term of line 1:
[{"ensure": "child-visible", "ok": true, "origin": {"kind": "program", "path": "shares.typify", "line": 1}}]Its skips member is []: Mounts has no (if ...), no reads line and no guard line. Its recorded member is [] too: Mounts declares no state primitive.
The exit statuses are those of typify plan DECLARATIONS ROOT.
Writes the facts file for ROOT: what a facts collector found on the filesystem, as JSON. For example:
{"collector": "typify 1.0", "root": "...", "facts": [{"fact": "exists", "args": ["/shares/research"]}, {"fact": "mode", "args": ["/shares/research"], "value": "0700"}]}The facts of version 1 are six: the collector's five, exists, directory, symlink, mode and owner, and clean, which the reader derives from the facts file. (clean <path> <name>) holds when <path> belongs to the observed facts root and no entry of the facts file at depth two or more below <path>, for which directory or symlink holds, has <name> as its last component: the entry of that name directly under <path>, such as <path>/.git itself, is not a nested one, and a regular file of that name is ignored; a marker at an ancestor of <path> is declared separately, over ancestors. No collector writes it, so clean adds nothing to the wire. It is usable wherever a fact call is, and a reads or guard line naming any other fact is E_DECLARATION of kind reference. A collected fact that is absent from the file is false. The collector writes root and every argument as a canonical absolute path, a mode as a string of four octal digits, such as "0700", and an owner as the decimal uid, in text. It never follows a symlink: a symlink fact carries the link's target text as its value. The file includes the root itself. The collector omits an entry whose path is not a canonical-path, a space (U+0020) in a component included, and writes "omitted": n beside facts, n counting each omitted entry once, the descendants of an omitted directory included, since the traversal is not pruned, and never once per fact, when n is positive, and no omitted member otherwise; a fact over an omitted entry is absent, and clean does not see below it. omitted is part of the facts wire: when present it is a positive integer, checked as the rest of the file is, and when absent it is zero. Canonical is lexical: nothing resolves a symbolic link, neither the collector nor the reader, and an ancestor of the root that is a link elsewhere on the machine concerns neither. A facts file given with --facts whose collector string, root, fact names, arguments, modes or owners do not follow this wire is refused with E_FILE, carrying that file's path. An E_FILE from a run of the collector, when facts, plan or tree runs it, carries the path of the root or entry that could not be read. The example is shortened: it elides the root's path as "...", which in a written file is the root's canonical absolute path, and it leaves out the root's own facts. plan reads the file with --facts FILE when it needs a fact, and so does tree when the declarations carry a guard or a reads line; see Synopsis. A second, independent collector, a shell script under test/, writes the same wire, omitting the same entries, and gates this one: the two files are compared as canonical JSON. See Primitives and state.
Exit status: 0 clean, 1 on errors, 2 on a usage error or an unreadable file.
Answers the reserved question line ? : WORD in a language, reading that language alone. A word the language declares is answered whatever its spelling; any other word is checked against the verb class, /[A-Za-z0-9][A-Za-z0-9-]*/, before the answer repeats it, and a word that fails it is E_USAGE, with the word as written as actual, and exit status 2 (see Questions). In text mode the answer is Typify lines, every one under the reserved verb ?. A declared word is answered by its declaring lines, in the order given on Questions, with no status line:
typify ask languages.typify Catalog itemprints:
? : form : item : <category> = <title>
? : file : catalog.typify
? : does : item <category> <title>
? : term : item : category title
? : is : category = "book" | "journal"
? : is : title = /[^=]+/
? : example : item : book = Algebra
? : count : item = 1..*
? : missing : refused
A word declared as a primitive, a class or a cell and built by no form is answered by its declaring lines of that kind, first line first: a class by its is line alone, a cell by its cell line and then the join lines of the table it names; in a language with a file line, a term or primitive that no form builds begins with its term or primitive line, and the file line follows it, then the is lines of the classes its signature names, each once, in signature order, and the rest in the order below. A spelling declared both as a verb or a constructor and as a class or a cell is answered by the union of its answers: the forms and constructors first, in the order below, then the class's is line, then the cell's cell line and its join lines, and no line is printed twice (see Questions). An answer's forms are those whose verb is the asked word and those whose does line builds the constructor the word names, each once, in declaration order; an answer with more than one constructor prints its lines per constructor, as Questions says. A form line and its does line are a pair: a constructor built by two forms is answered with every pair first, in declaration order, and the rest of the answer follows once. The lines come in this order: the first form line, the file line, the first does line and the form's restricts! line when it has one, then each further form line with its does line and its restricts! line when it has one; then the term or primitive line, the is lines, the constructor's own lines, every line whose first name after the introducer is the constructor (writes, reads, guard, effect, stage, scope, fuel and, for a fact constructor, fact), in declaration order, whatever its kind, the rule lines whose left side is the constructor, its ensure lines, the examples, the count lines, the missing line, the default lines, and the constructor's note lines last. When the body declares no unkeyed count for the word, the answer still prints count : <constructor> = *, before the keyed count line when one exists: with only a keyed count, the unkeyed bound is *. See Questions.
A word that nothing declares is answered undeclared, then by its near lines, and nothing more: the candidates at the least distance within the bound or, when none lies within it, the candidates that share a hyphen part with the word (see Questions). An undeclared word is an answer, not an error, and ask exits with status 0. itme is one exchange of adjacent letters from item:
typify ask languages.typify Catalog itmeprints:
? : itme = undeclared
? : near : item
With --json, ask prints one object with the members word, status (declared or undeclared), lines (every answer line as a string), near, accepts, which is always the empty array in v1, since no ? : accepts line prints, and diagnostics, which carries what reading the declaration reports, notes included, and is an empty array when nothing is reported; in text mode the notes' projections print before the answer lines. A declaration with an error, an unreadable file, or a word that fails the verb class gets no answer: under --json ask prints {"ok": false, "diagnostics": [...]}, with no answer fields, and in text mode the diagnostics' projections, as every command does, and no answer line. For itme:
{"word": "itme", "status": "undeclared", "lines": ["? : itme = undeclared", "? : near : item"], "near": ["item"], "accepts": [], "diagnostics": []}The lines and the JSON round-trip: a test parses every string of lines as a line under ?, rebuilds the status line and the near lines from word, status and near, and requires them equal to the printed lines.
With Typify as LANGUAGE, ask answers from the meta body, after reading the declaration file as every command does; see Questions.
Exit status: 0 for an answer, an undeclared word's included, 1 on errors in what was read, 2 on a usage error, a word that fails the verb class included, or an unreadable file.
Prints a language's grammar as data, and the grammar alone: the JSON grammar under --json or by default, and the GBNF text with --gbnf. The output is a document, not a report: it never carries a diagnostics key and never prints a note, which check reports. On a failed declaration, emit prints {"ok": false, "diagnostics": [...]} under --json, and the diagnostics' text projection otherwise, and exits with status 1, as check does. --gbnf together with --json is E_USAGE, with --gbnf as actual. The emitted grammar accepts exactly the lines that the reader accepts as well formed under the declaration's forms and classes, for every declaration that passes the declaration-time check. Counts, order, the results of library calls and the resolution of names are judged by the reader after that and are not in the grammar. See Emission.
typify emit languages.typify Catalog
typify emit languages.typify Catalog --gbnfThe first command prints Catalog's JSON grammar and the second its GBNF text. Emission shows both: The JSON grammar gives Catalog's JSON grammar as printed, with its top-level members, its class nodes and its form fields, and The GBNF text gives the readable structure of Catalog's GBNF rules and what the printed text adds to it.
Exit status: 0 clean, 1 on errors in what was read, a failed declaration included, 2 on a usage error, --gbnf with --json among them, or an unreadable file.
Prints the grammar of the meta language, the language that declaration files are written in: JSON by default and under --json, GBNF under --gbnf, as emit does for any language. It takes no declaration file. Its output is a grammar, not declaration source, and typify check refuses it. The meta language's self-declaration, typify.typify, is written by the release build into every archive at typify/share/typify.typify, beside bin/, and checked with typify check typify/share/typify.typify --json. See Emission.
Prints the reader's version and reader-source digest on one line, 1.0.0 sha256: followed by 64 lowercase hexadecimal digits; with --json it prints {"build": "sha256:...", "diagnostics": [], "version": "1.0.0"}. The package version is the language version: each release reads one grammar, and there is no compatibility table.
Every diagnostic is one native JSON document. In text mode a command prints the diagnostic's text projection; with --json the command puts its result on stdout as one JSON document, in the shapes given above. With --json, check, tree and plan each print their own object in every outcome, and that object carries diagnostics, an empty array when nothing is reported; ask prints its answer object, whose diagnostics carries what reading the declaration reports, notes included, or, on a failed declaration, an unreadable file or a word that fails the verb class, {"ok": false, "diagnostics": [...]} with no answer fields; emit prints the grammar alone, never with a diagnostics key, and prints {"ok": false, "diagnostics": [...]} only on a failed declaration; a usage error prints the object given under Diagnostics. A consumer in any language calls the executable and reads the JSON (the reader prints compact canonical JSON with object keys sorted; multi-key JSON examples in this wiki are spaced and ordered for reading). Version 1 requires the --json output on the test corpus to be byte-identical on all four platforms: Linux x86_64, Linux aarch64, macOS aarch64 and Windows x86_64. A host that runs the public corpus compares its output as canonical JSON, never as bytes, and compares a diagnostic by its code, file, range, and of data only the fields the registry lists for the code, never by its severity, message, fix or related; see Test your own host and Codes and the registry.
| Status | Meaning |
|---|---|
0 |
Clean. |
1 |
Errors in what was read. |
2 |
A usage error (E_USAGE), an unknown command included, or an unreadable file (E_FILE). |
Notes, the diagnostics of severity note such as N_CLASS_EMPTY, never change the exit status.
A diagnostic is one JSON document. Its nine fields are code, severity, file, range, message, related, fix, data and fingerprints ({"primaryLocationLineHash": ..., "rule": ..., "useOrdinal": ..., "verb": ...}). Its file, and a related entry's, is the path as given for a file named on the command line, and, for a program the tree located, its portable path relative to the root (see Paths). E_REQUIRED's file is the declaring file, the declaration file whose declaration carries the required! line, as given on the command line; the missing program's path, or, for a required! template with a placeholder that locates nothing, the template, is its data.path alone and appears in no other field. The range is a start and an exclusive end, each a line and a column counted in Unicode code points, with the byte offset beside; it is null for E_REQUIRED, E_FILE and E_USAGE. E_USAGE names no file, so its file is the empty string "", and its actual is the offending token as written, such as an unknown command's word, an unknown flag, the flag whose argument is missing, --facts when the declaration of a one-program plan reads a fact and no --facts is given, --gbnf when emit is given it with --json, a root read by the facts collector that is not a canonical-path after lexical normalization, as supplied, or, in a one-program form, a program's path that does not match its language's file template, or a word given to ask that the language does not declare and that fails the verb class, never the whole command line. A usage error, an unknown command included, prints {"ok": false, "diagnostics": [...]} when --json is among the arguments, and the text projection otherwise; the exit status is 2. The document follows SARIF's structure, and its SARIF projection renames the fields to SARIF's, such as ruleId for code, level for severity, region for range and properties for data. Every kind of diagnostic has a stable code. The text form, SARIF (--sarif), LSP (--lsp) and GitHub annotations (--github-annotations) are projections of the one document. See Diagnostics for an example, the projections and the conversion to the Language Server Protocol.
The reader reports every error it can find, ordered by position, by file, line and column, and within one position in the order of detection. A declaration is read whole and all its errors are reported; a program is read only when its declaration has no diagnostic of error severity. Only within the normalization of one term is the first failure alone reported (see Normalization). After a malformed line the reader recovers and reports no diagnostic that only the recovery would cause (see Every error, in order).
Paths the reader prints, in diagnostics and in JSON output, use / as the separator on all four platforms, Windows included.
tree and plan execute nothing and write nothing: they print a model or a plan. Acting on a plan is a consumer's work: its host executes the primitive terms under plan, in order, and nothing else; the terms under recorded have no host action. The library functions that rules call have no file, process or network access, so the reader stays a function of its inputs.