Documentation
¶
Overview ¶
Package validate validates Scheme syntax and produces typed expressions.
The package converts syntax.SyntaxValue into typed ValidatedExpr values for the compiler, accumulating multiple errors without short-circuiting:
result := validate.ValidateExpression(ctx, env, expr)
if !result.Ok() {
for _, err := range result.Errors {
fmt.Println(err)
}
}
validated := result.Expr
Validated Types ¶
- ValidatedIf: (if test conseq [alt])
- ValidatedDefine: (define name expr) or (define (name params...) body...)
- ValidatedLambda: (lambda (params...) body...)
- ValidatedCaseLambda: (case-lambda [clause] ...)
- ValidatedSetBang: (set! name expr)
- ValidatedQuote: (quote datum)
- ValidatedBegin: (begin expr...)
- ValidatedCall: (proc arg...)
- ValidatedSymbol: variable reference
- ValidatedLiteral: self-evaluating or passthrough
Hygiene ¶
The validator supports local variable shadowing of special forms (R7RS 4.2.2) using Flatt's scope-set model for identifier resolution.
Index ¶
- Constants
- func BodyIsFrameReleasable(proc ValidatedBodyAndParams, selfName string, ...) bool
- func BodyIsSelfTailReusable(proc ValidatedBodyAndParams, selfName string, ...) bool
- func ClassifyFrameReclaim(unit []ValidatedExpr, env *environment.EnvironmentFrame) map[string]bool
- func IsCaptureSafePrimitiveName(name string) bool
- func LetBindingSelfTailReusable(v *ValidatedLet, i int, env *environment.EnvironmentFrame) (int, bool)
- func WalkBindingRefs(expr ValidatedExpr, ...)
- func WalkSubExprs(expr ValidatedExpr, fn func(child ValidatedExpr, role ChildRole))
- type ChildRole
- type LetKind
- type RefRole
- type ValidatedApply
- type ValidatedBegin
- type ValidatedBodyAndParams
- type ValidatedCall
- type ValidatedCaseLambda
- type ValidatedCaseLambdaClause
- func (p *ValidatedCaseLambdaClause) Body() []ValidatedExpr
- func (p *ValidatedCaseLambdaClause) Docstring() string
- func (p *ValidatedCaseLambdaClause) FormName() string
- func (p *ValidatedCaseLambdaClause) Params() *ValidatedParams
- func (p *ValidatedCaseLambdaClause) SetFormName(nm string)
- func (p *ValidatedCaseLambdaClause) Source() *syntax.SourceContext
- type ValidatedDefine
- func (p *ValidatedDefine) Body() []ValidatedExpr
- func (p *ValidatedDefine) Docstring() string
- func (p *ValidatedDefine) FormName() string
- func (p *ValidatedDefine) Name() *syntax.SyntaxSymbol
- func (p *ValidatedDefine) Params() *ValidatedParams
- func (p *ValidatedDefine) SetFormName(nm string)
- func (p *ValidatedDefine) Source() *syntax.SourceContext
- func (p *ValidatedDefine) SubExp() ValidatedExpr
- type ValidatedDynamicWind
- type ValidatedExpr
- type ValidatedIf
- type ValidatedLambda
- type ValidatedLet
- type ValidatedLetBinding
- type ValidatedLiteral
- type ValidatedParams
- type ValidatedProcedure
- type ValidatedQuasiquote
- type ValidatedQuote
- type ValidatedSetBang
- type ValidatedSymbol
- type ValidatedWithContinuationMark
- type ValidationError
- type ValidationResult
Constants ¶
const DefaultMaxOriginDepth = 10
DefaultMaxOriginDepth is the default maximum number of macro expansions to show in error messages. Set to 0 for unlimited depth.
Variables ¶
This section is empty.
Functions ¶
func BodyIsFrameReleasable ¶ added in v1.17.0
func BodyIsFrameReleasable(proc ValidatedBodyAndParams, selfName string, env *environment.EnvironmentFrame) bool
BodyIsFrameReleasable reports whether proc's activation frame may be released to the pool at its tail calls (the OpReleaseEnvFrame optimization — fib-shaped general tail recursion). Unlike OpSelfTailCall it does NOT rebind in place or hardcode a jump: it releases the dead frame and performs a normal apply (which re-resolves the callee). So it needs neither the define's stability nor a self-tail call — only that the body can never expose its frame to a continuation:
- no capture operator in the body (no call/cc &c.),
- no escaping closure, and
- every callee is the self name or a capture-safe, non-rebindable primitive (bodyCalleesAllCaptureSafe) — a callee that could capture would pin the frame.
This is a conservative, per-body approximation of the interprocedural classifier (ClassifyFrameReclaim): it covers self-recursion over capture-safe primitives (fib, tak) but refuses a tail call to another user-defined function (mutual recursion), which the full call graph would admit. Sound either way; the call-graph precision is a later refinement.
func BodyIsSelfTailReusable ¶ added in v1.17.0
func BodyIsSelfTailReusable( proc ValidatedBodyAndParams, selfName string, env *environment.EnvironmentFrame, ) bool
BodyIsSelfTailReusable is the compiler entry point: it builds the production capture-operator identity test from env (hygiene-correct: a locally-shadowed call/cc is not the primitive) and runs the self-tail-reuse safety predicate. selfName is the closure's own bound name as a symbol Key.
NOTE: this is the IN-BODY safety half. The caller must additionally ensure the self BINDING is immutable against cross-unit redefinition — for a top-level define that means IsStable() at the emit site; for a lexical named-let loop the in-body ¬set! this predicate checks is the whole story.
func ClassifyFrameReclaim ¶ added in v1.17.0
func ClassifyFrameReclaim( unit []ValidatedExpr, env *environment.EnvironmentFrame, ) map[string]bool
ClassifyFrameReclaim returns, for every top-level function define in unit, whether its frame is reclaimable at its tail calls. It is the exported entry point over the Layer-B/C internals: build the call graph, run the greatest-fixpoint mayCapture, and project to a name→verdict map. The verdict is conservative (any uncertainty ⇒ not reclaimable).
Same-unit-define immutability is read from the producer's Stable bit via env.GetBinding(...).IsStable() — the single source of truth, backed by Option-B enforcement (the set!-gate + the cross-unit redefine guard). The tier-(a) vs tier-(b) distinction is therefore a property of WHICH env is passed, not a classifier argument: an env whose same-unit defines are NOT stamped Stable (WithImmutableTopLevel off, or a non-compiled env) yields mutable same-unit edges (tier-(a) behavior); an env whose defines ARE Stable (WithImmutableTopLevel on, compiled) yields immutable edges (tier-(b)).
PRECONDITION: env must be the post-compile env for unit (bindings stamped). An un-stamped (validate-only) env reports IsStable()==false uniformly, yielding the conservative tier-(a) verdict with no diagnostic — sound for the optimizer but a silent artifact for a measurement (guard with a positive control).
func IsCaptureSafePrimitiveName ¶ added in v1.17.0
IsCaptureSafePrimitiveName reports whether name is a core primitive the frame-reclaim classifier trusts as capture-safe — it cannot invoke a Scheme procedure or capture a continuation. This is the authoritative set for two callers: the classifier's own trust gate (classifyCallee) and the registry's WithStableBasePrimitives freeze. Only these primitives are ever trusted, so only these need stamping Stable under the optimization flag — stamping any other primitive would freeze it for no classifier benefit.
func LetBindingSelfTailReusable ¶ added in v1.17.0
func LetBindingSelfTailReusable(v *ValidatedLet, i int, env *environment.EnvironmentFrame) (int, bool)
LetBindingSelfTailReusable reports the arity and eligibility of the i-th binding of a recursively-scoped let (letrec / letrec* / named-let) for in-place self-tail reuse — the local-binding analogue of selfTailForDefine. ok is true iff
- the binding's Init is a lambda whose body is self-tail-reusable on the binding name (bodyIsSelfTailReusable), AND
- the binding name is immutable across the WHOLE let: never set! in any binding init or in the let body.
The second clause is the local immutability story. bodyIsSelfTailReusable only inspects the lambda's own body, but a sibling init or the let body could set! the name, which would make a hardcoded jump-to-pc=0 unsound. A lexical letrec binding cannot be mutated from outside the let, so set!-freedom within the let is sufficient (no IsStable() is needed, unlike a top-level define).
PRECONDITION: the caller must ensure v.Kind is recursive (letrec-family) so the lambda can see itself; in a plain let/let* the name is not in scope in the init.
func WalkBindingRefs ¶ added in v1.16.0
func WalkBindingRefs( expr ValidatedExpr, visit func(sym *syntax.SyntaxSymbol, role RefRole, depth int), )
WalkBindingRefs walks expr recursively, calling visit for every *syntax.SyntaxSymbol reference encountered, with its role and closure-nesting depth.
depth is the number of escaping closure boundaries crossed (0 = same closure as expr). Immediately-applied lambdas (ValidatedLambda or ValidatedCaseLambda as the Proc of a ValidatedCall or ValidatedApply) do NOT increment depth, since the closure does not escape.
ValidatedSetBang emits a synthetic RefSetBangTarget visit for its target name, then recurses into its value expression as a normal walk (the value's symbol references appear as RefInBody at the same depth).
Symbols are NEVER yielded with RefInClosureBody; "is this inside a closure?" is the depth > 0 predicate.
Role tagging is shallow: RefInCallProc and RefSetBangTarget are reported only on direct symbol children of the surrounding form. A symbol nested inside a non-leaf call-proc child — for example, the inner `f` and `g` in `((if c f g) x)`, or the inner symbols of `((f x) y)` — is reported as RefInBody, not RefInCallProc. The role describes the slot the symbol IS, not the slot of any enclosing non-symbol expression.
func WalkSubExprs ¶ added in v1.10.7
func WalkSubExprs(expr ValidatedExpr, fn func(child ValidatedExpr, role ChildRole))
WalkSubExprs calls fn for every direct sub-expression of expr, reporting each child's structural role:
- RoleCallProc: the operator of ValidatedCall and ValidatedApply
- RoleClosureBody: body of ValidatedLambda, ValidatedCaseLambda clause, or ValidatedDefine (function form)
- RoleNormal: everything else (arguments, inits, branches, sequence bodies)
ValidatedSetBang: walks only the value expression (RoleNormal). The set! target is mutation (tracked by Mutable), not a reference.
ValidatedSymbol has no children — fn is not called. The caller handles symbols directly before calling WalkSubExprs.
Types ¶
type ChildRole ¶ added in v1.10.7
type ChildRole int
ChildRole describes the structural position of a sub-expression within its parent validated form.
const ( // RoleNormal is the default: arguments, init expressions, branch arms, // body of begin/let/dynamic-wind/with-continuation-mark, define-variable value. RoleNormal ChildRole = iota // RoleCallProc is the operator position of ValidatedCall and ValidatedApply. RoleCallProc // RoleClosureBody is a body expression inside a closure boundary: // ValidatedLambda, ValidatedCaseLambda clause, or ValidatedDefine (function form). RoleClosureBody )
type LetKind ¶ added in v1.9.4
type LetKind int
LetKind encodes the two orthogonal dimensions of binding form semantics: init-visibility (do inits see the bindings?) and evaluation order (all-then-store vs sequential store-as-you-go).
| Kind | Inits see bindings? | Eval order | |------------|---------------------|-----------------| | Let | No (outer scope) | All-then-store | | LetStar | Preceding only | Sequential | | Letrec | All (full scope) | All-then-store | | LetrecStar | All (full scope) | Sequential |
func (LetKind) InitsInScope ¶ added in v1.9.4
InitsInScope reports whether init expressions see the let bindings.
func (LetKind) Sequential ¶ added in v1.9.4
Sequential reports whether init expressions are stored immediately (left-to-right) rather than all-then-store.
type RefRole ¶ added in v1.16.0
type RefRole int
RefRole describes the structural slot a symbol reference occupies. It is the "what role does this use play" axis, orthogonal to depth.
const ( // RefInBody is a normal-position reference: argument, return value, // init expression, branch arm, sequence body, set! value, etc. // This is the default for any non-call-proc, non-set!-target reference. RefInBody RefRole = iota // RefInCallProc is the operator position of a ValidatedCall or // ValidatedApply (the "callee" slot). RefInCallProc // RefSetBangTarget is the target name of a ValidatedSetBang (the // symbol being mutated). The value expression of the set! is walked // separately as RefInBody. RefSetBangTarget )
type ValidatedApply ¶ added in v1.5.0
type ValidatedApply struct {
Proc ValidatedExpr
PrefixArgs []ValidatedExpr
FinalList ValidatedExpr
// contains filtered or unexported fields
}
ValidatedApply represents (apply proc arg1 ... args)
R7RS §6.10: apply calls proc with the elements of the list (append (list arg1 ...) args) as arguments.
func (*ValidatedApply) FormName ¶ added in v1.5.0
func (p *ValidatedApply) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedApply) SetFormName ¶ added in v1.5.0
func (p *ValidatedApply) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedApply) Source ¶ added in v1.5.0
func (p *ValidatedApply) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedBegin ¶
type ValidatedBegin struct {
// contains filtered or unexported fields
}
ValidatedBegin represents (begin expr...)
func (*ValidatedBegin) Body ¶
func (p *ValidatedBegin) Body() []ValidatedExpr
Body returns the sequence of expressions in this begin form.
func (*ValidatedBegin) FormName ¶
func (p *ValidatedBegin) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedBegin) SetFormName ¶
func (p *ValidatedBegin) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedBegin) Source ¶
func (p *ValidatedBegin) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedBodyAndParams ¶
type ValidatedBodyAndParams interface {
Params() *ValidatedParams
Body() []ValidatedExpr
Docstring() string
}
ValidatedBodyAndParams provides access to parameters and body for procedure forms.
type ValidatedCall ¶
type ValidatedCall struct {
// contains filtered or unexported fields
}
ValidatedCall represents (proc arg...)
func (*ValidatedCall) Body ¶
func (p *ValidatedCall) Body() []ValidatedExpr
Body returns the argument expressions for this call.
func (*ValidatedCall) FormName ¶
func (p *ValidatedCall) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedCall) Proc ¶
func (p *ValidatedCall) Proc() ValidatedExpr
Proc returns the procedure expression being called.
func (*ValidatedCall) SetFormName ¶
func (p *ValidatedCall) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedCall) Source ¶
func (p *ValidatedCall) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedCaseLambda ¶
type ValidatedCaseLambda struct {
// contains filtered or unexported fields
}
ValidatedCaseLambda represents (case-lambda [clause] ...)
func (*ValidatedCaseLambda) Clauses ¶
func (p *ValidatedCaseLambda) Clauses() []*ValidatedCaseLambdaClause
Clauses returns the list of case-lambda clauses.
func (*ValidatedCaseLambda) FormName ¶
func (p *ValidatedCaseLambda) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedCaseLambda) SetFormName ¶
func (p *ValidatedCaseLambda) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedCaseLambda) Source ¶
func (p *ValidatedCaseLambda) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedCaseLambdaClause ¶
type ValidatedCaseLambdaClause struct {
// contains filtered or unexported fields
}
ValidatedCaseLambdaClause represents a single clause in case-lambda
func (*ValidatedCaseLambdaClause) Body ¶
func (p *ValidatedCaseLambdaClause) Body() []ValidatedExpr
Body returns the body expressions.
func (*ValidatedCaseLambdaClause) Docstring ¶ added in v1.10.3
func (p *ValidatedCaseLambdaClause) Docstring() string
Docstring returns the Guile-style docstring extracted from the body, or "" if no docstring was present.
func (*ValidatedCaseLambdaClause) FormName ¶
func (p *ValidatedCaseLambdaClause) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedCaseLambdaClause) Params ¶
func (p *ValidatedCaseLambdaClause) Params() *ValidatedParams
Params returns the parameter list.
func (*ValidatedCaseLambdaClause) SetFormName ¶
func (p *ValidatedCaseLambdaClause) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedCaseLambdaClause) Source ¶ added in v1.4.0
func (p *ValidatedCaseLambdaClause) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedDefine ¶
type ValidatedDefine struct {
IsFunction bool // True for (define (name ...) ...)
// StableInUnit reports that this define's name is defined exactly once and
// never set! within the compilation unit the validator saw, computed
// syntactically by symbol Key (conservative over-approximation: a same-Key
// local set! or shadowing define marks it non-stable — a false match costs
// optimization, never soundness). It is the in-unit evidence the compiler
// consumes (only for top-level/global defines) to populate
// BindingMeta.Stable when opt-in top-level immutability is enabled. Stamped
// by finalizeStability after the whole unit is validated.
StableInUnit bool
// contains filtered or unexported fields
}
ValidatedDefine represents both forms: (define name expr) and (define (name params...) body...)
func (*ValidatedDefine) Body ¶
func (p *ValidatedDefine) Body() []ValidatedExpr
Body returns the body expressions.
func (*ValidatedDefine) Docstring ¶ added in v1.10.3
func (p *ValidatedDefine) Docstring() string
Docstring returns the Guile-style docstring extracted from the body, or "" if no docstring was present.
func (*ValidatedDefine) FormName ¶
func (p *ValidatedDefine) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedDefine) Name ¶
func (p *ValidatedDefine) Name() *syntax.SyntaxSymbol
Name returns the name being defined.
func (*ValidatedDefine) Params ¶
func (p *ValidatedDefine) Params() *ValidatedParams
Params returns the parameter list.
func (*ValidatedDefine) SetFormName ¶
func (p *ValidatedDefine) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedDefine) Source ¶
func (p *ValidatedDefine) Source() *syntax.SourceContext
Source returns the source context for error reporting.
func (*ValidatedDefine) SubExp ¶
func (p *ValidatedDefine) SubExp() ValidatedExpr
SubExp returns the value expression for simple definitions.
type ValidatedDynamicWind ¶
type ValidatedDynamicWind struct {
Before ValidatedExpr
Thunk ValidatedExpr
After ValidatedExpr
// contains filtered or unexported fields
}
ValidatedDynamicWind represents (dynamic-wind before thunk after)
R7RS §6.10: dynamic-wind calls thunk without arguments, returning the result(s). Before is called whenever execution enters the dynamic extent of the call to thunk, and after is called whenever it exits.
func (*ValidatedDynamicWind) FormName ¶
func (p *ValidatedDynamicWind) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedDynamicWind) SetFormName ¶
func (p *ValidatedDynamicWind) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedDynamicWind) Source ¶
func (p *ValidatedDynamicWind) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedExpr ¶
type ValidatedExpr = forms.ValidatedExpr
ValidatedExpr is the interface for all validated expressions. The canonical definition lives in forms.ValidatedExpr to break the validate → forms ← machine import cycle.
type ValidatedIf ¶
type ValidatedIf struct {
Test ValidatedExpr
Conseq ValidatedExpr
Alt ValidatedExpr // nil if no alternative (will produce void)
// contains filtered or unexported fields
}
ValidatedIf represents (if test conseq [alt])
func (*ValidatedIf) FormName ¶
func (p *ValidatedIf) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedIf) SetFormName ¶
func (p *ValidatedIf) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedIf) Source ¶
func (p *ValidatedIf) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedLambda ¶
type ValidatedLambda struct {
// contains filtered or unexported fields
}
ValidatedLambda represents (lambda (params...) body...)
func (*ValidatedLambda) Body ¶
func (p *ValidatedLambda) Body() []ValidatedExpr
Body returns the body expressions.
func (*ValidatedLambda) Docstring ¶ added in v1.10.3
func (p *ValidatedLambda) Docstring() string
Docstring returns the Guile-style docstring extracted from the body, or "" if no docstring was present.
func (*ValidatedLambda) FormName ¶
func (p *ValidatedLambda) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedLambda) Params ¶
func (p *ValidatedLambda) Params() *ValidatedParams
Params returns the parameter list.
func (*ValidatedLambda) SetFormName ¶
func (p *ValidatedLambda) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedLambda) Source ¶
func (p *ValidatedLambda) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedLet ¶ added in v1.9.4
type ValidatedLet struct {
Kind LetKind
Bindings []ValidatedLetBinding
Tag *syntax.SyntaxSymbol
// contains filtered or unexported fields
}
ValidatedLet represents all four R7RS binding forms: let, let*, letrec, letrec*. The Kind field encodes which form this is — the type is shared because the four forms differ only in two orthogonal dimensions (init visibility and evaluation order), not in structure. Tag is non-nil for named let (compiled with letrec semantics).
func NewValidatedLet ¶ added in v1.10.7
func NewValidatedLet( formName string, source *syntax.SourceContext, kind LetKind, bindings []ValidatedLetBinding, body []ValidatedExpr, ) *ValidatedLet
NewValidatedLet constructs a ValidatedLet from pre-validated components. Used by the compiler for synthetic let forms (e.g., procedure inlining). Callers must ensure all bindings and body expressions are individually validated — this constructor does not re-validate its inputs.
This is the only exported constructor in the validate package. Other validated types are constructed exclusively within the package. Add exported constructors for other types only when an external consumer requires them.
func (*ValidatedLet) Body ¶ added in v1.9.4
func (p *ValidatedLet) Body() []ValidatedExpr
Body returns the body expressions.
func (*ValidatedLet) FormName ¶ added in v1.9.4
func (p *ValidatedLet) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedLet) SetFormName ¶ added in v1.9.4
func (p *ValidatedLet) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedLet) Source ¶ added in v1.9.4
func (p *ValidatedLet) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedLetBinding ¶ added in v1.9.4
type ValidatedLetBinding struct {
Name *syntax.SyntaxSymbol
Init ValidatedExpr
Mutable bool
Escapes bool
}
ValidatedLetBinding represents a single (name init-expr) binding pair. Mutable is true if the binding is targeted by set! in the body. Escapes is true if the binding is referenced in a non-call position.
type ValidatedLiteral ¶
type ValidatedLiteral struct {
Value syntax.SyntaxValue
// contains filtered or unexported fields
}
ValidatedLiteral represents self-evaluating data (numbers, strings, booleans, etc.) It's also used for passthrough forms like define-syntax, syntax-case, etc.
func (*ValidatedLiteral) FormName ¶
func (p *ValidatedLiteral) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedLiteral) SetFormName ¶
func (p *ValidatedLiteral) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedLiteral) Source ¶
func (p *ValidatedLiteral) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedParams ¶
type ValidatedParams struct {
Required []*syntax.SyntaxSymbol
Rest *syntax.SyntaxSymbol // nil if no rest parameter
// contains filtered or unexported fields
}
ValidatedParams represents a parameter list Handles: (a b c), (a b . rest), and just rest
type ValidatedProcedure ¶
type ValidatedProcedure interface {
ValidatedExpr
ValidatedBodyAndParams
}
ValidatedProcedure represents a validated procedure form with parameters and body.
type ValidatedQuasiquote ¶
type ValidatedQuasiquote struct {
Template syntax.SyntaxValue // The raw template - quasiquote has complex runtime semantics
// contains filtered or unexported fields
}
ValidatedQuasiquote represents (quasiquote template)
func (*ValidatedQuasiquote) FormName ¶
func (p *ValidatedQuasiquote) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedQuasiquote) SetFormName ¶
func (p *ValidatedQuasiquote) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedQuasiquote) Source ¶
func (p *ValidatedQuasiquote) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedQuote ¶
type ValidatedQuote struct {
Datum syntax.SyntaxValue
// contains filtered or unexported fields
}
ValidatedQuote represents (quote datum)
func (*ValidatedQuote) FormName ¶
func (p *ValidatedQuote) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedQuote) SetFormName ¶
func (p *ValidatedQuote) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedQuote) Source ¶
func (p *ValidatedQuote) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedSetBang ¶
type ValidatedSetBang struct {
Name *syntax.SyntaxSymbol
// contains filtered or unexported fields
}
ValidatedSetBang represents (set! name expr)
func (*ValidatedSetBang) FormName ¶
func (p *ValidatedSetBang) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedSetBang) SetFormName ¶
func (p *ValidatedSetBang) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedSetBang) Source ¶
func (p *ValidatedSetBang) Source() *syntax.SourceContext
Source returns the source context for error reporting.
func (*ValidatedSetBang) SubExp ¶
func (p *ValidatedSetBang) SubExp() ValidatedExpr
SubExp returns the value expression to be assigned.
type ValidatedSymbol ¶
type ValidatedSymbol struct {
Symbol *syntax.SyntaxSymbol
// contains filtered or unexported fields
}
ValidatedSymbol represents a variable reference
func (*ValidatedSymbol) FormName ¶
func (p *ValidatedSymbol) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedSymbol) SetFormName ¶
func (p *ValidatedSymbol) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedSymbol) Source ¶
func (p *ValidatedSymbol) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidatedWithContinuationMark ¶ added in v1.7.0
type ValidatedWithContinuationMark struct {
Key ValidatedExpr
Val ValidatedExpr
Body ValidatedExpr
// contains filtered or unexported fields
}
ValidatedWithContinuationMark represents (with-continuation-mark key val body)
Sets a continuation mark on the current frame during body evaluation. In tail position, the mark replaces any existing mark with the same key on the current frame. In non-tail position, the mark is removed after body completes.
func (*ValidatedWithContinuationMark) FormName ¶ added in v1.7.0
func (p *ValidatedWithContinuationMark) FormName() string
FormName returns the name of the form for error messages.
func (*ValidatedWithContinuationMark) SetFormName ¶ added in v1.7.0
func (p *ValidatedWithContinuationMark) SetFormName(nm string)
SetFormName sets the form name for error messages.
func (*ValidatedWithContinuationMark) Source ¶ added in v1.7.0
func (p *ValidatedWithContinuationMark) Source() *syntax.SourceContext
Source returns the source context for error reporting.
type ValidationError ¶
type ValidationError struct {
Source *syntax.SourceContext
Message string
Form string // p.g., "if", "define", "lambda"
}
ValidationError captures location and details for error reporting
func (ValidationError) Error ¶
func (p ValidationError) Error() string
func (ValidationError) ErrorWithMaxOriginDepth ¶
func (p ValidationError) ErrorWithMaxOriginDepth(maxDepth int) string
ErrorWithMaxOriginDepth returns the error message with a configurable origin chain depth.
type ValidationResult ¶
type ValidationResult struct {
Expr ValidatedExpr // nil if validation failed
Errors []ValidationError // All errors encountered
// contains filtered or unexported fields
}
ValidationResult collects all errors from validation
func ValidateExpression ¶
func ValidateExpression(ctx context.Context, env *environment.EnvironmentFrame, expr syntax.SyntaxValue) *ValidationResult
ValidateExpression validates a syntax expression and returns a validated form or a list of errors. The env parameter provides the environment context for checking local variable shadowing of special forms (R7RS §4.2.2).
func (*ValidationResult) Error ¶
func (p *ValidationResult) Error() string
func (*ValidationResult) Ok ¶
func (p *ValidationResult) Ok() bool
Ok returns true if no validation errors were encountered.
Source Files
¶
- capture_operator.go
- doc.go
- env_helpers.go
- errors.go
- frame_reclaim.go
- frame_reclaim_build.go
- register.go
- self_tail.go
- validate.go
- validate_apply.go
- validate_begin.go
- validate_call.go
- validate_case_lambda.go
- validate_cont_mark.go
- validate_define.go
- validate_dynamic_wind.go
- validate_escape.go
- validate_if.go
- validate_lambda.go
- validate_let.go
- validate_macro.go
- validate_quote.go
- validate_set.go
- validated_forms.go
- walk_binding_refs.go
- walk_sub_exprs.go