Browse documentation
Docs/Language

Extension-defined literals

A package can declare a literal tag for a format it owns. For example, if an installed package exposes a tag called custom, bring that name into scope before using it.

Extension-defined literals

A package can declare a literal tag for a format it owns. For example, if an installed package exposes a tag called custom, bring that name into scope before using it.

USE "pkg:example/records@1.0.0" EXPOSING (custom)
records = custom"payload"

Grid looks up the parser in the installed package at compile time. Native formats such as GEDCOM come from the selected engine edition and use bare tags. Native GEDCOM example

Three spellings

custom"...", custom"""...""" and <custom>...</custom> select the same parser.

  • Ordinary quotes decode Grid escapes such as \n.
  • Triple quotes and angle blocks keep the payload exactly as written.
  • An angle block ends at the first matching closing tag, ignoring case.

Package literals never interpolate on their own. A package that supplies a template compiler adds the template attribute; see Reactive templates.

Naming and conflicts

EXPOSING (custom) makes the tag available by its own name. An alias selects the same tag under a qualified name.

USE "pkg:example/records@1.0.0" AS records
items = <records.custom>payload</records.custom>

The compiler rejects conflicting imports and attempts to replace built-in or native format tags.

When the package runs

Formatting and inspecting a model leave the literal's text untouched and do not run the package. Compiling runs the installed, verified parser once per distinct payload and replaces the literal with the constant value it returns. A parser error or a missing package fails the compile with a diagnostic that points inside the payload.

The compiled model then runs without the parser package. Editing the literal and recompiling needs the same package version again. The compiled model also records which package and payload produced each value, for review.

Using the value

Native GEDCOM in Standard/Lite and Pro returns genealogy records plus node and edge tables. It preserves unresolved relationship records and warns at the original pointers. A large batch of warnings still compiles within the diagnostic limit. Use gedcom directly when constructing a graph. GEDCOM result fields

graph ancestry = GRAPH(gedcom"""0 HEAD
1 GEDC
2 VERS 7.0
0 @I1@ INDI
1 NAME Isolated /Example/
0 TRLR
""")

node_count = ancestry.NODE_COUNT()

Pass the literal directly to GRAPH; a named or computed record is not folded into a graph at compile time, because that would lose its live dependency.

Editors

A package can describe how editors should color its payloads. For native data literals, source artifact rendering uses the compiler's format catalog. The literal's text can be inspected without loading its domain parser. An artifact whose stored delimiter would cut its payload short receives AST/UNSUPPORTED. The editor can still show the artifact fields.

Extension authoring contract