rl

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Node Kinds
	K_COMMENT                  = "comment"
	K_SOURCE_FILE              = "source_file"
	K_SHEBANG                  = "shebang"
	K_FILE_HEADER              = "file_header"
	K_ARG_BLOCK                = "arg_block"
	K_CMD_BLOCK                = "cmd_block"
	K_CMD_DESCRIPTION          = "cmd_description"
	K_CMD_DESCRIPTION_CONTENTS = "cmd_description_contents"
	K_CMD_CALLS                = "cmd_calls"
	K_ASSIGN                   = "assign"
	K_CATCH_BLOCK              = "catch_block"
	K_EXPR                     = "expr"
	K_EXPR_STMT                = "expr_stmt"
	K_PRIMARY_EXPR             = "primary_expr"
	K_PARENTHESIZED_EXPR       = "parenthesized_expr"
	K_LITERAL                  = "literal"
	K_VAR_PATH                 = "var_path"
	K_INT                      = "int"
	K_BOOL                     = "bool"
	K_FLOAT                    = "float"
	K_SCIENTIFIC_NUMBER        = "scientific_number"
	K_LIST                     = "list"
	K_NULL                     = "null"
	K_CALL                     = "call"
	K_OR_EXPR                  = "or_expr"
	K_AND_EXPR                 = "and_expr"
	K_COMPARE_EXPR             = "compare_expr"
	K_ADD_EXPR                 = "add_expr"
	K_MULT_EXPR                = "mult_expr"
	K_UNARY_EXPR               = "unary_expr"
	K_FALLBACK_EXPR            = "fallback_expr"
	K_CATCH_EXPR               = "catch_expr"
	K_INDEXED_EXPR             = "indexed_expr"
	K_STRING                   = "string"
	K_STRING_CONTENT           = "string_content"
	K_BACKSLASH                = "\\"
	K_ESC_BACKSLASH            = "esc_backslash"
	K_ESC_SINGLE_QUOTE         = "esc_single_quote"
	K_ESC_DOUBLE_QUOTE         = "esc_double_quote"
	K_ESC_BACKTICK             = "esc_backtick"
	K_ESC_NEWLINE              = "esc_newline"
	K_ESC_TAB                  = "esc_tab"
	K_ESC_OPEN_BRACKET         = "esc_open_bracket"
	K_INTERPOLATION            = "interpolation"
	K_FILL_ALIGNMENT           = "fill_alignment"
	K_MAP                      = "map"
	K_IDENTIFIER               = "identifier"
	K_COMPOUND_ASSIGN          = "compound_assign"
	K_PLUS_EQUAL               = "+="
	K_MINUS_EQUAL              = "-="
	K_STAR_EQUAL               = "*="
	K_SLASH_EQUAL              = "/="
	K_PERCENT_EQUAL            = "%="
	K_PLUS                     = "+"
	K_MINUS                    = "-"
	K_NOT                      = "not"
	K_IF_STMT                  = "if_stmt"
	K_BREAK_STMT               = "break_stmt"
	K_CONTINUE_STMT            = "continue_stmt"
	K_FOR_LOOP                 = "for_loop"
	K_WHILE_LOOP               = "while_loop"
	K_DEFER_BLOCK              = "defer_block"
	K_SLICE                    = "slice"
	K_SHELL_STMT               = "shell_stmt"
	K_SHELL_CMD                = "shell_cmd"
	K_DEL_STMT                 = "del_stmt"
	K_JSON_PATH                = "json_path"
	K_RAD_BLOCK                = "rad_block"
	K_RAD_FIELD_STMT           = "rad_field_stmt"
	K_RAD_SORT_STMT            = "rad_sort_stmt"
	K_RAD_SORT_SPECIFIER       = "rad_sort_specifier"
	K_ASC                      = "asc"
	K_DESC                     = "desc"
	K_RAD_FIELD_MODIFIER_STMT  = "rad_field_modifier_stmt"
	K_RAD_FIELD_MOD_COLOR      = "rad_field_mod_color"
	K_RAD_FIELD_MOD_MAP        = "rad_field_mod_map"
	K_RAD_FIELD_MOD_FILTER     = "rad_field_mod_filter"
	K_RAD_IF_STMT              = "rad_if_stmt"
	K_RAD_OPTION_STMT          = "rad_option_stmt"
	K_LIST_COMPREHENSION       = "list_comprehension"
	K_ERROR                    = "ERROR"
	K_INCR_DECR                = "incr_decr"
	K_PLUS_PLUS                = "++"
	K_MINUS_MINUS              = "--"
	K_TERNARY_EXPR             = "ternary_expr"
	K_SWITCH_STMT              = "switch_stmt"
	K_SWITCH_CASE_EXPR         = "switch_case_expr"
	K_SWITCH_CASE_BLOCK        = "switch_case_block"
	K_FN_LAMBDA                = "fn_lambda"
	K_PASS                     = "pass_stmt"
	K_FN_NAMED                 = "fn_named"
	K_RETURN_STMT              = "return_stmt"
	K_YIELD_STMT               = "yield_stmt"
	K_STRING_TYPE              = "string_type"
	K_INT_TYPE                 = "int_type"
	K_FLOAT_TYPE               = "float_type"
	K_BOOL_TYPE                = "bool_type"
	K_LIST_TYPE                = "list_type"
	K_ERROR_TYPE               = "error_type"
	K_ANY_TYPE                 = "any_type"
	K_VOID_TYPE                = "void_type"
	K_FN_TYPE                  = "fn_type"
	K_MAP_TYPE                 = "map_type"
	K_MAP_ENTRY_TYPE           = "map_entry_type"

	// Field names
	F_LEFT                = "left"
	F_LEFTS               = "lefts"
	F_RIGHT               = "right"
	F_ROOT                = "root"
	F_INDEXING            = "indexing"
	F_INDEX               = "index"
	F_LIST_ENTRY          = "list_entry"
	F_FUNC                = "func"
	F_ARG                 = "arg"
	F_NAMED_ARG           = "named_arg"
	F_OP                  = "op"
	F_CONTENTS            = "contents"
	F_EXPR                = "expr"
	F_FORMAT              = "format"
	F_THOUSANDS_SEPARATOR = "thousands_separator"
	F_ALIGNMENT           = "alignment"
	F_FILL_ALIGNMENT      = "fill_alignment"
	F_PADDING             = "padding"
	F_PRECISION           = "precision"
	F_MAP_ENTRY           = "map_entry"
	F_KEY                 = "key"
	F_VALUE               = "value"
	F_ALT                 = "alt"
	F_CONDITION           = "condition"
	F_STMT                = "stmt"
	F_KEYWORD             = "keyword"
	F_START               = "start"
	F_END                 = "end"
	F_SHELL_CMD           = "shell_cmd"
	F_MODIFIER            = "modifier"
	F_QUIET_MOD           = "quiet_mod"
	F_CONFIRM_MOD         = "confirm_mod"
	F_COMMAND             = "command"
	F_SEGMENT             = "segment"
	F_SOURCE              = "source"
	F_RAD_TYPE            = "rad_type"
	F_IDENTIFIER          = "identifier"
	F_SPECIFIER           = "specifier"
	F_MOD_STMT            = "mod_stmt"
	F_COLOR               = "color"
	F_REGEX               = "regex"
	F_LAMBDA              = "lambda"
	F_TRUE_BRANCH         = "true_branch"
	F_FALSE_BRANCH        = "false_branch"
	F_NAME                = "name"
	F_FIRST               = "first"
	F_SECOND              = "second"
	F_DISCRIMINANT        = "discriminant"
	F_CASE                = "case"
	F_CASE_KEY            = "case_key"
	F_DEFAULT             = "default"
	F_YIELD_STMT          = "yield_stmt"
	F_RETURN_STMT         = "return_stmt"
	F_DELEGATE            = "delegate"
	F_PARAM               = "param"
	F_METADATA_ENTRY      = "metadata_entry"
	F_BLOCK_COLON         = "block_colon"
	F_CATCH               = "catch"
	F_TYPE                = "type"
	F_RETURN_TYPE         = "return_type"
	F_VARARG_MARKER       = "vararg_marker"
	F_VARIADIC_MARKER     = "variadic_marker" // todo merge with above
	F_OPTIONAL            = "optional"
	F_LEAF_TYPE           = "leaf_type"
	F_ANY                 = "any"
	F_ENUM                = "enum"
	F_NAMED_ENTRY         = "named_entry"
	F_KEY_NAME            = "key_name"
	F_KEY_TYPE            = "key_type"
	F_VALUE_TYPE          = "value_type"
	F_LIST                = "list"
	F_NORMAL_PARAM        = "normal_param"
	F_NAMED_ONLY_PARAM    = "named_only_param"
	F_VARARG_PARAM        = "vararg_param"
	F_CALLBACK_IDENTIFIER = "callback_identifier"
	F_CALLBACK_LAMBDA     = "callback_lambda"
	F_DESCRIPTION         = "description"
	F_CALLS               = "calls"
	F_CONTEXT             = "context"

	// Keywords
	KEYWORD_ASC      = "asc"
	KEYWORD_DESC     = "desc"
	KEYWORD_RAD      = "rad"
	KEYWORD_REQUEST  = "request" // deprecated, kept for migration diagnostics
	KEYWORD_DISPLAY  = "display" // deprecated, kept for migration diagnostics
	KEYWORD_INSECURE = "insecure"
	KEYWORD_QUIET    = "quiet"
	KEYWORD_NOPRINT  = "noprint"

	// Types
	T_STR        = "str"
	T_STR_LIST   = "str[]"
	T_INT        = "int"
	T_INT_LIST   = "int[]"
	T_FLOAT      = "float"
	T_FLOAT_LIST = "float[]"
	T_BOOL       = "bool"
	T_BOOL_LIST  = "bool[]"
	T_ERROR      = "error"
	T_ANY        = "any"
	T_VOID       = "void"
	T_LIST       = "list"
	T_MAP        = "map"
)
View Source
const (
	// 1xxxx Syntax Errors
	ErrInvalidSyntax       Error = "10001"
	ErrMissingColon        Error = "10002"
	ErrMissingIdentifier   Error = "10003"
	ErrMissingExpression   Error = "10004"
	ErrMissingCloseParen   Error = "10005"
	ErrMissingCloseBracket Error = "10006"
	ErrMissingCloseBrace   Error = "10007"
	ErrReservedKeyword     Error = "10008"
	ErrUnexpectedToken     Error = "10009"
	ErrMissingOpenParen    Error = "10010"
	ErrMissingOpenBracket  Error = "10011"
	ErrMissingOpenBrace    Error = "10012"
	ErrMissingComma        Error = "10013"
	ErrMissingEquals       Error = "10014"
	ErrMissingArrow        Error = "10015"
	ErrMissingType         Error = "10016"
	ErrMissingNewline      Error = "10017"
	ErrMissingIndent       Error = "10018"
	ErrUnexpectedIndent    Error = "10019"
	ErrUnterminatedString  Error = "10020"
	ErrMissingOperator     Error = "10021"
	ErrKeywordMisuse       Error = "10022"

	// 2xxxx Runtime Errors
	ErrGenericRuntime       Error = "20000"
	ErrParseIntFailed       Error = "20001"
	ErrParseFloatFailed           = "20002"
	ErrFileRead                   = "20003"
	ErrFileNoPermission           = "20004"
	ErrFileNoExist                = "20005"
	ErrFileWrite                  = "20006"
	ErrAmbiguousEpoch             = "20007"
	ErrInvalidTimeUnit            = "20008"
	ErrInvalidTimeZone            = "20009"
	ErrUserInput                  = "20010"
	ErrParseJson                  = "20011"
	ErrBugTypeCheck               = "20012"
	ErrFileWalk                   = "20013"
	ErrMutualExclArgs             = "20014"
	ErrZipStrict                  = "20015"
	ErrCast                       = "20016"
	ErrNumInvalidRange            = "20017"
	ErrEmptyList                  = "20018"
	ErrArgsContradict             = "20019"
	ErrFid                        = "20020"
	ErrDecode                     = "20021"
	ErrNoStashId                  = "20022"
	ErrSleepStr                   = "20023"
	ErrInvalidRegex               = "20024"
	ErrColorizeValNotInEnum       = "20025"
	ErrStdinRead                  = "20026"
	ErrInvalidCheckDuration       = "20027"
	ErrUndefinedVariable          = "20028"
	ErrIndexOutOfBounds           = "20029"
	ErrBreakOutsideLoop           = "20030"
	ErrContinueOutsideLoop        = "20031"
	ErrNotIterable                = "20032"
	ErrUnpackMismatch             = "20033"
	ErrSwitchNoMatch              = "20034"
	ErrSwitchMultipleMatch        = "20035"
	ErrDivisionByZero             = "20036"
	ErrNegativeIndex              = "20037"
	ErrVoidValue                  = "20038"
	ErrUnsupportedOperation       = "20039"
	ErrAssertionFailed            = "20040"
	ErrKeyNotFound                = "20041"
	ErrInternalBug                = "20042"
	ErrParseDuration              = "20043"
	ErrParseDate                  = "20044"

	// 3xxxx Type Errors
	ErrTypeMismatch     Error = "30001"
	ErrInvalidTypeForOp Error = "30002"
	ErrCannotFormat     Error = "30003"
	ErrCannotIndex      Error = "30004"
	ErrCannotAssign     Error = "30005"
	ErrInvalidArgType   Error = "30006"
	ErrWrongArgCount    Error = "30007"
	ErrCannotCompare    Error = "30008"
	ErrCannotConvert    Error = "30009"

	// 4xxxx Validation Errors
	ErrScientificNotationNotWholeNumber Error = "40001"
	ErrHoistedFunctionShadowsArgument   Error = "40002"
	ErrUnknownFunction                  Error = "40003"
	ErrReturnOutsideFunction            Error = "40004"
	ErrYieldOutsideFunction             Error = "40005"
	ErrInvalidAssignmentTarget          Error = "40006"
	ErrRadOptionNoEffect                Error = "40007"
	ErrDeprecatedBlockKeyword           Error = "40008"
)

