Documentation
¶
Index ¶
- func SourceError(pos Position, format string, args ...any) error
- type AssertExpr
- type AtomExpr
- type ConditionalExpr
- type Expr
- type FallbackExpr
- type Lexer
- type LoopExpr
- type MapEntry
- type NeedsPipelineError
- type Node
- type ParallelExpr
- type Parser
- type PipelineExpr
- type Position
- type ProjectionExpr
- type Token
- type TokenType
- type Value
- type ValueKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SourceError ¶ added in v0.8.0
SourceError formats a parse- or compile-time error with a source position. Every message has the shape "file:line:col: msg", the same convention used by go/parser and gopls, so editors and human readers both get the familiar format.
The error kind is BadRequest, which every transport in the Nexss ecosystem maps to HTTP 400 without further inspection.
Types ¶
type AssertExpr ¶ added in v0.8.0
type AtomExpr ¶
type AtomExpr struct {
Name string
Profile string
Prompt string
Targets []string
Excludes []string
Params map[string]string // from (key=value) — literal strings
Inputs map[string]string // from (key=value) where value has a dot
Args map[string]*Value // from @{ key: value } — typed
Modifiers []string
}
AtomExpr is a single action reference in the pipeline.
Modifiers come from the `:key=value` syntax. Params and Inputs come from the older `(key=value, ...)` syntax and remain for backward compatibility. Args come from `@{ key: value }` and carry full typed structure (see Value).
type ConditionalExpr ¶
ConditionalExpr is `gate ? target` or `gate ? target : else`. Else is nil in the two-arm form.
type FallbackExpr ¶
type NeedsPipelineError ¶ added in v0.8.0
type NeedsPipelineError struct {
Reason string
}
NeedsPipelineError is returned by ParseArrowDSL when the AST contains a construct the static DAG model cannot represent.
The three constructs that trigger it are loop(), conditional (? :), and fallback (||). They are runtime compositions, not graph topology: a DAG is by definition acyclic and cannot encode an unbounded loop, a data-dependent branch, or a try-then-else chain. CompilePipeline handles all three by composing actions, so callers that can execute a composed action should detect this error and fall back.
Callers should use errors.As to test for this type:
var npe *compiler.NeedsPipelineError
if errors.As(err, &npe) {
// fall back to CompilePipeline
}
func (*NeedsPipelineError) Error ¶ added in v0.8.0
func (e *NeedsPipelineError) Error() string
type ParallelExpr ¶
type ParallelExpr struct {
Children []Expr
}
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser walks the token stream produced by Lexer and builds an AST.
The parser is split across four files:
parser.go — Parser struct, token advance, entry points
parser_precedence.go — the operator precedence chain
parser_atom.go — atoms, modifiers, ternary-colon detection
parser_blocks.go — brace / paren / bracket scanning, projections,
loops, asserts
The split mirrors the grammar: each file owns one level of the language.
func NewParserWithFile ¶ added in v0.8.0
func (*Parser) ParseExpression ¶
ParseExpression parses a complete pipeline expression and requires that the token stream is exhausted when it returns.
type PipelineExpr ¶
type Position ¶ added in v0.8.0
Position identifies a source location inside a .nflow file. It is the lowest-level error-position type in the flow stack; higher layers (flow, runner) re-export it so callers do not need to import compiler directly.
type ProjectionExpr ¶
type ProjectionExpr struct {
Raw string
}
type TokenType ¶
type TokenType int
const ( TokenEOF TokenType = iota TokenIdent TokenString TokenNumber TokenArrow TokenPipe TokenOr TokenAmpersand TokenLParen TokenRParen TokenLBrace TokenRBrace TokenQuestion TokenColon TokenAssign TokenAtPrompt // @text — free-form prompt annotation TokenAtBrace // @{...} — structural inline arguments TokenHash TokenTilde TokenComma TokenLBracket // [ TokenRBracket // ] TokenInvalid )
type Value ¶ added in v0.8.0
type Value struct {
Kind ValueKind
Str string // ValueString
Num float64 // ValueNumber
Bool bool // ValueBool
Ref string // ValueRef: "user.name" (leading dot stripped)
Map []MapEntry // ValueMap: ordered, so error messages and diffs are stable
Slice []*Value // ValueSlice
}
Value is a typed value inside an @{} block. It is the compile-time representation of a DSL argument: at execution the parser resolves it into a concrete Go value (string, float64, bool, map[string]any, []any, or a reference looked up in the pipeline state).
func (*Value) IsWholeStateRef ¶ added in v0.8.0
IsWholeStateRef reports whether this value is a bare "." reference, meaning "the entire state as it arrived". The compiler treats this specially: it snapshots the state before injecting other args, so the reference never captures a self-modifying map.