Std.Syntax
View source →The generic quoted-AST value a Tier-3 computed by elab receives and
returns (macro-facility design §3, generic layer). Reflects the parser's
{tag, meta, third} node: Node for a child list, Leaf for a scalar
third value, Raw for a node the parser produced that doesn't fit the
{tag, meta, third} shape at all (e.g. a bare impossible-body marker
or a non-conforming pattern tuple) -- reflected opaquely rather than
crashing. attrs carries the semantic meta (a function's name, an
operator, a literal's subtype) — dropping it would lose those. A meta
value need not be a plain scalar: SynLit also covers a list of values
(SList), a nested AST (SSyntax), and a lookup table (SMap), each
losslessly. Source positions are not represented (the expansion is
re-elaborated, K3 firewall).
Types
-
type Syntax = Node | Leaf | Raw | Quoted | Failure -
type NameSyntaxShape-specific aliases keep generated family records readable without introducing separate runtime representations or weakening the generic reflection boundary.
-
type ModuleNameSyntax -
type TypeSyntax -
type PatternSyntax -
type ExpressionSyntax -
type StatementSyntax -
type CodeSyntax -
type CasesSyntax -
type ParametersSyntax -
type FieldsSyntax -
type DeclarationsSyntax -
type ModuleBodySyntax -
type TokenSyntax -
type Diagnostic -
type MacroResult = Expanded | Rejected -
type Attr = KV -
type SynLit = SInt | SChar | SFloat | SStr | SBool | SAtom | SList | SSyntax | SMap | SOpaque -
type SynPair = SPair -
type AttrResult = Found | Missing -
type PatternHeads = Heads | InvalidHeadsA constructor head extracted from a reflected match arm. The arity is retained in the generic constructor key so source-defined derivations can reject unsupported payload views without compiler-owned domain knowledge.
-
type PatternHead = ValidHead | InvalidHead -
type PayloadTypes = Payloads | InvalidPayload
Functions
-
# fn alias_from(spec: AliasSpec) -> Syntax
-
# fn alias_node(name: String, rhs: Syntax) -> Syntax
typealiasis what the authored surface tags this node with, and the elaborator's header pre-pass keys off it: only a flagged alias gets a forward-referenceable header. Emitting the flag is therefore not cosmetic -- without it a generated alias (Handle,Datain anfsm) is invisible to any declaration lowered before it, including the enclosing unit's own declarations, which module lifting inlines ahead of the generated ones. -
# fn alias_spec(name: String, value: Syntax) -> AliasSpec
-
# fn atom_literal(value: Atom) -> Syntax
-
# fn attr(values: List(Attr), key: Atom) -> AttrResult
-
# fn attr_atom_is(values: List(Attr), key: Atom, expected: Atom) -> Bool
-
# fn attr_value(name: Atom, value: SynLit) -> Attr
-
# fn attrs(syntax: Syntax) -> List(Attr)
-
# fn block(items: List(Syntax)) -> Syntax
-
# fn bool_literal(value: Bool) -> Syntax
-
# fn call(name: String, args: List(Syntax)) -> Syntax
callis part of the compile-time reflection API. Core-evaluator macro execution must unfold it across the Std.Syntax interface boundary, so its body is semantic interface data rather than an opaque runtime detail. -
# fn caller_identifier(name: String) -> Syntax
Name-intent constructors make scope decisions explicit in macro source.
caller_identifierdeliberately retains the call-site scope; the other two are used for generated references and declaration names respectively. -
# fn captured_parameter_name(value: Syntax) -> Option(String)
-
# fn captured_parameter_pattern(value: Syntax) -> Option(Syntax)
-
# fn captured_parameter_type(value: Syntax) -> Option(Syntax)
-
# fn char_literal(value: Char) -> Syntax
-
# fn children(syntax: Syntax) -> List(Syntax)
-
# fn collect_pattern_heads(arms: List(Syntax), seen: List(Syntax), keys: List(Atom)) -> PatternHeads
-
# fn constructor_key(values: List(Attr)) -> Atom
-
# fn constructor_name(values: List(Attr)) -> Bool
-
# fn context_attr(syntax: Syntax, key: Atom) -> AttrResult
Look up one field in the generic staged expansion context.
-
# fn derive_pattern_heads(body: Syntax) -> PatternHeads
-
# fn diagnostic_details(primary: Syntax, message: String, hint: String) -> Syntax
Attach user-facing content to an authored diagnostic while keeping its stable failure name in the outer
Failure. Presentation adapters consume this record uniformly for source-defined macros. -
# fn diagnostic_subspan(target: Syntax, start: Int, length: Int) -> Syntax
Select a Unicode-scalar-relative range inside syntax captured from the caller. The compiler validates the range against the captured source span; an invalid or generated target falls back to the macro invocation. Macro authors therefore cannot forge a path or escape the captured syntax.
-
# fn enum_type(name: String, variants: List(Syntax)) -> Syntax
-
# fn enum_variant(name: String) -> Syntax
-
# fn enum_variant_payload(name: String, payloads: List(Syntax)) -> Syntax
Build a constructor variant with explicitly typed payload fields. The parser represents enum constructors as function definitions whose params are type expressions, so this is the same surface form as a user-written
type Message = Ping(Int)declaration. -
# fn expand(value: Syntax) -> MacroResult
-
# fn expansion_context(syntax: Syntax) -> Syntax
Read the generic staged expansion context attached to reflected syntax. A context-free use site is represented by the same opaque value used for any unavailable syntax, so a source-defined macro can inspect it without relying on a compiler-owned callback record.
-
# fn exported_identifier(name: String) -> Syntax
-
# fn float_literal(value: Float) -> Syntax
-
# fn fresh(name: String) -> Syntax
Mark a generated binder or reference for the parser's existing hygienic freshening pass. Use the marker at each generated occurrence that should share a binding; syntax reflected from the caller remains untouched. The marker is compile-time syntax and disappears before ordinary elaboration; it is not a runtime name generator.
-
# fn function(name: String, params: List(Syntax), return_type: Syntax, body: Syntax) -> Syntax
-
# fn function_downcase_identifier(identifier: Syntax, params: List(Syntax), return_type: Syntax, body: Syntax) -> Syntax
Build a function whose name is derived from reflected identifier syntax. The generic syntax bridge performs the requested Unicode-safe transform while converting the compile-time Syntax value back to parser AST.
-
# fn function_from(spec: FunctionSpec) -> Syntax
-
# fn guarded_match_arm(pattern: Syntax, guard: Syntax, body: Syntax) -> Syntax
-
# fn handler_children(body: Syntax) -> List(Syntax)
-
# fn handler_head(arm: Syntax) -> PatternHead
-
# fn has_key(keys: List(Atom), key: Atom) -> Bool
-
# fn has_tag(syntax: Syntax, expected: Atom) -> Bool
-
# fn identifier_name(value: Syntax) -> Option(String)
Generic identifier transformations for declaration-producing macros. These inspect reflected identifier syntax only; domain macros decide what generated name means (for example, an actor query adapter).
-
# fn int_literal(value: Int) -> Syntax
Lift ordinary primitive values into literal syntax. These constructors are explicit so a string can never be mistaken for an identifier or raw syntax.
-
# fn integer(value: Int) -> Syntax
-
# fn is_variable_named(syntax: Syntax, expected: Atom) -> Bool
-
# fn leaf(name: Atom, values: List(Attr), value: SynLit) -> Syntax
-
# fn leaf_value(syntax: Syntax) -> SynLit
-
# fn let_binding(name: String, value: Syntax) -> Syntax
-
# fn lift_module(module: SynLit, behaviour: Atom, declarations: List(Syntax)) -> Syntax
-
# fn lift_module_isolated(module: SynLit, behaviour: Atom, declarations: List(Syntax)) -> Syntax
Build a lifted unit that inherits enclosing declarations but not the imports used only to define the surrounding macro. Macro authors can use this when the generated unit declares its complete import surface.
-
# fn linear_parameter_spec(name: String, kind: Syntax) -> ParameterSpec
-
# fn list(items: List(Syntax)) -> Syntax
-
# fn match_arm(pattern: Syntax, body: Syntax) -> Syntax
-
# fn module_from(spec: ModuleSpec) -> Syntax
-
# fn node(name: Atom, values: List(Attr), terms: List(Syntax)) -> Syntax
-
# fn parameter(name: String, kind: Syntax) -> Syntax
-
# fn parameter_from(spec: ParameterSpec) -> Syntax
-
# fn parameter_linear(name: String, kind: Syntax) -> Syntax
-
# fn parameter_literals(params: List(Syntax)) -> SynLit
-
# fn parameter_names(items: List(Syntax)) -> SynLit
-
# fn parameter_spec(name: String, kind: Syntax) -> ParameterSpec
-
# fn parameters_from(specs: List(ParameterSpec)) -> List(Syntax)
-
# fn pattern_head(pattern: Syntax) -> PatternHead
Extract a closed constructor head from a reflected match arm. A handler whose head cannot determine a nominal constructor is rejected by the caller rather than silently widening the generated message/event type.
-
# fn payload_types(args: List(Syntax)) -> PayloadTypes
-
# fn private_identifier(name: String) -> Syntax
-
# fn reject(diagnostic: Diagnostic) -> MacroResult
-
# fn reject_all(diagnostics: List(Diagnostic)) -> MacroResult
-
# fn reverse_heads(items: List(Syntax)) -> List(Syntax)
-
# fn reverse_heads_acc(items: List(Syntax), acc: List(Syntax)) -> List(Syntax)
-
# fn string_literal(value: String) -> Syntax
-
# fn syntax_atom(value: Atom) -> SynLit
-
# fn syntax_bool(value: Bool) -> SynLit
-
# fn syntax_int(value: Int) -> SynLit
-
# fn syntax_list(items: List(Syntax)) -> SynLit
-
# fn syntax_string(value: String) -> SynLit
-
# fn tag(syntax: Syntax) -> Atom
Small, total operations used by source-defined syntax macros. These keep syntax analysis in Cure instead of teaching the compiler about a macro's domain-specific declarations.
-
# fn tuple(items: List(Syntax)) -> Syntax
-
# fn tuple_type(items: List(Syntax)) -> Syntax
-
# fn typed_let_binding(name: String, kind: Syntax, value: Syntax) -> Syntax
-
# fn typed_pattern(name: String, kind: Syntax) -> Syntax
-
# fn unit_literal() -> Syntax
The unit value has a two-tuple parser representation rather than an ordinary expression node. The parser bridge recognizes this reflected marker and restores the canonical
()AST before re-elaboration. -
# fn use_module(name: String) -> Syntax
-
# fn valid_payload_type(payload: Syntax) -> Bool
-
# fn variable(name: String) -> Syntax