note to reader: I am currently very inconsistently applying these errors. still debating if we should them, feel free to ignore if you're implementing something. Note: when adding here, update the reference! docs-web/docs/reference/errors.md

Variables

This section is empty.

Functions

func AstDump added in v0.9.0

func AstDump(node Node) string

AstDump produces a human-readable tree representation of an AST.

func GetChild

func GetChild(node *ts.Node, fieldName string) *ts.Node

func GetChildren

func GetChildren(node *ts.Node, fieldName string) []ts.Node

func GetSrc

func GetSrc(node *ts.Node, src string) string

Types

type ASTDefault added in v0.9.0

type ASTDefault struct {
	Node Node
	Src  string
}

ASTDefault holds an AST node and source for a function parameter default value.

type ArgBlock added in v0.9.0

type ArgBlock struct {
	Decls            []ArgDecl
	EnumConstraints  map[string]*ArgEnumConstraint
	RegexConstraints map[string]*ArgRegexConstraint
	RangeConstraints map[string]*ArgRangeConstraint
	Requirements     []ArgRelation
	Exclusions       []ArgRelation
	// contains filtered or unexported fields
}

ArgBlock represents the top-level args: block.

func NewArgBlock added in v0.9.0

func NewArgBlock(span Span, decls []ArgDecl) *ArgBlock

func (*ArgBlock) Children added in v0.9.0

func (n *ArgBlock) Children() []Node

func (*ArgBlock) Kind added in v0.9.0

func (n *ArgBlock) Kind() NodeKind

func (*ArgBlock) Span added in v0.9.0

func (n *ArgBlock) Span() Span

type ArgDecl added in v0.9.0

type ArgDecl struct {
	Name       string
	TypeName   string // "int", "str", "int[]", etc.
	IsOptional bool
	IsVariadic bool
	Rename     *string
	Shorthand  *string
	Default    Node // expression node or nil
	Comment    *string
	// Pre-parsed typed default values for metadata consumers
	DefaultString     *string
	DefaultInt        *int64
	DefaultFloat      *float64
	DefaultBool       *bool
	DefaultStringList *[]string
	DefaultIntList    *[]int64
	DefaultFloatList  *[]float64
	DefaultBoolList   *[]bool
	// contains filtered or unexported fields
}

ArgDecl represents a single arg declaration (e.g. "name str? = "default").

func NewArgDecl added in v0.9.0

func NewArgDecl(span Span, name, typeName string) *ArgDecl

func (*ArgDecl) Children added in v0.9.0

func (n *ArgDecl) Children() []Node

func (*ArgDecl) ExternalName added in v0.9.0

func (n *ArgDecl) ExternalName() string

ExternalName returns the CLI-visible name (hyphenated form), or the rename if set.

func (*ArgDecl) Kind added in v0.9.0

func (n *ArgDecl) Kind() NodeKind

func (*ArgDecl) Span added in v0.9.0

func (n *ArgDecl) Span() Span

type ArgEnumConstraint added in v0.9.0

type ArgEnumConstraint struct {
	Span_  Span
	Values []string
}

ArgEnumConstraint restricts an arg to a set of string values.

type ArgRangeConstraint added in v0.9.0

type ArgRangeConstraint struct {
	Span_       Span
	OpenerToken string // "[" or "("
	CloserToken string // "]" or ")"
	Min         *float64
	Max         *float64
}

ArgRangeConstraint restricts an arg to a numeric range.

type ArgRegexConstraint added in v0.9.0

type ArgRegexConstraint struct {
	Span_ Span
	Value string
}

ArgRegexConstraint restricts an arg value to match a regex.

type ArgRelation added in v0.9.0

type ArgRelation struct {
	Span_    Span
	Arg      string
	IsMutual bool
	Related  []string // required or excluded arg names
}

ArgRelation represents a requires or excludes relation between args.

type Assign added in v0.9.0

type Assign struct {
	Targets         []Node      // left-hand sides (var paths)
	Values          []Node      // right-hand sides
	IsUnpacking     bool        // true if `a, b = ...` syntax
	UpdateEnclosing bool        // true for compound assign/incr-decr (updates enclosing scope)
	Catch           *CatchBlock // optional catch block
	// contains filtered or unexported fields
}

Assign handles simple assignment, unpacking, and desugared compound assign (+=) and increment/decrement (++).

func NewAssign added in v0.9.0

func NewAssign(span Span, targets, values []Node, isUnpacking bool, catch *CatchBlock) *Assign

func (*Assign) Children added in v0.9.0

func (n *Assign) Children() []Node

func (*Assign) Kind added in v0.9.0

func (n *Assign) Kind() NodeKind

func (*Assign) Span added in v0.9.0

func (n *Assign) Span() Span

type Break added in v0.9.0

type Break struct {
	// contains filtered or unexported fields
}

Break represents a break statement.

func NewBreak added in v0.9.0

func NewBreak(span Span) *Break

func (*Break) Children added in v0.9.0

func (n *Break) Children() []Node

Leaf nodes - no children.

func (*Break) Kind added in v0.9.0

func (n *Break) Kind() NodeKind

func (*Break) Span added in v0.9.0

func (n *Break) Span() Span

type Call added in v0.9.0

type Call struct {
	Func      Node           // the function expression
	Args      []Node         // positional arguments
	NamedArgs []CallNamedArg // named arguments
	// contains filtered or unexported fields
}

Call represents a function call.

func NewCall added in v0.9.0

func NewCall(span Span, fn Node, args []Node, namedArgs []CallNamedArg) *Call

func (*Call) Children added in v0.9.0

func (n *Call) Children() []Node

func (*Call) Kind added in v0.9.0

func (n *Call) Kind() NodeKind

func (*Call) Span added in v0.9.0

func (n *Call) Span() Span

type CallNamedArg added in v0.9.0

type CallNamedArg struct {
	Name      string
	NameSpan  Span // span of the argument name
	Value     Node
	ValueSpan Span // span of the argument value
}

CallNamedArg is a named argument in a function call.

type CatchBlock added in v0.9.0

type CatchBlock struct {
	Stmts []Node
	// contains filtered or unexported fields
}

CatchBlock represents an error-catching block attached to a statement.

func NewCatchBlock added in v0.9.0

func NewCatchBlock(span Span, stmts []Node) *CatchBlock

func (*CatchBlock) Span added in v0.9.0

func (n *CatchBlock) Span() Span

type CatchExpr added in v0.9.0

type CatchExpr struct {
	Left  Node
	Right Node
	// contains filtered or unexported fields
}

CatchExpr represents the error-catching operator (left catch right). Unlike Fallback (??), CatchExpr only catches errors, not null values.

func NewCatchExpr added in v0.9.0

func NewCatchExpr(span Span, left, right Node) *CatchExpr

func (*CatchExpr) Children added in v0.9.0

func (n *CatchExpr) Children() []Node

func (*CatchExpr) Kind added in v0.9.0

func (n *CatchExpr) Kind() NodeKind

func (*CatchExpr) Span added in v0.9.0

func (n *CatchExpr) Span() Span

type CmdBlock added in v0.9.0

type CmdBlock struct {
	Name             string
	Description      *string
	Decls            []ArgDecl
	EnumConstraints  map[string]*ArgEnumConstraint
	RegexConstraints map[string]*ArgRegexConstraint
	RangeConstraints map[string]*ArgRangeConstraint
	Requirements     []ArgRelation
	Exclusions       []ArgRelation
	Callback         CmdCallback
	// contains filtered or unexported fields
}

CmdBlock represents a command definition block.

func NewCmdBlock added in v0.9.0

func NewCmdBlock(span Span, name string) *CmdBlock

func (*CmdBlock) Children added in v0.9.0

func (n *CmdBlock) Children() []Node

func (*CmdBlock) Kind added in v0.9.0

func (n *CmdBlock) Kind() NodeKind

func (*CmdBlock) Span added in v0.9.0

func (n *CmdBlock) Span() Span

type CmdCallback added in v0.9.0

type CmdCallback struct {
	Span_          Span
	IsLambda       bool
	IdentifierName *string
	IdentifierSpan *Span
	Lambda         *Lambda
}

CmdCallback represents a command's callback - either a function name or inline lambda.

type Continue added in v0.9.0

type Continue struct {
	// contains filtered or unexported fields
}

Continue represents a continue statement.

func NewContinue added in v0.9.0

func NewContinue(span Span) *Continue

func (*Continue) Children added in v0.9.0

func (n *Continue) Children() []Node

func (*Continue) Kind added in v0.9.0

func (n *Continue) Kind() NodeKind

func (*Continue) Span added in v0.9.0

func (n *Continue) Span() Span

type Defer added in v0.9.0

type Defer struct {
	IsErrDefer bool   // true for errdefer
	Body       []Node // deferred statements
	// contains filtered or unexported fields
}

Defer represents a defer or errdefer block.

func NewDefer added in v0.9.0

func NewDefer(span Span, isErrDefer bool, body []Node) *Defer

func (*Defer) Children added in v0.9.0

func (n *Defer) Children() []Node

func (*Defer) Kind added in v0.9.0

func (n *Defer) Kind() NodeKind

func (*Defer) Span added in v0.9.0

func (n *Defer) Span() Span

type Del added in v0.9.0

type Del struct {
	Targets []Node // var paths to delete
	// contains filtered or unexported fields
}

Del represents a del statement.

func NewDel added in v0.9.0

func NewDel(span Span, targets []Node) *Del

func (*Del) Children added in v0.9.0

func (n *Del) Children() []Node

func (*Del) Kind added in v0.9.0

func (n *Del) Kind() NodeKind

func (*Del) Span added in v0.9.0

func (n *Del) Span() Span

type Error

type Error string

func (Error) String

func (e Error) String() string

type ExprStmt added in v0.9.0

type ExprStmt struct {
	Expr  Node
	Catch *CatchBlock
	// contains filtered or unexported fields
}

ExprStmt wraps an expression used as a statement.

func NewExprStmt added in v0.9.0

func NewExprStmt(span Span, expr Node, catch *CatchBlock) *ExprStmt

func (*ExprStmt) Children added in v0.9.0

func (n *ExprStmt) Children() []Node

func (*ExprStmt) Kind added in v0.9.0

func (n *ExprStmt) Kind() NodeKind

func (*ExprStmt) Span added in v0.9.0

func (n *ExprStmt) Span() Span

type Fallback added in v0.9.0

type Fallback struct {
	Left  Node
	Right Node
	// contains filtered or unexported fields
}

Fallback represents the null-coalescing operator (left ?? right).

func NewFallback added in v0.9.0

func NewFallback(span Span, left, right Node) *Fallback

func (*Fallback) Children added in v0.9.0

func (n *Fallback) Children() []Node

func (*Fallback) Kind added in v0.9.0

func (n *Fallback) Kind() NodeKind

func (*Fallback) Span added in v0.9.0

func (n *Fallback) Span() Span

type FileHeader added in v0.9.0

type FileHeader struct {
	Contents        string
	MetadataEntries map[string]string
	// contains filtered or unexported fields
}

FileHeader represents the --- block with description and metadata entries.

func NewFileHeader added in v0.9.0

func NewFileHeader(span Span, contents string, metadata map[string]string) *FileHeader

func (*FileHeader) Children added in v0.9.0

func (n *FileHeader) Children() []Node

func (*FileHeader) Kind added in v0.9.0

func (n *FileHeader) Kind() NodeKind

func (*FileHeader) Span added in v0.9.0

func (n *FileHeader) Span() Span

type FnDef added in v0.9.0

type FnDef struct {
	Name    string
	Typing  *TypingFnT // parameter types and return type
	Body    []Node
	IsBlock bool // block function (uses return stmt) vs expression function
	DefSpan Span // span of the keyword or name for error reporting
	// contains filtered or unexported fields
}

FnDef represents a named function definition.

func NewFnDef added in v0.9.0

func NewFnDef(span Span, name string, typing *TypingFnT, body []Node, isBlock bool, defSpan Span) *FnDef

func (*FnDef) Children added in v0.9.0

func (n *FnDef) Children() []Node

func (*FnDef) Kind added in v0.9.0

func (n *FnDef) Kind() NodeKind

func (*FnDef) Span added in v0.9.0

func (n *FnDef) Span() Span

type ForLoop added in v0.9.0

type ForLoop struct {
	Vars    []string // loop variable names
	Iter    Node     // the iterable expression
	Body    []Node   // statement list
	Context *string  // optional "with x" context name
	// contains filtered or unexported fields
}

ForLoop represents a for ... in ... loop.

func NewForLoop added in v0.9.0

func NewForLoop(span Span, vars []string, iter Node, body []Node, context *string) *ForLoop

func (*ForLoop) Children added in v0.9.0

func (n *ForLoop) Children() []Node

func (*ForLoop) Kind added in v0.9.0

func (n *ForLoop) Kind() NodeKind

func (*ForLoop) Span added in v0.9.0

func (n *ForLoop) Span() Span

type Identifier added in v0.9.0

type Identifier struct {
	Name string
	// contains filtered or unexported fields
}

Identifier represents a variable reference.

func NewIdentifier added in v0.9.0

func NewIdentifier(span Span, name string) *Identifier

func (*Identifier) Children added in v0.9.0

func (n *Identifier) Children() []Node

func (*Identifier) Kind added in v0.9.0

func (n *Identifier) Kind() NodeKind

func (*Identifier) Span added in v0.9.0

func (n *Identifier) Span() Span

type If added in v0.9.0

type If struct {
	Branches []IfBranch
	// contains filtered or unexported fields
}

If represents an if/elif/else chain.

func NewIf added in v0.9.0

func NewIf(span Span, branches []IfBranch) *If

func (*If) Children added in v0.9.0

func (n *If) Children() []Node

func (*If) Kind added in v0.9.0

func (n *If) Kind() NodeKind

func (*If) Span added in v0.9.0

func (n *If) Span() Span

type IfBranch added in v0.9.0

type IfBranch struct {
	Condition Node   // nil for else
	Body      []Node // statements
}

IfBranch is a single branch (if, elif, or else). Condition is nil for the else branch.

type InterpolationFormat added in v0.9.0

type InterpolationFormat struct {
	ThousandsSeparator bool
	Alignment          string // "<" for left, "" for right (default)
	FillChar           string // explicit fill char from fill_alignment (e.g. "*" from :*>), "" if not specified
	ZeroPad            bool   // :05 shorthand (any type; sign-aware for numbers) vs :0>5 (explicit fill)
	Padding            Node   // padding width expression
	Precision          Node   // precision expression
}

InterpolationFormat holds pre-extracted format specifiers for string interpolation (alignment, padding, precision, etc.).

type JsonPath added in v0.9.0

type JsonPath struct {
	Segments []JsonPathSeg
	// contains filtered or unexported fields
}

JsonPath represents a json field path expression (e.g. json[].age, json[0].name.first).

func NewJsonPath added in v0.9.0

func NewJsonPath(span Span, segments []JsonPathSeg) *JsonPath

func (*JsonPath) Children added in v0.9.0

func (n *JsonPath) Children() []Node

func (*JsonPath) Kind added in v0.9.0

func (n *JsonPath) Kind() NodeKind

func (*JsonPath) Span added in v0.9.0

func (n *JsonPath) Span() Span

type JsonPathIdx added in v0.9.0

type JsonPathIdx struct {
	Span Span
	Expr Node // nil = wildcard
}

JsonPathIdx is an index within a json path segment. Expr is nil for wildcard [].

type JsonPathSeg added in v0.9.0

type JsonPathSeg struct {
	Key     string // the identifier part (e.g. "json", "age", "names")
	KeySpan Span   // span of the key for error reporting
	Indexes []JsonPathIdx
}

JsonPathSeg is one segment in a json path (e.g. "json[]" or ".age" or ".names[0]").

type Lambda added in v0.9.0

type Lambda struct {
	Typing  *TypingFnT // parameter types and return type
	Body    []Node
	IsBlock bool // block function vs expression function
	DefSpan Span // span of the keyword for error reporting
	// contains filtered or unexported fields
}

Lambda represents an anonymous function.

func NewLambda added in v0.9.0

func NewLambda(span Span, typing *TypingFnT, body []Node, isBlock bool, defSpan Span) *Lambda

func (*Lambda) Children added in v0.9.0

func (n *Lambda) Children() []Node

func (*Lambda) Kind added in v0.9.0

func (n *Lambda) Kind() NodeKind

func (*Lambda) Span added in v0.9.0

func (n *Lambda) Span() Span

type ListComp added in v0.9.0

type ListComp struct {
	Expr      Node     // the expression to evaluate per iteration
	Vars      []string // loop variable names
	Iter      Node     // the iterable expression
	Condition Node     // optional filter condition (nil if absent)
	Context   *string  // optional "with x" context name
	// contains filtered or unexported fields
}

ListComp represents a list comprehension [expr for vars in iter if cond].

func NewListComp added in v0.9.0

func NewListComp(span Span, expr Node, vars []string, iter Node, condition Node, context *string) *ListComp

func (*ListComp) Children added in v0.9.0

func (n *ListComp) Children() []Node

func (*ListComp) Kind added in v0.9.0

func (n *ListComp) Kind() NodeKind

func (*ListComp) Span added in v0.9.0

func (n *ListComp) Span() Span

type LitBool added in v0.9.0

type LitBool struct {
	Value bool
	// contains filtered or unexported fields
}

LitBool represents a boolean literal.

func NewLitBool added in v0.9.0

func NewLitBool(span Span, value bool) *LitBool

func (*LitBool) Children added in v0.9.0

func (n *LitBool) Children() []Node

func (*LitBool) Kind added in v0.9.0

func (n *LitBool) Kind() NodeKind

func (*LitBool) Span added in v0.9.0

func (n *LitBool) Span() Span

type LitFloat added in v0.9.0

type LitFloat struct {
	Value float64
	// contains filtered or unexported fields
}

LitFloat represents a floating-point literal.

func NewLitFloat added in v0.9.0

func NewLitFloat(span Span, value float64) *LitFloat

func (*LitFloat) Children added in v0.9.0

func (n *LitFloat) Children() []Node

func (*LitFloat) Kind added in v0.9.0

func (n *LitFloat) Kind() NodeKind

func (*LitFloat) Span added in v0.9.0

func (n *LitFloat) Span() Span

type LitInt added in v0.9.0

type LitInt struct {
	Value int64
	// contains filtered or unexported fields
}

LitInt represents an integer literal.

func NewLitInt added in v0.9.0

func NewLitInt(span Span, value int64) *LitInt

func (*LitInt) Children added in v0.9.0

func (n *LitInt) Children() []Node

func (*LitInt) Kind added in v0.9.0

func (n *LitInt) Kind() NodeKind

func (*LitInt) Span added in v0.9.0

func (n *LitInt) Span() Span

type LitList added in v0.9.0

type LitList struct {
	Elements []Node
	// contains filtered or unexported fields
}

LitList represents a list literal [a, b, c].

func NewLitList added in v0.9.0

func NewLitList(span Span, elements []Node) *LitList

func (*LitList) Children added in v0.9.0

func (n *LitList) Children() []Node

func (*LitList) Kind added in v0.9.0

func (n *LitList) Kind() NodeKind

func (*LitList) Span added in v0.9.0

func (n *LitList) Span() Span

type LitMap added in v0.9.0

type LitMap struct {
	Entries []MapEntry
	// contains filtered or unexported fields
}

LitMap represents a map literal {k: v, ...}.

func NewLitMap added in v0.9.0

func NewLitMap(span Span, entries []MapEntry) *LitMap

func (*LitMap) Children added in v0.9.0

func (n *LitMap) Children() []Node

func (*LitMap) Kind added in v0.9.0

func (n *LitMap) Kind() NodeKind

func (*LitMap) Span added in v0.9.0

func (n *LitMap) Span() Span

type LitNull added in v0.9.0

type LitNull struct {
	// contains filtered or unexported fields
}

LitNull represents a null literal.

func NewLitNull added in v0.9.0

func NewLitNull(span Span) *LitNull

func (*LitNull) Children added in v0.9.0

func (n *LitNull) Children() []Node

func (*LitNull) Kind added in v0.9.0

func (n *LitNull) Kind() NodeKind

func (*LitNull) Span added in v0.9.0

func (n *LitNull) Span() Span

type LitString added in v0.9.0

type LitString struct {
	Simple   bool            // true = use Value, false = use Segments
	Value    string          // resolved string (when Simple)
	Segments []StringSegment // literal text + interpolation exprs
	// contains filtered or unexported fields
}

LitString uses a hybrid representation: simple strings (no interpolation) store just Value; interpolated strings use Segments.

func NewLitStringInterpolated added in v0.9.0

func NewLitStringInterpolated(span Span, segments []StringSegment) *LitString

func NewLitStringSimple added in v0.9.0

func NewLitStringSimple(span Span, value string) *LitString

func (*LitString) Children added in v0.9.0

func (n *LitString) Children() []Node

func (*LitString) Kind added in v0.9.0

func (n *LitString) Kind() NodeKind

func (*LitString) Span added in v0.9.0

func (n *LitString) Span() Span

type MapEntry added in v0.9.0

type MapEntry struct {
	Key   Node
	Value Node
}

MapEntry is a key-value pair in a map literal.

type MapNamedKey

type MapNamedKey struct {
	Name       string
	IsOptional bool
}

func NewMapNamedKey

func NewMapNamedKey(name string, isOptional bool) MapNamedKey

type Node added in v0.9.0

type Node interface {
	Kind() NodeKind
	Span() Span
	Children() []Node
}

Node is the interface all AST nodes implement.

type NodeKind added in v0.9.0

type NodeKind uint16

NodeKind identifies the type of an AST node.

const (
	// Statements
	NAssign    NodeKind = iota // also handles desugared += -= *= /= ++ --
	NExprStmt                  // expression used as a statement
	NIf                        // if/elif/else
	NSwitch                    // switch/case
	NForLoop                   // for ... in ...
	NWhileLoop                 // while ...
	NShell                     // shell statement ($...)
	NDel                       // del statement
	NDefer                     // defer/errdefer block
	NBreak                     // break
	NContinue                  // continue
	NReturn                    // return [values]
	NYield                     // yield [values]
	NPass                      // pass (no-op)
	NFnDef                     // named function definition

	// Expressions
	NOpBinary   // binary operation (a + b, a and b, etc.)
	NOpUnary    // unary operation (-x, not x)
	NTernary    // condition ? true : false
	NFallback   // left ?? right
	NCatchExpr  // left catch right
	NCall       // function call
	NVarPath    // a.b[c].d - flat segment chain
	NIdentifier // variable name
	NLambda     // anonymous function

	// Literals
	NLitInt    // integer literal
	NLitFloat  // float literal
	NLitBool   // true/false
	NLitNull   // null
	NLitString // string (simple or interpolated)
	NLitList   // [a, b, c]
	NLitMap    // {k: v}

	// Comprehension
	NListComp // [expr for vars in iter if cond]

	// Switch case alternatives
	NSwitchCaseExpr  // single-expression case (case X -> expr)
	NSwitchCaseBlock // multi-statement case (case X:\n  stmts)

	// Rad block internals
	NRadBlock    // rad block
	NRadField    // field declaration in a rad block
	NRadSort     // sort specifier in a rad block
	NRadFieldMod // field modifier (color, map, filter)
	NRadIf       // conditional in a rad block
	NRadOption   // block-level option (e.g. insecure)

	// JSON
	NJsonPath // json[].field path expression

	// Script metadata
	NFileHeader // --- block with description + metadata
	NArgBlock   // args: block
	NArgDecl    // single arg declaration
	NCmdBlock   // command definition

	// Structural
	NSourceFile // root node of a script
)

func (NodeKind) String added in v0.9.0

func (k NodeKind) String() string

type OpBinary added in v0.9.0

type OpBinary struct {
	Op         Operator
	Left       Node
	Right      Node
	IsCompound bool // true when desugared from compound assign (e.g. +=)
	// contains filtered or unexported fields
}

OpBinary represents a binary operation.

func NewOpBinary added in v0.9.0

func NewOpBinary(span Span, op Operator, left, right Node) *OpBinary

func (*OpBinary) Children added in v0.9.0

func (n *OpBinary) Children() []Node

func (*OpBinary) Kind added in v0.9.0

func (n *OpBinary) Kind() NodeKind

func (*OpBinary) Span added in v0.9.0

func (n *OpBinary) Span() Span

type OpUnary added in v0.9.0

type OpUnary struct {
	Op      Operator
	Operand Node
	// contains filtered or unexported fields
}

OpUnary represents a unary operation.

func NewOpUnary added in v0.9.0

func NewOpUnary(span Span, op Operator, operand Node) *OpUnary

func (*OpUnary) Children added in v0.9.0

func (n *OpUnary) Children() []Node

func (*OpUnary) Kind added in v0.9.0

func (n *OpUnary) Kind() NodeKind

func (*OpUnary) Span added in v0.9.0

func (n *OpUnary) Span() Span

type Operator added in v0.9.0

type Operator uint8

Operator identifies a binary or unary operator.

const (
	// Arithmetic
	OpAdd Operator = iota
	OpSub
	OpMul
	OpDiv
	OpMod

	// Comparison
	OpEq
	OpNeq
	OpLt
	OpLte
	OpGt
	OpGte

	// Logical
	OpAnd
	OpOr

	// Membership
	OpIn    // in
	OpNotIn // not in

	// Unary
	OpNeg // -x
	OpNot // not x
)

func (Operator) String added in v0.9.0

func (op Operator) String() string

type Pass added in v0.9.0

type Pass struct {
	// contains filtered or unexported fields
}

Pass is a no-op statement.

func NewPass added in v0.9.0

func NewPass(span Span) *Pass

func (*Pass) Children added in v0.9.0

func (n *Pass) Children() []Node

func (*Pass) Kind added in v0.9.0

func (n *Pass) Kind() NodeKind

func (*Pass) Span added in v0.9.0

func (n *Pass) Span() Span

type PathSegment added in v0.9.0

type PathSegment struct {
	Field   *string // dot access: .name (nil if bracket)
	Index   Node    // bracket access: [expr] (nil if dot or slice)
	IsSlice bool    // [start:end] slice syntax
	IsUFCS  bool    // true when indexing node was directly a K_CALL (UFCS syntax)
	Start   Node    // slice start (may be nil)
	End     Node    // slice end (may be nil)
	// contains filtered or unexported fields
}

PathSegment represents one segment in a var path.

func NewPathSegmentField added in v0.9.0

func NewPathSegmentField(span Span, field string) PathSegment

func NewPathSegmentIndex added in v0.9.0

func NewPathSegmentIndex(span Span, index Node) PathSegment

func NewPathSegmentSlice added in v0.9.0

func NewPathSegmentSlice(span Span, start, end Node) PathSegment

func (PathSegment) Span added in v0.9.0

func (p PathSegment) Span() Span

Span returns the span of this path segment.

type RadBlock added in v0.9.0

type RadBlock struct {
	Keyword     string // the keyword used: "rad", "request", or "display"
	KeywordSpan Span   // span of just the keyword token
	Source      Node   // the source expression (URL string, list, map, or nil)
	Stmts       []Node // block statements (RadField, RadSort, etc.)
	// contains filtered or unexported fields
}

RadBlock represents a rad block with an optional source expression.

func NewRadBlock added in v0.9.0

func NewRadBlock(span Span, keyword string, keywordSpan Span, source Node, stmts []Node) *RadBlock

func (*RadBlock) Children added in v0.9.0

func (n *RadBlock) Children() []Node

func (*RadBlock) Kind added in v0.9.0

func (n *RadBlock) Kind() NodeKind

func (*RadBlock) Span added in v0.9.0

func (n *RadBlock) Span() Span

type RadField added in v0.9.0

type RadField struct {
	Identifiers []Node // field name Identifier nodes
	// contains filtered or unexported fields
}

RadField represents a field declaration in a rad block. A single statement can declare multiple fields (e.g. "name age email").

func NewRadField added in v0.9.0

func NewRadField(span Span, identifiers []Node) *RadField

func (*RadField) Children added in v0.9.0

func (n *RadField) Children() []Node

func (*RadField) Kind added in v0.9.0

func (n *RadField) Kind() NodeKind

func (*RadField) Span added in v0.9.0

func (n *RadField) Span() Span

type RadFieldMod added in v0.9.0

type RadFieldMod struct {
	Fields  []Node // target field identifiers (nil for individual modifiers)
	ModType string // "color", "map", "filter" (empty for container)
	Args    []Node // modifier arguments or child modifier nodes
	// contains filtered or unexported fields
}

RadFieldMod represents a field modifier statement. At the container level (K_RAD_FIELD_MODIFIER_STMT): Fields holds the target field identifiers, ModType is empty, and Args holds the child modifier nodes. At the individual level (color/map/filter): Fields is nil, ModType is set, and Args holds the modifier arguments (expressions/lambdas).

func NewRadFieldMod added in v0.9.0

func NewRadFieldMod(span Span, fields []Node, modType string, args []Node) *RadFieldMod

func (*RadFieldMod) Children added in v0.9.0

func (n *RadFieldMod) Children() []Node

func (*RadFieldMod) Kind added in v0.9.0

func (n *RadFieldMod) Kind() NodeKind

func (*RadFieldMod) Span added in v0.9.0

func (n *RadFieldMod) Span() Span

type RadIf added in v0.9.0

type RadIf struct {
	Branches []IfBranch // reuses IfBranch from the top-level If node
	// contains filtered or unexported fields
}

RadIf represents a conditional in a rad block (if/elif/else). Mirrors the top-level If node's branch structure.

func NewRadIf added in v0.9.0

func NewRadIf(span Span, branches []IfBranch) *RadIf

func (*RadIf) Children added in v0.9.0

func (n *RadIf) Children() []Node

func (*RadIf) Kind added in v0.9.0

func (n *RadIf) Kind() NodeKind

func (*RadIf) Span added in v0.9.0

func (n *RadIf) Span() Span

type RadNode

type RadNode struct {
	Node *ts.Node
	Src  string
}

func NewRadNode

func NewRadNode(node *ts.Node, src string) *RadNode

type RadOption added in v0.9.0

type RadOption struct {
	Keyword string
	Value   Node // optional expression; nil means implied true
	// contains filtered or unexported fields
}

RadOption represents a block-level option like `insecure` or `insecure true`.

func NewRadOption added in v0.9.0

func NewRadOption(span Span, keyword string, value Node) *RadOption

func (*RadOption) Children added in v0.9.0

func (n *RadOption) Children() []Node

func (*RadOption) Kind added in v0.9.0

func (n *RadOption) Kind() NodeKind

func (*RadOption) Span added in v0.9.0

func (n *RadOption) Span() Span

type RadSort added in v0.9.0

type RadSort struct {
	Specifiers []RadSortSpecifier
	// contains filtered or unexported fields
}

RadSort represents a sort specifier in a rad block.

func NewRadSort added in v0.9.0

func NewRadSort(span Span, specifiers []RadSortSpecifier) *RadSort

func (*RadSort) Children added in v0.9.0

func (n *RadSort) Children() []Node

func (*RadSort) Kind added in v0.9.0

func (n *RadSort) Kind() NodeKind

func (*RadSort) Span added in v0.9.0

func (n *RadSort) Span() Span

type RadSortSpecifier added in v0.9.0

type RadSortSpecifier struct {
	Field     string // field name to sort by
	Ascending bool   // true = asc, false = desc
}

RadSortSpecifier is a single sort field + direction.

type RadType

type RadType int

Actual interpreter types

const (
	RadStrT RadType = iota
	RadIntT
	RadFloatT
	RadBoolT
	RadListT
	RadMapT
	RadFnT
	RadNullT
	RadErrorT
)

func (RadType) AsString

func (r RadType) AsString() string

type Return added in v0.9.0

type Return struct {
	Values []Node
	// contains filtered or unexported fields
}

Return represents a return statement with optional values.

func NewReturn added in v0.9.0

func NewReturn(span Span, values []Node) *Return

func (*Return) Children added in v0.9.0

func (n *Return) Children() []Node

func (*Return) Kind added in v0.9.0

func (n *Return) Kind() NodeKind

func (*Return) Span added in v0.9.0

func (n *Return) Span() Span

type Shell added in v0.9.0

type Shell struct {
	Targets   []Node      // assignment targets (if shell assigns to vars)
	Cmd       Node        // the command expression
	Catch     *CatchBlock // optional catch block
	IsQuiet   bool        // quiet modifier
	IsConfirm bool        // confirm modifier
	// contains filtered or unexported fields
}

Shell represents a shell statement ($...).

func NewShell added in v0.9.0

func NewShell(span Span, targets []Node, cmd Node, catch *CatchBlock, isQuiet, isConfirm bool) *Shell

func (*Shell) Children added in v0.9.0

func (n *Shell) Children() []Node

func (*Shell) Kind added in v0.9.0

func (n *Shell) Kind() NodeKind

func (*Shell) Span added in v0.9.0

func (n *Shell) Span() Span

type SourceFile added in v0.9.0

type SourceFile struct {
	Header *FileHeader
	Args   *ArgBlock
	Cmds   []*CmdBlock
	Stmts  []Node
	// contains filtered or unexported fields
}

SourceFile is the root AST node for a script.

func NewSourceFile added in v0.9.0

func NewSourceFile(span Span, stmts []Node) *SourceFile

func (*SourceFile) Children added in v0.9.0

func (n *SourceFile) Children() []Node

func (*SourceFile) Kind added in v0.9.0

func (n *SourceFile) Kind() NodeKind

func (*SourceFile) Span added in v0.9.0

func (n *SourceFile) Span() Span

type Span added in v0.9.0

type Span struct {
	File      string
	StartByte int
	EndByte   int
	StartRow  int
	StartCol  int
	EndRow    int
	EndCol    int
}

Span represents a location range in source code. All positions are 0-indexed.

func (Span) EndColumn added in v0.9.0

func (s Span) EndColumn() int

EndColumn returns the 1-indexed end column number for display.

func (Span) EndLine added in v0.9.0

func (s Span) EndLine() int

EndLine returns the 1-indexed end line number for display.

func (Span) StartColumn added in v0.9.0

func (s Span) StartColumn() int

StartColumn returns the 1-indexed start column number for display.

func (Span) StartLine added in v0.9.0

func (s Span) StartLine() int

StartLine returns the 1-indexed start line number for display.

type StringSegment added in v0.9.0

type StringSegment struct {
	IsLiteral bool                 // true = Text only, false = Expr
	Text      string               // literal text (resolved escapes)
	Expr      Node                 // interpolation expression (when !IsLiteral)
	Format    *InterpolationFormat // optional format specifiers
	// contains filtered or unexported fields
}

StringSegment is either literal text or an interpolation expression.

func NewStringSegmentInterp added in v0.9.0

func NewStringSegmentInterp(expr Node, format *InterpolationFormat, span Span) StringSegment

NewStringSegmentInterp creates an interpolation string segment.

func (StringSegment) Span added in v0.9.0

func (s StringSegment) Span() Span

Span returns the span of this string segment.

type Switch added in v0.9.0

type Switch struct {
	Discriminant Node         // the value being switched on
	Cases        []SwitchCase // case branches
	Default      *SwitchDefault
	// contains filtered or unexported fields
}

Switch represents a switch/case statement.

func NewSwitch added in v0.9.0

func NewSwitch(span Span, discriminant Node, cases []SwitchCase, dflt *SwitchDefault) *Switch

func (*Switch) Children added in v0.9.0

func (n *Switch) Children() []Node

func (*Switch) Kind added in v0.9.0

func (n *Switch) Kind() NodeKind

func (*Switch) Span added in v0.9.0

func (n *Switch) Span() Span

type SwitchCase added in v0.9.0

type SwitchCase struct {
	Keys []Node // match values (can be multiple: case 1, 2:)
	Alt  Node   // either SwitchCaseExpr or SwitchCaseBlock
}

SwitchCase is a single case branch.

type SwitchCaseBlock added in v0.9.0

type SwitchCaseBlock struct {
	Stmts []Node
	// contains filtered or unexported fields
}

SwitchCaseBlock is a multi-statement case body (case X:\n stmts).

func NewSwitchCaseBlock added in v0.9.0

func NewSwitchCaseBlock(span Span, stmts []Node) *SwitchCaseBlock

func (*SwitchCaseBlock) Children added in v0.9.0

func (n *SwitchCaseBlock) Children() []Node

func (*SwitchCaseBlock) Kind added in v0.9.0

func (n *SwitchCaseBlock) Kind() NodeKind

func (*SwitchCaseBlock) Span added in v0.9.0

func (n *SwitchCaseBlock) Span() Span

type SwitchCaseExpr added in v0.9.0

type SwitchCaseExpr struct {
	Values []Node // right-hand side values
	// contains filtered or unexported fields
}

SwitchCaseExpr is a single-expression case value (case X: expr).

func NewSwitchCaseExpr added in v0.9.0

func NewSwitchCaseExpr(span Span, values []Node) *SwitchCaseExpr

func (*SwitchCaseExpr) Children added in v0.9.0

func (n *SwitchCaseExpr) Children() []Node

func (*SwitchCaseExpr) Kind added in v0.9.0

func (n *SwitchCaseExpr) Kind() NodeKind

func (*SwitchCaseExpr) Span added in v0.9.0

func (n *SwitchCaseExpr) Span() Span

type SwitchDefault added in v0.9.0

type SwitchDefault struct {
	Alt Node // either SwitchCaseExpr or SwitchCaseBlock
}

SwitchDefault is the default branch of a switch.

type Ternary added in v0.9.0

type Ternary struct {
	Condition Node
	True      Node
	False     Node
	// contains filtered or unexported fields
}

Ternary represents a ternary expression (cond ? true : false).

func NewTernary added in v0.9.0

func NewTernary(span Span, condition, trueExpr, falseExpr Node) *Ternary

func (*Ternary) Children added in v0.9.0

func (n *Ternary) Children() []Node

func (*Ternary) Kind added in v0.9.0

func (n *Ternary) Kind() NodeKind

func (*Ternary) Span added in v0.9.0

func (n *Ternary) Span() Span

type TypingAnyListT

type TypingAnyListT struct{} // var: list i.e. any[]

Collections

func NewAnyListType

func NewAnyListType() *TypingAnyListT

func (*TypingAnyListT) IsCompatibleWith

func (t *TypingAnyListT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingAnyListT) Name

func (t *TypingAnyListT) Name() string

type TypingAnyMapT

type TypingAnyMapT struct{} // var: map i.e. { any: any }

func NewAnyMapType

func NewAnyMapType() *TypingAnyMapT

func (*TypingAnyMapT) IsCompatibleWith

func (t *TypingAnyMapT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingAnyMapT) Name

func (t *TypingAnyMapT) Name() string

type TypingAnyT

type TypingAnyT struct{} // var: any

func NewAnyType

func NewAnyType() *TypingAnyT

func (*TypingAnyT) IsCompatibleWith

func (t *TypingAnyT) IsCompatibleWith(TypingCompatVal) bool

func (*TypingAnyT) Name

func (t *TypingAnyT) Name() string

type TypingBoolT

type TypingBoolT struct{} // var: bool

func NewBoolType

func NewBoolType() *TypingBoolT

func (*TypingBoolT) IsCompatibleWith

func (t *TypingBoolT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingBoolT) Name

func (t *TypingBoolT) Name() string

type TypingCompatVal

type TypingCompatVal struct {
	Val  interface{} // Specific int64, float64, string, bool, []interface{}, map[string]interface{}
	Type *RadType
}

first check Val, then Type

func NewBoolSubject

func NewBoolSubject(val bool) TypingCompatVal

func NewErrorSubject

func NewErrorSubject() TypingCompatVal

func NewFloatSubject

func NewFloatSubject(val float64) TypingCompatVal

func NewFnSubject

func NewFnSubject() TypingCompatVal

func NewIntSubject

func NewIntSubject(val int64) TypingCompatVal

func NewListSubject

func NewListSubject() TypingCompatVal

func NewMapSubject

func NewMapSubject() TypingCompatVal

func NewNullSubject

func NewNullSubject() TypingCompatVal

func NewStrSubject

func NewStrSubject(val string) TypingCompatVal

func NewSubject

func NewSubject(val interface{}) TypingCompatVal

func NewVoidSubject

func NewVoidSubject() TypingCompatVal

type TypingErrorT

type TypingErrorT struct{} // var: error

func NewErrorType

func NewErrorType() *TypingErrorT

func (*TypingErrorT) IsCompatibleWith

func (t *TypingErrorT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingErrorT) Name

func (t *TypingErrorT) Name() string

type TypingFloatT

type TypingFloatT struct{} // var: float

func NewFloatType

func NewFloatType() *TypingFloatT

func (*TypingFloatT) IsCompatibleWith

func (t *TypingFloatT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingFloatT) Name

func (t *TypingFloatT) Name() string

type TypingFnParam

type TypingFnParam struct {
	Name       string
	Type       *TypingT
	IsVariadic bool // vararg
	NamedOnly  bool // if true, can only be passed as a named arg
	IsOptional bool
	// Default is the CST-based default. Still needed because typing
	// resolution sets it from CST, and the converter reads it to produce
	// DefaultAST. Built-in defaults are pre-converted in rts/signatures.go init().
	Default    *RadNode
	DefaultAST *ASTDefault // AST-based default (used by interpreter at call time)
}

func (TypingFnParam) AnonymousOnly

func (t TypingFnParam) AnonymousOnly() bool

type TypingFnT

type TypingFnT struct {
	Name    string // empty if anonymous
	Params  []TypingFnParam
	ReturnT *TypingT
}

Complex / Unions / Misc

func NewTypingFnT

func NewTypingFnT(fnNode *ts.Node, src string) *TypingFnT

K_FN_NAMED expected as node

func (*TypingFnT) ByName

func (t *TypingFnT) ByName() map[string]TypingFnParam

type TypingIntT

type TypingIntT struct{} // var: int

func NewIntType

func NewIntType() *TypingIntT

func (*TypingIntT) IsCompatibleWith

func (t *TypingIntT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingIntT) Name

func (t *TypingIntT) Name() string

type TypingListT

type TypingListT struct {
	// contains filtered or unexported fields
}

func NewListType

func NewListType(elem TypingT) *TypingListT

func (*TypingListT) IsCompatibleWith

func (t *TypingListT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingListT) Name

func (t *TypingListT) Name() string

type TypingMapT

type TypingMapT struct {
	// contains filtered or unexported fields
}

func NewMapType

func NewMapType(key, val TypingT) *TypingMapT

func (*TypingMapT) IsCompatibleWith

func (t *TypingMapT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingMapT) Name

func (t *TypingMapT) Name() string

type TypingOptionalT

type TypingOptionalT struct {
	// contains filtered or unexported fields
}

func NewOptionalType

func NewOptionalType(t TypingT) *TypingOptionalT

func (*TypingOptionalT) IsCompatibleWith

func (t *TypingOptionalT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingOptionalT) Name

func (t *TypingOptionalT) Name() string

type TypingStrEnumT

type TypingStrEnumT struct {
	// contains filtered or unexported fields
}

func NewStrEnumType

func NewStrEnumType(values ...string) *TypingStrEnumT

func (*TypingStrEnumT) IsCompatibleWith

func (t *TypingStrEnumT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingStrEnumT) Name

func (t *TypingStrEnumT) Name() string

type TypingStrT

type TypingStrT struct{} // var: str

Primitives / Union Primitives

func NewStrType

func NewStrType() *TypingStrT

func (*TypingStrT) IsCompatibleWith

func (t *TypingStrT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingStrT) Name

func (t *TypingStrT) Name() string

type TypingStructT

type TypingStructT struct {
	// contains filtered or unexported fields
}

func NewStructType

func NewStructType(named map[MapNamedKey]TypingT) *TypingStructT

func (*TypingStructT) IsCompatibleWith

func (t *TypingStructT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingStructT) Name

func (t *TypingStructT) Name() string

type TypingT

type TypingT interface {
	Name() string
	IsCompatibleWith(val TypingCompatVal) bool
}

type TypingTupleT

type TypingTupleT struct {
	// contains filtered or unexported fields
}

func NewTupleType

func NewTupleType(types ...TypingT) *TypingTupleT

func (*TypingTupleT) IsCompatibleWith

func (t *TypingTupleT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingTupleT) Name

func (t *TypingTupleT) Name() string

type TypingUnionT

type TypingUnionT struct {
	// contains filtered or unexported fields
}

func NewUnionType

func NewUnionType(types ...TypingT) *TypingUnionT

func (*TypingUnionT) IsCompatibleWith

func (t *TypingUnionT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingUnionT) Name

func (t *TypingUnionT) Name() string

type TypingVarArgT

type TypingVarArgT struct {
	// contains filtered or unexported fields
}

Modifiers

func NewVarArgType

func NewVarArgType(t TypingT) *TypingVarArgT

func (*TypingVarArgT) IsCompatibleWith

func (t *TypingVarArgT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingVarArgT) Name

func (t *TypingVarArgT) Name() string

type TypingVoidT

type TypingVoidT struct{} // -> void

func NewVoidType

func NewVoidType() *TypingVoidT

func (*TypingVoidT) IsCompatibleWith

func (t *TypingVoidT) IsCompatibleWith(val TypingCompatVal) bool

func (*TypingVoidT) Name

func (t *TypingVoidT) Name() string

type VarPath added in v0.9.0

type VarPath struct {
	Root     Node          // the base identifier or expression
	Segments []PathSegment // .field, [expr], [start:end]
	// contains filtered or unexported fields
}

VarPath represents chained access: a.b[c].d

func NewVarPath added in v0.9.0

func NewVarPath(span Span, root Node, segments []PathSegment) *VarPath

func (*VarPath) Children added in v0.9.0

func (n *VarPath) Children() []Node

func (*VarPath) Kind added in v0.9.0

func (n *VarPath) Kind() NodeKind

func (*VarPath) Span added in v0.9.0

func (n *VarPath) Span() Span

type WhileLoop added in v0.9.0

type WhileLoop struct {
	Condition Node   // nil = infinite loop
	Body      []Node // statement list
	// contains filtered or unexported fields
}

WhileLoop represents a while loop. Condition is nil for infinite loops.

func NewWhileLoop added in v0.9.0

func NewWhileLoop(span Span, condition Node, body []Node) *WhileLoop

func (*WhileLoop) Children added in v0.9.0

func (n *WhileLoop) Children() []Node

func (*WhileLoop) Kind added in v0.9.0

func (n *WhileLoop) Kind() NodeKind

func (*WhileLoop) Span added in v0.9.0

func (n *WhileLoop) Span() Span

type Yield added in v0.9.0

type Yield struct {
	Values []Node
	// contains filtered or unexported fields
}

Yield represents a yield statement with optional values.

func NewYield added in v0.9.0

func NewYield(span Span, values []Node) *Yield

func (*Yield) Children added in v0.9.0

func (n *Yield) Children() []Node

func (*Yield) Kind added in v0.9.0

func (n *Yield) Kind() NodeKind

func (*Yield) Span added in v0.9.0

func (n *Yield) Span() Span

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL