schema: ludicc --emit-schema / ludic schema, --check --diagnostics=json, and editor attributes
--emit-schema FILE writes the compiler's resolved view once the program type-checks: every
record (fields, types, defaults as written, docs, places, attributes), every registry with its
entries in their final order after the open-registry merge (key, constant, index, file:line:col
of the entry and of each field value, and which file contributed which keys), every const, and
the zero-argument functions a fn value can name. Deterministic, schema_version 1; the runtime is
left out. `ludic schema [file] [-o FILE]` wraps it.
--check --diagnostics=json prints every error as one JSON array on stdout: the checker's and the
module rules' all, a parse or lowering error as the last. Tokens and nodes now carry a column.
Fields take several @attributes; @Ref(Registry), @OneOf(PREFIX_), @Range(lo, hi), @Unit("..."),
@Asset("..."), @Color on a field and @AppendOnly / @ByKey on a registry change nothing but go into
the schema, and @Ref naming no registry is an error (every one reported). Fixtures:
examples/lang/attributes.ludic, examples/rejected/ref_unknown.ludic, cases in ludic-dev test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f8d811aa97
commit
42deb76c28
27 changed files with 1220 additions and 23 deletions
|
|
@ -94,6 +94,10 @@ property Node {
|
|||
mg: int = -1 # 0.S2: its index in the migration's tables (migrate.ludic)
|
||||
vw: int = -1 # 0.S: the view a function was generated for or written in
|
||||
cm: int = -1 # 0.S: the component a function was generated for or written in
|
||||
col: int = 0 # the column of its first token (1-based; 0 when generated)
|
||||
at: int = -1 # its attributes (@Ref(Items), @Range(0, 1), ...): a group in attrs.ludic
|
||||
sp0: int = -1 # a field's default, a const's value, an entry field's value: where its
|
||||
sp1: int = -1 # source text starts and ends in its file (the schema's text of it)
|
||||
}
|
||||
|
||||
# every node remembers where it was parsed (file + the line of the token the
|
||||
|
|
@ -105,6 +109,7 @@ function node(kind: int) -> Node {
|
|||
n.file = g_parse_file
|
||||
if g_parsing and pi < len(toks) {
|
||||
n.line = toks[pi].line
|
||||
n.col = toks[pi].col
|
||||
n.pos = toks[pi].pos
|
||||
if g_gen_nodes { n.pos = -1 } # made by the compiler, not read from a file
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue