cst

package
v6.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: BSD-2-Clause Imports: 22 Imported by: 0

README

See ../dsl/README.md for more information about Miller's use of abstract syntax trees (ASTs) and concrete syntax trees (CSTs) within the Miller put/filter domain-specific language (DSL).

Files

  • types.go is a starting point for seeing datatypes involved in the concrete syntax tree.
    • IExecutable is the interface for executable nodes, such as assignment statements, or statement blocks (if-bodies, etc.).
    • IEvaluable is the interface for evaluable expressions (e.g. right-hand sides of assignment statements).
  • root.go contains the top-level logic for building a CST from an AST at parse time (cstRoot, err := cst.Build(astRoot)), as well as executing the CST on a per-record basis (cstRoot.Execute(runtimeState)). See also the put transformer.

Notes

Go is a strongly typed language, but the AST is polymorphic. This results in if/else or switch statements as an AST is walked.

Also, when we modify code, there can be changes in the BNF grammar not yet reflected in the AST. Likewise, there can be AST changes not yet reflected here. (Example: you are partway through adding a new binary operator to the grammar.)

As a result, throughout the code, there are error checks which may seem redundant but which are in place to make incremental development more pleasant and robust.

During CST build from an AST, one starts from the AST root and walks down through the nodes of the AST. Within a caller method, there is an if/else or switch statement on the AST node type. (Example: is this a leaf node, like the string literal "abcd", int literal 3, field-name $x? Or a binary operator like +, or function call like cos?).

Different builder methods are invoked for leaves, operators, etc. There is also, redundantly, a precondition assertion within each builder method: the leaf-builder method checks to make sure it's given an AST leaf node to build from; the operator-builder method checks to make sure it's given an AST operator node to build from; etc. The caller and the callee are doing the same kinds of check, which might seem redundant. The callees return Go error in case there is something new in the caller which has not yet been implemented in the callee.

This is all done to make development more happy: when you see things like CST build: AST unary operator node unhandled you can check the code here and see what you need to do next to continue development.

Documentation

Overview

Package cst implements the Miller programming language. It is named for the concrete syntax tree data structure.

Index

Constants

View Source
const (
	DSLInstanceTypePut = iota
	DSLInstanceTypeFilter
	DSLInstanceTypeREPL
)

Variables

View Source
var KEYWORD_USAGE_TABLE = []tKeywordUsageEntry{
	{"all", allKeywordUsage},
	{"begin", beginKeywordUsage},
	{"bool", boolKeywordUsage},
	{"break", breakKeywordUsage},
	{"call", callKeywordUsage},
	{"continue", continueKeywordUsage},
	{"do", doKeywordUsage},
	{"dump", dumpKeywordUsage},
	{"edump", edumpKeywordUsage},
	{"elif", elifKeywordUsage},
	{"else", elseKeywordUsage},
	{"emit1", emit1KeywordUsage},
	{"emit", emitKeywordUsage},
	{"emitf", emitfKeywordUsage},
	{"emitp", emitpKeywordUsage},
	{"end", endKeywordUsage},
	{"eprint", eprintKeywordUsage},
	{"eprintn", eprintnKeywordUsage},
	{"false", falseKeywordUsage},
	{"filter", filterKeywordUsage},
	{"float", floatKeywordUsage},
	{"for", forKeywordUsage},
	{"func", funcKeywordUsage},
	{"funct", functKeywordUsage},
	{"if", ifKeywordUsage},
	{"in", inKeywordUsage},
	{"int", intKeywordUsage},
	{"map", mapKeywordUsage},
	{"num", numKeywordUsage},
	{"print", printKeywordUsage},
	{"printn", printnKeywordUsage},
	{"return", returnKeywordUsage},
	{"stderr", stderrKeywordUsage},
	{"stdout", stdoutKeywordUsage},
	{"str", strKeywordUsage},
	{"subr", subrKeywordUsage},
	{"tee", teeKeywordUsage},
	{"true", trueKeywordUsage},
	{"unset", unsetKeywordUsage},
	{"var", varKeywordUsage},
	{"while", whileKeywordUsage},
	{"ENV", ENVKeywordUsage},
	{"FILENAME", FILENAMEKeywordUsage},
	{"FILENUM", FILENUMKeywordUsage},
	{"FNR", FNRKeywordUsage},
	{"IFS", IFSKeywordUsage},
	{"IPS", IPSKeywordUsage},
	{"IRS", IRSKeywordUsage},
	{"M_E", M_EKeywordUsage},
	{"M_PI", M_PIKeywordUsage},
	{"NF", NFKeywordUsage},
	{"NR", NRKeywordUsage},
	{"OFS", OFSKeywordUsage},
	{"OPS", OPSKeywordUsage},
	{"ORS", ORSKeywordUsage},
}

Functions

func AnyHOF

func AnyHOF(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

func ApplyHOF

func ApplyHOF(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

func BinaryShortCircuitPlaceholder

func BinaryShortCircuitPlaceholder(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval

func ENVKeywordUsage

func ENVKeywordUsage()

func EveryHOF

func EveryHOF(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

func FILENAMEKeywordUsage

func FILENAMEKeywordUsage()

func FILENUMKeywordUsage

func FILENUMKeywordUsage()

func FNRKeywordUsage

func FNRKeywordUsage()

func FoldHOF

func FoldHOF(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	input3 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

func IFSKeywordUsage

func IFSKeywordUsage()

func IPSKeywordUsage

func IPSKeywordUsage()

func IRSKeywordUsage

func IRSKeywordUsage()

func ListKeywordsAsParagraph

func ListKeywordsAsParagraph()

----------------------------------------------------------------

func ListKeywordsVertically

func ListKeywordsVertically()

----------------------------------------------------------------

func M_EKeywordUsage

func M_EKeywordUsage()

func M_PIKeywordUsage

func M_PIKeywordUsage()

func NFKeywordUsage

func NFKeywordUsage()

func NRKeywordUsage

func NRKeywordUsage()

func OFSKeywordUsage

func OFSKeywordUsage()

func OPSKeywordUsage

func OPSKeywordUsage()

func ORSKeywordUsage

func ORSKeywordUsage()

func ReduceHOF

func ReduceHOF(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

func SelectHOF

func SelectHOF(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

func SortHOF

func SortHOF(
	inputs []*mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

func TernaryShortCircuitPlaceholder

func TernaryShortCircuitPlaceholder(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval

func TryUsageForKeyword

func TryUsageForKeyword(name string) bool

func TryUsageForKeywordApproximate

func TryUsageForKeywordApproximate(searchString string) bool

func UsageForKeyword

func UsageForKeyword(name string)

func UsageKeywords

func UsageKeywords()

Pass function_name == NULL to get usage for all keywords.

func ValidateAST

func ValidateAST(
	ast *dsl.AST,
	dslInstanceType DSLInstanceType,
) error

----------------------------------------------------------------

func WarnOnAST

func WarnOnAST(
	ast *dsl.AST,
) bool

---------------------------------------------------------------- Returns true if there are no warnings.

Types

type ASTBuildVisitorFunc

type ASTBuildVisitorFunc func(dslString string, astNode *dsl.AST)

ASTBuildVisitorFunc is a callback, used by RootNode's Build method, which CST-builder callsites can use to visit parse-to-AST result of multi-string DSL inputs. Nominal use: mlr put -v, mlr put -d, etc.

type AbsentCoalesceOperatorNode

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

================================================================ a ?? b evaluates to b only when a is absent. Example: '$foo ?? 0' when the current record has no field $foo.

func BuildAbsentCoalesceOperatorNode

func BuildAbsentCoalesceOperatorNode(a, b IEvaluable) *AbsentCoalesceOperatorNode

func (*AbsentCoalesceOperatorNode) Evaluate

func (node *AbsentCoalesceOperatorNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

This is different from most of the evaluator functions in that it does short-circuiting: the second argument is not evaluated if the first argument is not absent.

type ArrayLiteralNode

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

----------------------------------------------------------------

func (*ArrayLiteralNode) Evaluate

func (node *ArrayLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type ArrayOrMapIndexAccessNode

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

----------------------------------------------------------------

func (*ArrayOrMapIndexAccessNode) Evaluate

func (node *ArrayOrMapIndexAccessNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type ArrayOrMapPositionalNameAccessNode

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

================================================================ For x = [7,8,9], x[[2]] = 2 For y = {"a":7,"b":8,"c":9}, y[[2]] = "b"

func (*ArrayOrMapPositionalNameAccessNode) Evaluate

func (node *ArrayOrMapPositionalNameAccessNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type ArrayOrMapPositionalValueAccessNode

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

================================================================ For x = [7,8,9], x[[2]] = 8 For y = {"a":7,"b":8,"c":9}, y[[2]] = 8

func (*ArrayOrMapPositionalValueAccessNode) Evaluate

func (node *ArrayOrMapPositionalValueAccessNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type ArraySliceAccessNode

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

----------------------------------------------------------------

func (*ArraySliceAccessNode) Evaluate

func (node *ArraySliceAccessNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type AssignmentNode

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

----------------------------------------------------------------

func NewAssignmentNode

func NewAssignmentNode(
	lvalueNode IAssignable,
	rvalueNode IEvaluable,
) *AssignmentNode

func (*AssignmentNode) Execute

func (node *AssignmentNode) Execute(
	state *runtime.State,
) (*BlockExitPayload, error)

type BareBooleanStatementNode

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

---------------------------------------------------------------- BareBooleanStatementNode is for implicit filter statements such as mlr filter 'NR < 10' -- "implicit" since the word "filter" doesn't appear within the single quotes as part of the DSL expression per se. Or (as noted above) mlr put 'NR < 10' is a no-op.

func (*BareBooleanStatementNode) Execute

func (node *BareBooleanStatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type BinaryFuncWithState

type BinaryFuncWithState func(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

BinaryFuncWithState is for select, apply, and reduce.

type BinaryFunctionCallsiteNode

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

----------------------------------------------------------------

func (*BinaryFunctionCallsiteNode) Evaluate

func (node *BinaryFunctionCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type BinaryFunctionWithStateCallsiteNode

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

----------------------------------------------------------------

func (*BinaryFunctionWithStateCallsiteNode) Evaluate

func (node *BinaryFunctionWithStateCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type BlockExitPayload

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

type BlockExitStatus

type BlockExitStatus int

---------------------------------------------------------------- Things a block of statements can do: * execute all the way to the end without a return * break * continue * (throw an exception if the Miller DSL were to support that) * return void * return a value

const (
	// BLOCK_EXIT_RUN_TO_END is implemented as *BlockExitPayload being nil
	BLOCK_EXIT_BREAK        BlockExitStatus = 1
	BLOCK_EXIT_CONTINUE     BlockExitStatus = 2
	BLOCK_EXIT_RETURN_VOID  BlockExitStatus = 3
	BLOCK_EXIT_RETURN_VALUE BlockExitStatus = 4
)

type BoolLiteralNode

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

----------------------------------------------------------------

func (*BoolLiteralNode) Evaluate

func (node *BoolLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type BreakNode

type BreakNode struct {
}

----------------------------------------------------------------

func (*BreakNode) Execute

func (node *BreakNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type BuiltinFunctionInfo

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

================================================================

func (*BuiltinFunctionInfo) JoinHelp

func (info *BuiltinFunctionInfo) JoinHelp() string

JoinHelp must be used to format any function help-strings for output. for source-code storage, these have newlines in them. For any presentation to the user, they must be formatted using the JoinHelp() method which joins newlines. This is crucial for rendering of help-strings for manual page, webdocs, etc wherein we must let the user's resizing of the terminal window or browser determine -- at their choosing -- where lines wrap.

type BuiltinFunctionManager

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

================================================================

var BuiltinFunctionManagerInstance *BuiltinFunctionManager = NewBuiltinFunctionManager()

================================================================ This is a singleton so the online-help functions can query it for listings, online help, etc.

func NewBuiltinFunctionManager

func NewBuiltinFunctionManager() *BuiltinFunctionManager

func (*BuiltinFunctionManager) ListBuiltinFunctionClasses

func (manager *BuiltinFunctionManager) ListBuiltinFunctionClasses()

func (*BuiltinFunctionManager) ListBuiltinFunctionNamesAsParagraph

func (manager *BuiltinFunctionManager) ListBuiltinFunctionNamesAsParagraph()

func (*BuiltinFunctionManager) ListBuiltinFunctionNamesVertically

func (manager *BuiltinFunctionManager) ListBuiltinFunctionNamesVertically()

func (*BuiltinFunctionManager) ListBuiltinFunctionUsage

func (manager *BuiltinFunctionManager) ListBuiltinFunctionUsage(functionName string)

func (*BuiltinFunctionManager) ListBuiltinFunctionUsageApproximate

func (manager *BuiltinFunctionManager) ListBuiltinFunctionUsageApproximate(
	text string,
) bool

func (*BuiltinFunctionManager) ListBuiltinFunctionUsages

func (manager *BuiltinFunctionManager) ListBuiltinFunctionUsages()

----------------------------------------------------------------

func (*BuiltinFunctionManager) ListBuiltinFunctionUsagesByClass

func (manager *BuiltinFunctionManager) ListBuiltinFunctionUsagesByClass()

func (*BuiltinFunctionManager) ListBuiltinFunctionsAsTable

func (manager *BuiltinFunctionManager) ListBuiltinFunctionsAsTable()

func (*BuiltinFunctionManager) ListBuiltinFunctionsInClass

func (manager *BuiltinFunctionManager) ListBuiltinFunctionsInClass(class string)

func (*BuiltinFunctionManager) LookUp

func (manager *BuiltinFunctionManager) LookUp(functionName string) *BuiltinFunctionInfo

func (*BuiltinFunctionManager) TryListBuiltinFunctionUsage

func (manager *BuiltinFunctionManager) TryListBuiltinFunctionUsage(
	functionName string,
) bool

func (*BuiltinFunctionManager) TryListBuiltinFunctionUsageApproximate

func (manager *BuiltinFunctionManager) TryListBuiltinFunctionUsageApproximate(
	searchString string,
) bool

type CondBlockNode

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

func (*CondBlockNode) Execute

func (node *CondBlockNode) Execute(
	state *runtime.State,
) (*BlockExitPayload, error)

----------------------------------------------------------------

type ContinueNode

type ContinueNode struct {
}

----------------------------------------------------------------

func (*ContinueNode) Execute

func (node *ContinueNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type DSLInstanceType

type DSLInstanceType int

---------------------------------------------------------------- DSLInstanceType is for minor differences in DSL handling between mlr put, mlr filter, and mlr repl.

Namely, for "bare booleans" which are non-assignment statements like 'NR > 10' or 'true' or '$x =~ "(..)_(...)" or even '1+2'.

  • For mlr put, bare booleans are no-ops; except side-effects (like regex-captures)
  • For mlr filter, they set the filter condition only if they're the last statement in the main block.
  • For mlr repl, similar to mlr filter: they are used to track the output to be printed for an expression entered at the REPL prompt.

type DirectFieldRvalueNode

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

----------------------------------------------------------------

func (*DirectFieldRvalueNode) Evaluate

func (node *DirectFieldRvalueNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type DirectFieldValueLvalueNode

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

----------------------------------------------------------------

func NewDirectFieldValueLvalueNode

func NewDirectFieldValueLvalueNode(lhsFieldName *mlrval.Mlrval) *DirectFieldValueLvalueNode

func (*DirectFieldValueLvalueNode) Assign

func (node *DirectFieldValueLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*DirectFieldValueLvalueNode) AssignIndexed

func (node *DirectFieldValueLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*DirectFieldValueLvalueNode) Unassign

func (node *DirectFieldValueLvalueNode) Unassign(
	state *runtime.State,
)

func (*DirectFieldValueLvalueNode) UnassignIndexed

func (node *DirectFieldValueLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type DirectOosvarRvalueNode

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

----------------------------------------------------------------

func (*DirectOosvarRvalueNode) Evaluate

func (node *DirectOosvarRvalueNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type DirectOosvarValueLvalueNode

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

----------------------------------------------------------------

func NewDirectOosvarValueLvalueNode

func NewDirectOosvarValueLvalueNode(lhsOosvarName *mlrval.Mlrval) *DirectOosvarValueLvalueNode

func (*DirectOosvarValueLvalueNode) Assign

func (node *DirectOosvarValueLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*DirectOosvarValueLvalueNode) AssignIndexed

func (node *DirectOosvarValueLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*DirectOosvarValueLvalueNode) Unassign

func (node *DirectOosvarValueLvalueNode) Unassign(
	state *runtime.State,
)

func (*DirectOosvarValueLvalueNode) UnassignIndexed

func (node *DirectOosvarValueLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type DoWhileLoopNode

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

================================================================

func NewDoWhileLoopNode

func NewDoWhileLoopNode(
	statementBlockNode *StatementBlockNode,
	conditionNode IEvaluable,
	conditionToken *token.Token,
) *DoWhileLoopNode

func (*DoWhileLoopNode) Execute

func (node *DoWhileLoopNode) Execute(state *runtime.State) (*BlockExitPayload, error)

----------------------------------------------------------------

type DotCallsiteNode

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

---------------------------------------------------------------- DotCallsiteNode special-cases the dot operator, which is: * string + string, with coercion to string if either side is int/float/bool/etc. * map attribute access, if the left-hand side is a map.

func (*DotCallsiteNode) Evaluate

func (node *DotCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type DumpStatementNode

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

func (*DumpStatementNode) Execute

func (node *DumpStatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

----------------------------------------------------------------

type Emit1StatementNode

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

func (*Emit1StatementNode) Execute

func (node *Emit1StatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type EmitFStatementNode

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

func (*EmitFStatementNode) Execute

func (node *EmitFStatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type EmitXStatementNode

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

func (*EmitXStatementNode) Execute

func (node *EmitXStatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

================================================================

type EmptyCoalesceOperatorNode

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

================================================================ a ?? b evaluates to b only when a is absent or empty. Example: '$foo ?? 0' when the current record has no field $foo, or when $foo is empty..

func BuildEmptyCoalesceOperatorNode

func BuildEmptyCoalesceOperatorNode(a, b IEvaluable) *EmptyCoalesceOperatorNode

func (*EmptyCoalesceOperatorNode) Evaluate

func (node *EmptyCoalesceOperatorNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

This is different from most of the evaluator functions in that it does short-circuiting: the second argument is not evaluated if the first argument is not absent.

type EnvironmentVariableLvalueNode

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

----------------------------------------------------------------

func NewEnvironmentVariableLvalueNode

func NewEnvironmentVariableLvalueNode(
	nameExpression IEvaluable,
) *EnvironmentVariableLvalueNode

func (*EnvironmentVariableLvalueNode) Assign

func (node *EnvironmentVariableLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*EnvironmentVariableLvalueNode) AssignIndexed

func (node *EnvironmentVariableLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*EnvironmentVariableLvalueNode) Unassign

func (node *EnvironmentVariableLvalueNode) Unassign(
	state *runtime.State,
)

func (*EnvironmentVariableLvalueNode) UnassignIndexed

func (node *EnvironmentVariableLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type EnvironmentVariableNode

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

func (*EnvironmentVariableNode) Evaluate

func (node *EnvironmentVariableNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type EvaluablePair

type EvaluablePair struct {
	Key   IEvaluable
	Value IEvaluable
}

func NewEvaluablePair

func NewEvaluablePair(key IEvaluable, value IEvaluable) *EvaluablePair

type Executor

type Executor func(state *runtime.State) (*BlockExitPayload, error)

type FILENAMENode

type FILENAMENode struct {
}

----------------------------------------------------------------

func (*FILENAMENode) Evaluate

func (node *FILENAMENode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type FILENUMNode

type FILENUMNode struct {
}

----------------------------------------------------------------

func (*FILENUMNode) Evaluate

func (node *FILENUMNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type FLATSEPNode

type FLATSEPNode struct {
}

----------------------------------------------------------------

func (*FLATSEPNode) Evaluate

func (node *FLATSEPNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type FNRNode

type FNRNode struct {
}

----------------------------------------------------------------

func (*FNRNode) Evaluate

func (node *FNRNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type FilterStatementNode

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

func (*FilterStatementNode) Execute

func (node *FilterStatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type FloatLiteralNode

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

----------------------------------------------------------------

func (*FloatLiteralNode) Evaluate

func (node *FloatLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type ForLoopMultivariableNode

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

================================================================

func NewForLoopMultivariableNode

func NewForLoopMultivariableNode(
	keyIndexVariables []*runtime.StackVariable,
	valueIndexVariable *runtime.StackVariable,
	indexableNode IEvaluable,
	statementBlockNode *StatementBlockNode,
) *ForLoopMultivariableNode

func (*ForLoopMultivariableNode) Execute

func (node *ForLoopMultivariableNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type ForLoopOneVariableNode

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

================================================================

func NewForLoopOneVariableNode

func NewForLoopOneVariableNode(
	variableName string,
	indexableNode IEvaluable,
	statementBlockNode *StatementBlockNode,
) *ForLoopOneVariableNode

func (*ForLoopOneVariableNode) Execute

func (node *ForLoopOneVariableNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type ForLoopTwoVariableNode

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

================================================================

func NewForLoopTwoVariableNode

func NewForLoopTwoVariableNode(
	keyIndexVariable *runtime.StackVariable,
	valueIndexVariable *runtime.StackVariable,
	indexableNode IEvaluable,
	statementBlockNode *StatementBlockNode,
) *ForLoopTwoVariableNode

func (*ForLoopTwoVariableNode) Execute

func (node *ForLoopTwoVariableNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type FullOosvarLvalueNode

type FullOosvarLvalueNode struct {
}

----------------------------------------------------------------

func NewFullOosvarLvalueNode

func NewFullOosvarLvalueNode() *FullOosvarLvalueNode

func (*FullOosvarLvalueNode) Assign

func (node *FullOosvarLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*FullOosvarLvalueNode) AssignIndexed

func (node *FullOosvarLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*FullOosvarLvalueNode) Unassign

func (node *FullOosvarLvalueNode) Unassign(
	state *runtime.State,
)

func (*FullOosvarLvalueNode) UnassignIndexed

func (node *FullOosvarLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type FullOosvarRvalueNode

type FullOosvarRvalueNode struct {
}

----------------------------------------------------------------

func (*FullOosvarRvalueNode) Evaluate

func (node *FullOosvarRvalueNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type FullSrecLvalueNode

type FullSrecLvalueNode struct {
}

----------------------------------------------------------------

func NewFullSrecLvalueNode

func NewFullSrecLvalueNode() *FullSrecLvalueNode

func (*FullSrecLvalueNode) Assign

func (node *FullSrecLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*FullSrecLvalueNode) AssignIndexed

func (node *FullSrecLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*FullSrecLvalueNode) Unassign

func (node *FullSrecLvalueNode) Unassign(
	state *runtime.State,
)

func (*FullSrecLvalueNode) UnassignIndexed

func (node *FullSrecLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type FullSrecRvalueNode

type FullSrecRvalueNode struct {
}

----------------------------------------------------------------

func (*FullSrecRvalueNode) Evaluate

func (node *FullSrecRvalueNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type IAssignable

type IAssignable interface {
	Assign(rvalue *mlrval.Mlrval, state *runtime.State) error

	// 'foo = "bar"' or 'foo[3]["abc"] = "bar"'
	// For non-indexed assignment, which is the normal case, indices can be
	// zero-length or nil.
	AssignIndexed(rvalue *mlrval.Mlrval, indices []*mlrval.Mlrval, state *runtime.State) error

	Unassign(state *runtime.State)

	UnassignIndexed(indices []*mlrval.Mlrval, state *runtime.State)
}

================================================================ This is for any left-hand side (LHS or Lvalue) of an assignment statement.

type IEvaluable

type IEvaluable interface {
	Evaluate(state *runtime.State) *mlrval.Mlrval
}

================================================================ This is for any right-hand side (RHS or Rvalue) of an assignment statement. Also, for computed field names on the left-hand side, like '$a . $b' in mlr put '$[$a . $b]' = $x + $y'.

func BuildZaryFunctionCallsiteNode

func BuildZaryFunctionCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

type IExecutable

type IExecutable interface {
	Execute(state *runtime.State) (*BlockExitPayload, error)
}

---------------------------------------------------------------- This is for all statements and statement blocks within the CST.

type IFSNode

type IFSNode struct {
}

----------------------------------------------------------------

func (*IFSNode) Evaluate

func (node *IFSNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type IPSNode

type IPSNode struct {
}

----------------------------------------------------------------

func (*IPSNode) Evaluate

func (node *IPSNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type IRSNode

type IRSNode struct {
}

----------------------------------------------------------------

func (*IRSNode) Evaluate

func (node *IRSNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type IfChainNode

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

----------------------------------------------------------------

func NewIfChainNode

func NewIfChainNode(ifItems []*IfItem) *IfChainNode

func (*IfChainNode) Execute

func (node *IfChainNode) Execute(state *runtime.State) (*BlockExitPayload, error)

----------------------------------------------------------------

type IfItem

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

---------------------------------------------------------------- For each if/elif/elif/else portion: the conditional part (...) and the statement-block part {...}. For "else", the conditional is nil.

type IndexedLvalueNode

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

----------------------------------------------------------------

func NewIndexedLvalueNode

func NewIndexedLvalueNode(
	baseLvalue IAssignable,
	indexEvaluables []IEvaluable,
) *IndexedLvalueNode

func (*IndexedLvalueNode) Assign

func (node *IndexedLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

Computes Lvalue indices and then delegates to the baseLvalue. E.g. for '$x[1][2] = 3' or '@x[1][2] = 3', the indices are [1,2], and the baseLvalue is '$x' or '@x' respectively.

func (*IndexedLvalueNode) AssignIndexed

func (node *IndexedLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*IndexedLvalueNode) Unassign

func (node *IndexedLvalueNode) Unassign(
	state *runtime.State,
)

func (*IndexedLvalueNode) UnassignIndexed

func (node *IndexedLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type IndirectFieldValueLvalueNode

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

----------------------------------------------------------------

func NewIndirectFieldValueLvalueNode

func NewIndirectFieldValueLvalueNode(
	lhsFieldNameExpression IEvaluable,
) *IndirectFieldValueLvalueNode

func (*IndirectFieldValueLvalueNode) Assign

func (node *IndirectFieldValueLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*IndirectFieldValueLvalueNode) AssignIndexed

func (node *IndirectFieldValueLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*IndirectFieldValueLvalueNode) Unassign

func (node *IndirectFieldValueLvalueNode) Unassign(
	state *runtime.State,
)

func (*IndirectFieldValueLvalueNode) UnassignIndexed

func (node *IndirectFieldValueLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type IndirectFieldValueNode

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

----------------------------------------------------------------

func (*IndirectFieldValueNode) Evaluate

func (node *IndirectFieldValueNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type IndirectOosvarValueLvalueNode

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

----------------------------------------------------------------

func NewIndirectOosvarValueLvalueNode

func NewIndirectOosvarValueLvalueNode(
	lhsOosvarNameExpression IEvaluable,
) *IndirectOosvarValueLvalueNode

func (*IndirectOosvarValueLvalueNode) Assign

func (node *IndirectOosvarValueLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*IndirectOosvarValueLvalueNode) AssignIndexed

func (node *IndirectOosvarValueLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*IndirectOosvarValueLvalueNode) Unassign

func (node *IndirectOosvarValueLvalueNode) Unassign(
	state *runtime.State,
)

func (*IndirectOosvarValueLvalueNode) UnassignIndexed

func (node *IndirectOosvarValueLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type IndirectOosvarValueNode

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

----------------------------------------------------------------

func (*IndirectOosvarValueNode) Evaluate

func (node *IndirectOosvarValueNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type IntLiteralNode

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

----------------------------------------------------------------

func (*IntLiteralNode) Evaluate

func (node *IntLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type LiteralEmptyStringNode

type LiteralEmptyStringNode struct {
}

================================================================

func (*LiteralEmptyStringNode) Evaluate

func (node *LiteralEmptyStringNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type LiteralOneNode

type LiteralOneNode struct {
}

================================================================

func (*LiteralOneNode) Evaluate

func (node *LiteralOneNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type LocalVariableLvalueNode

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

----------------------------------------------------------------

func NewLocalVariableLvalueNode

func NewLocalVariableLvalueNode(
	stackVariable *runtime.StackVariable,
	typeName string,
	defineTypedAtScope bool,
) *LocalVariableLvalueNode

func (*LocalVariableLvalueNode) Assign

func (node *LocalVariableLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*LocalVariableLvalueNode) AssignIndexed

func (node *LocalVariableLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*LocalVariableLvalueNode) Unassign

func (node *LocalVariableLvalueNode) Unassign(
	state *runtime.State,
)

func (*LocalVariableLvalueNode) UnassignIndexed

func (node *LocalVariableLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type LocalVariableNode

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

func (*LocalVariableNode) Evaluate

func (node *LocalVariableNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type LogicalANDOperatorNode

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

================================================================

func BuildLogicalANDOperatorNode

func BuildLogicalANDOperatorNode(a, b IEvaluable) *LogicalANDOperatorNode

func (*LogicalANDOperatorNode) Evaluate

func (node *LogicalANDOperatorNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type LogicalOROperatorNode

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

================================================================

func BuildLogicalOROperatorNode

func BuildLogicalOROperatorNode(a, b IEvaluable) *LogicalOROperatorNode

func (*LogicalOROperatorNode) Evaluate

func (node *LogicalOROperatorNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type MapLiteralNode

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

----------------------------------------------------------------

func (*MapLiteralNode) Evaluate

func (node *MapLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type MathENode

type MathENode struct {
}

----------------------------------------------------------------

func (*MathENode) Evaluate

func (node *MathENode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type MathPINode

type MathPINode struct {
}

----------------------------------------------------------------

func (*MathPINode) Evaluate

func (node *MathPINode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type MlrvalLiteralNode

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

func BuildMlrvalLiteralNode

func BuildMlrvalLiteralNode(literal *mlrval.Mlrval) *MlrvalLiteralNode

func (*MlrvalLiteralNode) Evaluate

func (node *MlrvalLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type NFNode

type NFNode struct {
}

----------------------------------------------------------------

func (*NFNode) Evaluate

func (node *NFNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type NRNode

type NRNode struct {
}

----------------------------------------------------------------

func (*NRNode) Evaluate

func (node *NRNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type NodeBuilder

type NodeBuilder func(astNode *dsl.ASTNode) (IEvaluable, error)

---------------------------------------------------------------- Many functions have this signature. This type-alias is for function-name lookup tables.

type NullLiteralNode

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

----------------------------------------------------------------

func (*NullLiteralNode) Evaluate

func (node *NullLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type OFSNode

type OFSNode struct {
}

----------------------------------------------------------------

func (*OFSNode) Evaluate

func (node *OFSNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type OPSNode

type OPSNode struct {
}

----------------------------------------------------------------

func (*OPSNode) Evaluate

func (node *OPSNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type ORSNode

type ORSNode struct {
}

----------------------------------------------------------------

func (*ORSNode) Evaluate

func (node *ORSNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type PanicNode

type PanicNode struct {
}

func (*PanicNode) Evaluate

func (node *PanicNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type PositionalFieldNameLvalueNode

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

func NewPositionalFieldNameLvalueNode

func NewPositionalFieldNameLvalueNode(
	lhsFieldIndexExpression IEvaluable,
) *PositionalFieldNameLvalueNode

func (*PositionalFieldNameLvalueNode) Assign

func (node *PositionalFieldNameLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*PositionalFieldNameLvalueNode) AssignIndexed

func (node *PositionalFieldNameLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*PositionalFieldNameLvalueNode) Unassign

func (node *PositionalFieldNameLvalueNode) Unassign(
	state *runtime.State,
)

func (*PositionalFieldNameLvalueNode) UnassignIndexed

func (node *PositionalFieldNameLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type PositionalFieldNameNode

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

func (*PositionalFieldNameNode) Evaluate

func (node *PositionalFieldNameNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

TODO: code-dedupe these next four Evaluate methods

type PositionalFieldValueLvalueNode

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

func NewPositionalFieldValueLvalueNode

func NewPositionalFieldValueLvalueNode(
	lhsFieldIndexExpression IEvaluable,
) *PositionalFieldValueLvalueNode

func (*PositionalFieldValueLvalueNode) Assign

func (node *PositionalFieldValueLvalueNode) Assign(
	rvalue *mlrval.Mlrval,
	state *runtime.State,
) error

func (*PositionalFieldValueLvalueNode) AssignIndexed

func (node *PositionalFieldValueLvalueNode) AssignIndexed(
	rvalue *mlrval.Mlrval,
	indices []*mlrval.Mlrval,
	state *runtime.State,
) error

func (*PositionalFieldValueLvalueNode) Unassign

func (node *PositionalFieldValueLvalueNode) Unassign(
	state *runtime.State,
)

Same code as PositionalFieldNameLvalueNode. May as well let them do 'unset $[[[7]]]' as well as $[[7]]'.

func (*PositionalFieldValueLvalueNode) UnassignIndexed

func (node *PositionalFieldValueLvalueNode) UnassignIndexed(
	indices []*mlrval.Mlrval,
	state *runtime.State,
)

type PositionalFieldValueNode

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

func (*PositionalFieldValueNode) Evaluate

func (node *PositionalFieldValueNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type PrintStatementNode

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

func (*PrintStatementNode) Execute

func (node *PrintStatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

----------------------------------------------------------------

type RegexCaptureBinaryFunctionCallsiteNode

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

---------------------------------------------------------------- RegexCaptureBinaryFunctionCallsiteNode special-cases the =~ and !=~ operators which set the CST State object's captures array for "\1".."\9". This is identical to BinaryFunctionCallsite except that BinaryFunctionCallsite's impl function takes two *mlrval.Mlrval arguments and returns a *mlrval.Mlrval, whereas RegexCaptureBinaryFunctionCallsiteNode's impl function takes two *mlrval.Mlrval arguments but returns *mlrval.Mlrval along with a []string captures array. The captures are stored in the State object for use in subsequent statements.

Note the use of "capture" is ambiguous:

  • There is the regex-match part which captures submatches out of a full match expression, and saves them.

* Then there is the part which inserts these captures into another string.

  • For sub/gsub, the former and latter are both within the sub/gsub routine. E.g. with $y = sub($x, "(..)_(...)", "\2:\1" and $x being "ab_cde", $y will be "cde:ab".

  • For =~ and !=~, the former are right there, but the latter can be several lines later. E.g. if ($x =~ "(..)_(...)") { ... other lines of code ... $y = "\2:\1"; }

So: this RegexCaptureBinaryFunctionCallsiteNode only refers to the =~ and !=~ callsites only -- not sub/gsub, and not the capture-using replacement statements like '$y = "\2:\1".

func (*RegexCaptureBinaryFunctionCallsiteNode) Evaluate

type RegexCaptureReplacementNode

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

RegexCaptureReplacementNode is for any string literal that has any "\0" .. "\9" in it. As of the original design of Miller, submatches are captured in one place and interpolated in another. For example:

if ($x =~ "(..)_(...)" {
  ... other lines of code ...
  $y = "\2:\1";
}

This node type is for things like "\2:\1". They can occur quite far from the =~ callsite so we need to check all string literals to see if they have "\0" .. "\9" anywhere within them. If they do, we precompute a replacementCaptureMatrix which is basically compiled information about the replacement string -- the start/end offsets of the "\1", "\2", etc substrings.

func (*RegexCaptureReplacementNode) Evaluate

func (node *RegexCaptureReplacementNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

As noted above, in things like

if ($x =~ "(..)_(...)" {
  ... other lines of code ...
  $y = "\2:\1";
}

the captures can be set (by =~ or !=~) quite far from where they are used. This is why we consult the state's regex captures here, to see if they've been set on some previous invocation of =~ or !=~.

type RegexLiteralNode

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

func (*RegexLiteralNode) Evaluate

func (node *RegexLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type ReturnNode

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

----------------------------------------------------------------

func (*ReturnNode) Execute

func (node *ReturnNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type RootNode

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

---------------------------------------------------------------- Please see root.go for context and comments.

func NewEmptyRoot

func NewEmptyRoot(
	recordWriterOptions *cli.TWriterOptions,
	dslInstanceType DSLInstanceType,
) *RootNode

NewEmptyRoot sets up an empty CST, before ingesting any DSL strings. For mlr put and mlr filter, CSTs are constructed, then ASTs are ingested from DSL strings. For the REPL, a CST is constructed once, then an AST is ingested on every line of input from the REPL.

func (*RootNode) Build

func (root *RootNode) Build(
	dslStrings []string,
	dslInstanceType DSLInstanceType,
	isReplImmediate bool,
	doWarnings bool,
	astBuildVisitorFunc ASTBuildVisitorFunc,
) (hadWarnings bool, err error)

Used by DSL -> AST -> CST callsites including mlr put, mlr filter, and mlr repl. The RootNode must be separately instantiated (e.g. NewEmptyRoot()) since the CST is partially reset on every line of input from the REPL prompt.

func (*RootNode) BuildAndInstallUDF

func (root *RootNode) BuildAndInstallUDF(astNode *dsl.ASTNode) error

BuildAndInstallUDF is for named UDFs, like `func f(a, b) { return b - a}'.

func (*RootNode) BuildAndInstallUDS

func (root *RootNode) BuildAndInstallUDS(astNode *dsl.ASTNode) error

func (*RootNode) BuildArrayLiteralNode

func (node *RootNode) BuildArrayLiteralNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildArrayOrMapIndexAccessNode

func (node *RootNode) BuildArrayOrMapIndexAccessNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildArrayOrMapPositionalNameAccessNode

func (node *RootNode) BuildArrayOrMapPositionalNameAccessNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildArrayOrMapPositionalValueAccessNode

func (node *RootNode) BuildArrayOrMapPositionalValueAccessNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildArraySliceAccessNode

func (node *RootNode) BuildArraySliceAccessNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildArraySliceEmptyLowerIndexNode

func (root *RootNode) BuildArraySliceEmptyLowerIndexNode(
	astNode *dsl.ASTNode,
) (*LiteralOneNode, error)

In array slices like 'myarray[:4]', the lower index is always 1 since Miller user-space indices are 1-up.

func (*RootNode) BuildArraySliceEmptyUpperIndexNode

func (root *RootNode) BuildArraySliceEmptyUpperIndexNode(
	astNode *dsl.ASTNode,
) (*LiteralEmptyStringNode, error)

In array slices like 'myarray[4:]', the upper index is always n, where n is the length of the array, since Miller user-space indices are 1-up. However, we don't have access to the array length in this AST node so we return "" so the slice-index CST node can compute it.

func (*RootNode) BuildAssignableNode

func (root *RootNode) BuildAssignableNode(
	astNode *dsl.ASTNode,
) (IAssignable, error)

----------------------------------------------------------------

func (*RootNode) BuildAssignmentNode

func (root *RootNode) BuildAssignmentNode(
	astNode *dsl.ASTNode,
) (*AssignmentNode, error)

================================================================

func (*RootNode) BuildBareBooleanStatementNode

func (root *RootNode) BuildBareBooleanStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

----------------------------------------------------------------

func (*RootNode) BuildBinaryFunctionCallsiteNode

func (root *RootNode) BuildBinaryFunctionCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildBinaryFunctionWithStateCallsiteNode

func (root *RootNode) BuildBinaryFunctionWithStateCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildBoolLiteralNode

func (root *RootNode) BuildBoolLiteralNode(literal string) *BoolLiteralNode

func (*RootNode) BuildBreakNode

func (root *RootNode) BuildBreakNode(astNode *dsl.ASTNode) (*BreakNode, error)

func (*RootNode) BuildBuiltinFunctionCallsiteNode

func (root *RootNode) BuildBuiltinFunctionCallsiteNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

----------------------------------------------------------------

func (*RootNode) BuildCondBlockNode

func (root *RootNode) BuildCondBlockNode(astNode *dsl.ASTNode) (*CondBlockNode, error)

func (*RootNode) BuildConstantNode

func (root *RootNode) BuildConstantNode(astNode *dsl.ASTNode) (IEvaluable, error)

================================================================

func (*RootNode) BuildContextVariableNode

func (root *RootNode) BuildContextVariableNode(astNode *dsl.ASTNode) (IEvaluable, error)

================================================================

func (*RootNode) BuildContinueNode

func (root *RootNode) BuildContinueNode(astNode *dsl.ASTNode) (*ContinueNode, error)

func (*RootNode) BuildDirectFieldRvalueNode

func (root *RootNode) BuildDirectFieldRvalueNode(fieldName string) *DirectFieldRvalueNode

func (*RootNode) BuildDirectFieldValueLvalueNode

func (root *RootNode) BuildDirectFieldValueLvalueNode(
	astNode *dsl.ASTNode,
) (IAssignable, error)

func (*RootNode) BuildDirectOosvarRvalueNode

func (root *RootNode) BuildDirectOosvarRvalueNode(variableName string) *DirectOosvarRvalueNode

func (*RootNode) BuildDirectOosvarValueLvalueNode

func (root *RootNode) BuildDirectOosvarValueLvalueNode(astNode *dsl.ASTNode) (IAssignable, error)

func (*RootNode) BuildDoWhileLoopNode

func (root *RootNode) BuildDoWhileLoopNode(astNode *dsl.ASTNode) (*DoWhileLoopNode, error)

func (*RootNode) BuildDotCallsiteNode

func (root *RootNode) BuildDotCallsiteNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildDottedLvalueNode

func (root *RootNode) BuildDottedLvalueNode(astNode *dsl.ASTNode) (IAssignable, error)

BuildDottedLvalueNode is basically the same as BuildIndexedLvalueNode except at the syntax level: 'mymap["x"]["y"]' is the same as 'mymap.x.y'.

func (*RootNode) BuildDumpStatementNode

func (root *RootNode) BuildDumpStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

----------------------------------------------------------------

func (*RootNode) BuildEdumpStatementNode

func (root *RootNode) BuildEdumpStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildEmit1StatementNode

func (root *RootNode) BuildEmit1StatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildEmitFStatementNode

func (root *RootNode) BuildEmitFStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildEmitPStatementNode

func (root *RootNode) BuildEmitPStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildEmitStatementNode

func (root *RootNode) BuildEmitStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildEnvironmentVariableLvalueNode

func (root *RootNode) BuildEnvironmentVariableLvalueNode(astNode *dsl.ASTNode) (IAssignable, error)

func (*RootNode) BuildEnvironmentVariableNode

func (root *RootNode) BuildEnvironmentVariableNode(astNode *dsl.ASTNode) (*EnvironmentVariableNode, error)

func (*RootNode) BuildEprintStatementNode

func (root *RootNode) BuildEprintStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildEprintnStatementNode

func (root *RootNode) BuildEprintnStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildEvaluableNode

func (root *RootNode) BuildEvaluableNode(astNode *dsl.ASTNode) (IEvaluable, error)

----------------------------------------------------------------

func (*RootNode) BuildFILENAMENode

func (root *RootNode) BuildFILENAMENode() *FILENAMENode

func (*RootNode) BuildFILENUMNode

func (root *RootNode) BuildFILENUMNode() *FILENUMNode

func (*RootNode) BuildFLATSEPNode

func (root *RootNode) BuildFLATSEPNode() *FLATSEPNode

func (*RootNode) BuildFNRNode

func (root *RootNode) BuildFNRNode() *FNRNode

func (*RootNode) BuildFilterStatementNode

func (root *RootNode) BuildFilterStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildFloatLiteralNode

func (root *RootNode) BuildFloatLiteralNode(literal string) *FloatLiteralNode

func (*RootNode) BuildForLoopMultivariableNode

func (root *RootNode) BuildForLoopMultivariableNode(
	astNode *dsl.ASTNode,
) (*ForLoopMultivariableNode, error)

func (*RootNode) BuildForLoopOneVariableNode

func (root *RootNode) BuildForLoopOneVariableNode(astNode *dsl.ASTNode) (*ForLoopOneVariableNode, error)

func (*RootNode) BuildForLoopTwoVariableNode

func (root *RootNode) BuildForLoopTwoVariableNode(astNode *dsl.ASTNode) (*ForLoopTwoVariableNode, error)

func (*RootNode) BuildFullOosvarLvalueNode

func (root *RootNode) BuildFullOosvarLvalueNode(astNode *dsl.ASTNode) (IAssignable, error)

func (*RootNode) BuildFullOosvarRvalueNode

func (root *RootNode) BuildFullOosvarRvalueNode() *FullOosvarRvalueNode

func (*RootNode) BuildFullSrecLvalueNode

func (root *RootNode) BuildFullSrecLvalueNode(astNode *dsl.ASTNode) (IAssignable, error)

func (*RootNode) BuildFullSrecRvalueNode

func (root *RootNode) BuildFullSrecRvalueNode() *FullSrecRvalueNode

func (*RootNode) BuildFunctionCallsiteNode

func (root *RootNode) BuildFunctionCallsiteNode(astNode *dsl.ASTNode) (IEvaluable, error)

func (*RootNode) BuildIFSNode

func (root *RootNode) BuildIFSNode() *IFSNode

func (*RootNode) BuildIPSNode

func (root *RootNode) BuildIPSNode() *IPSNode

func (*RootNode) BuildIRSNode

func (root *RootNode) BuildIRSNode() *IRSNode

func (*RootNode) BuildIfChainNode

func (root *RootNode) BuildIfChainNode(astNode *dsl.ASTNode) (*IfChainNode, error)

func (*RootNode) BuildIndexedLvalueNode

func (root *RootNode) BuildIndexedLvalueNode(astNode *dsl.ASTNode) (IAssignable, error)

Either 'mymap["attr"]' or 'mymap.attr'. Furthermore they can be mixed as in 'mymap["foo"].bar' or 'mymap.foo["bar"]'.

func (*RootNode) BuildIndirectFieldValueLvalueNode

func (root *RootNode) BuildIndirectFieldValueLvalueNode(
	astNode *dsl.ASTNode,
) (IAssignable, error)

func (*RootNode) BuildIndirectFieldValueNode

func (root *RootNode) BuildIndirectFieldValueNode(
	astNode *dsl.ASTNode,
) (*IndirectFieldValueNode, error)

func (*RootNode) BuildIndirectOosvarValueLvalueNode

func (root *RootNode) BuildIndirectOosvarValueLvalueNode(
	astNode *dsl.ASTNode,
) (IAssignable, error)

func (*RootNode) BuildIndirectOosvarValueNode

func (root *RootNode) BuildIndirectOosvarValueNode(
	astNode *dsl.ASTNode,
) (*IndirectOosvarValueNode, error)

func (*RootNode) BuildIntLiteralNode

func (root *RootNode) BuildIntLiteralNode(literal string) *IntLiteralNode

func (*RootNode) BuildLeafNode

func (root *RootNode) BuildLeafNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

----------------------------------------------------------------

func (*RootNode) BuildLocalVariableLvalueNode

func (root *RootNode) BuildLocalVariableLvalueNode(astNode *dsl.ASTNode) (IAssignable, error)

func (*RootNode) BuildLocalVariableNode

func (root *RootNode) BuildLocalVariableNode(variableName string) *LocalVariableNode

func (*RootNode) BuildMapLiteralNode

func (node *RootNode) BuildMapLiteralNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildMathENode

func (root *RootNode) BuildMathENode() *MathENode

func (*RootNode) BuildMathPINode

func (root *RootNode) BuildMathPINode() *MathPINode

func (*RootNode) BuildMultipleArityFunctionCallsiteNode

func (root *RootNode) BuildMultipleArityFunctionCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

----------------------------------------------------------------

func (*RootNode) BuildNFNode

func (root *RootNode) BuildNFNode() *NFNode

func (*RootNode) BuildNRNode

func (root *RootNode) BuildNRNode() *NRNode

func (*RootNode) BuildNullLiteralNode

func (root *RootNode) BuildNullLiteralNode() *NullLiteralNode

func (*RootNode) BuildOFSNode

func (root *RootNode) BuildOFSNode() *OFSNode

func (*RootNode) BuildOPSNode

func (root *RootNode) BuildOPSNode() *OPSNode

func (*RootNode) BuildORSNode

func (root *RootNode) BuildORSNode() *ORSNode

func (*RootNode) BuildPanicNode

func (root *RootNode) BuildPanicNode(astNode *dsl.ASTNode) (*PanicNode, error)

func (*RootNode) BuildPositionalFieldNameLvalueNode

func (root *RootNode) BuildPositionalFieldNameLvalueNode(
	astNode *dsl.ASTNode,
) (IAssignable, error)

func (*RootNode) BuildPositionalFieldNameNode

func (node *RootNode) BuildPositionalFieldNameNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildPositionalFieldValueLvalueNode

func (root *RootNode) BuildPositionalFieldValueLvalueNode(
	astNode *dsl.ASTNode,
) (IAssignable, error)

func (*RootNode) BuildPositionalFieldValueNode

func (node *RootNode) BuildPositionalFieldValueNode(
	astNode *dsl.ASTNode,
) (IEvaluable, error)

func (*RootNode) BuildPrintStatementNode

func (root *RootNode) BuildPrintStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

----------------------------------------------------------------

func (*RootNode) BuildPrintnStatementNode

func (root *RootNode) BuildPrintnStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildRegexCaptureBinaryFunctionCallsiteNode

func (root *RootNode) BuildRegexCaptureBinaryFunctionCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildRegexLiteralNode

func (root *RootNode) BuildRegexLiteralNode(literal string) IEvaluable

func (*RootNode) BuildReturnNode

func (root *RootNode) BuildReturnNode(astNode *dsl.ASTNode) (*ReturnNode, error)

func (*RootNode) BuildStatementBlockNode

func (root *RootNode) BuildStatementBlockNode(
	astNode *dsl.ASTNode,
) (*StatementBlockNode, error)

----------------------------------------------------------------

func (*RootNode) BuildStatementBlockNodeFromBeginOrEnd

func (root *RootNode) BuildStatementBlockNodeFromBeginOrEnd(
	astBeginOrEndNode *dsl.ASTNode,
) (*StatementBlockNode, error)

----------------------------------------------------------------

func (*RootNode) BuildStatementNode

func (root *RootNode) BuildStatementNode(
	astNode *dsl.ASTNode,
) (IExecutable, error)

----------------------------------------------------------------

func (*RootNode) BuildStringLiteralNode

func (root *RootNode) BuildStringLiteralNode(literal string) IEvaluable

func (*RootNode) BuildSubroutineCallsiteNode

func (root *RootNode) BuildSubroutineCallsiteNode(astNode *dsl.ASTNode) (IExecutable, error)

func (*RootNode) BuildTeeStatementNode

func (root *RootNode) BuildTeeStatementNode(astNode *dsl.ASTNode) (IExecutable, error)

----------------------------------------------------------------

func (*RootNode) BuildTernaryFunctionCallsiteNode

func (root *RootNode) BuildTernaryFunctionCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildTernaryFunctionWithStateCallsiteNode

func (root *RootNode) BuildTernaryFunctionWithStateCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildTripleForLoopNode

func (root *RootNode) BuildTripleForLoopNode(astNode *dsl.ASTNode) (*TripleForLoopNode, error)

func (*RootNode) BuildUDF

func (root *RootNode) BuildUDF(
	astNode *dsl.ASTNode,
	functionName string,
	isFunctionLiteral bool,
) (*UDF, error)

BuildUDF is for named UDFs, like `func f(a, b) { return b - a}', or, unnamed UDFs like `func (a, b) { return b - a }'.

func (*RootNode) BuildUnaryFunctionCallsiteNode

func (root *RootNode) BuildUnaryFunctionCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildUnaryFunctionWithContextCallsiteNode

func (root *RootNode) BuildUnaryFunctionWithContextCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildUnnamedUDFNode

func (root *RootNode) BuildUnnamedUDFNode(astNode *dsl.ASTNode) (IEvaluable, error)

func (*RootNode) BuildUnsetNode

func (root *RootNode) BuildUnsetNode(
	astNode *dsl.ASTNode,
) (*UnsetNode, error)

================================================================

func (*RootNode) BuildVariadicFunctionCallsiteNode

func (root *RootNode) BuildVariadicFunctionCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildVariadicFunctionWithStateCallsiteNode

func (root *RootNode) BuildVariadicFunctionWithStateCallsiteNode(
	astNode *dsl.ASTNode,
	builtinFunctionInfo *BuiltinFunctionInfo,
) (IEvaluable, error)

func (*RootNode) BuildWhileLoopNode

func (root *RootNode) BuildWhileLoopNode(astNode *dsl.ASTNode) (*WhileLoopNode, error)

func (*RootNode) ExecuteBeginBlocks

func (root *RootNode) ExecuteBeginBlocks(state *runtime.State) error

func (*RootNode) ExecuteEndBlocks

func (root *RootNode) ExecuteEndBlocks(state *runtime.State) error

func (*RootNode) ExecuteMainBlock

func (root *RootNode) ExecuteMainBlock(state *runtime.State) (outrec *mlrval.Mlrmap, err error)

func (*RootNode) ExecuteREPLImmediate

func (root *RootNode) ExecuteREPLImmediate(state *runtime.State) (outrec *mlrval.Mlrmap, err error)

This is the 'execute once' part of that.

func (*RootNode) IngestAST

func (root *RootNode) IngestAST(
	ast *dsl.AST,

	isReplImmediate bool,
	doWarnings bool,
) (hadWarnings bool, err error)

If the user has multiple put -f / put -e pieces, we can AST-parse each separately and build them. However we cannot resolve UDF/UDS references until after they're all ingested -- e.g. first piece calls a function which the second defines, or mutual recursion across pieces, etc.

func (*RootNode) ProcessEndOfStream

func (root *RootNode) ProcessEndOfStream()

func (*RootNode) RegisterOutputHandlerManager

func (root *RootNode) RegisterOutputHandlerManager(
	outputHandlerManager output.OutputHandlerManager,
)

func (*RootNode) ResetBeginBlocksForREPL

func (root *RootNode) ResetBeginBlocksForREPL()

This is for the REPL's resetblocks command.

func (*RootNode) ResetEndBlocksForREPL

func (root *RootNode) ResetEndBlocksForREPL()

This is for the REPL's resetblocks command.

func (*RootNode) ResetForREPL

func (root *RootNode) ResetForREPL()

This is the 'and then discarded' part of that.

func (*RootNode) ResetMainBlockForREPL

func (root *RootNode) ResetMainBlockForREPL()

This is for the REPL's resetblocks command.

func (*RootNode) Resolve

func (root *RootNode) Resolve() error

Resolve is called after IngestAST has been called one or more times. See comments above IngestAST.

func (*RootNode) ShowBlockReport

func (root *RootNode) ShowBlockReport()

This is for the REPL's context-printer command.

func (*RootNode) WithRedefinableUDFUDS

func (root *RootNode) WithRedefinableUDFUDS() *RootNode

Nominally for mlr put/filter we want to flag overwritten UDFs/UDSs as an error. But in the REPL, which is interactive, people should be able to redefine. This method allows the latter use-case.

func (*RootNode) WithStrictMode

func (root *RootNode) WithStrictMode(strictMode bool) *RootNode

WithStrictMode allows for runtime handling of absent-reads and untyped assignments.

type Signature

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

----------------------------------------------------------------

func NewSignature

func NewSignature(
	funcOrSubrName string,
	arity int,
	typeGatedParameterNames []*types.TypeGatedMlrvalName,
	typeGatedReturnValue *types.TypeGatedMlrvalName,
) *Signature

type StandardTernaryOperatorNode

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

================================================================

func BuildStandardTernaryOperatorNode

func BuildStandardTernaryOperatorNode(a, b, c IEvaluable) *StandardTernaryOperatorNode

func (*StandardTernaryOperatorNode) Evaluate

func (node *StandardTernaryOperatorNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type StatementBlockNode

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

---------------------------------------------------------------- Also implements IExecutable

func NewStatementBlockNode

func NewStatementBlockNode() *StatementBlockNode

----------------------------------------------------------------

func (*StatementBlockNode) AppendStatementNode

func (node *StatementBlockNode) AppendStatementNode(executable IExecutable)

----------------------------------------------------------------

func (*StatementBlockNode) Execute

func (node *StatementBlockNode) Execute(state *runtime.State) (*BlockExitPayload, error)

----------------------------------------------------------------

func (*StatementBlockNode) ExecuteFrameless

func (node *StatementBlockNode) ExecuteFrameless(state *runtime.State) (*BlockExitPayload, error)

type StringLiteralNode

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

---------------------------------------------------------------- StringLiteralNode is for any string literal that doesn't have any "\0" .. "\9" in it.

func (*StringLiteralNode) Evaluate

func (node *StringLiteralNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type TFunctionClass

type TFunctionClass string
const (
	FUNC_CLASS_ARITHMETIC  TFunctionClass = "arithmetic"
	FUNC_CLASS_MATH        TFunctionClass = "math"
	FUNC_CLASS_STATS       TFunctionClass = "stats"
	FUNC_CLASS_BOOLEAN     TFunctionClass = "boolean"
	FUNC_CLASS_STRING      TFunctionClass = "string"
	FUNC_CLASS_HASHING     TFunctionClass = "hashing"
	FUNC_CLASS_CONVERSION  TFunctionClass = "conversion"
	FUNC_CLASS_TYPING      TFunctionClass = "typing"
	FUNC_CLASS_COLLECTIONS TFunctionClass = "collections"
	FUNC_CLASS_HOFS        TFunctionClass = "higher-order-functions"
	FUNC_CLASS_SYSTEM      TFunctionClass = "system"
	FUNC_CLASS_TIME        TFunctionClass = "time"
)

type TeeStatementNode

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

func (*TeeStatementNode) Execute

func (node *TeeStatementNode) Execute(state *runtime.State) (*BlockExitPayload, error)

----------------------------------------------------------------

type TernaryFuncWithState

type TernaryFuncWithState func(
	input1 *mlrval.Mlrval,
	input2 *mlrval.Mlrval,
	input3 *mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

TernaryFuncWithState is for fold.

type TernaryFunctionCallsiteNode

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

----------------------------------------------------------------

func (*TernaryFunctionCallsiteNode) Evaluate

func (node *TernaryFunctionCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type TernaryFunctionWithStateCallsiteNode

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

----------------------------------------------------------------

func (*TernaryFunctionWithStateCallsiteNode) Evaluate

func (node *TernaryFunctionWithStateCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type TripleForLoopNode

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

================================================================

func NewTripleForLoopNode

func NewTripleForLoopNode(
	startBlockNode *StatementBlockNode,
	precontinuationAssignments []IExecutable,
	continuationExpressionNode IEvaluable,
	continuationExpressionToken *token.Token,
	updateBlockNode *StatementBlockNode,
	bodyBlockNode *StatementBlockNode,
) *TripleForLoopNode

func (*TripleForLoopNode) Execute

func (node *TripleForLoopNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type UDF

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

----------------------------------------------------------------

func NewUDF

func NewUDF(
	signature *Signature,
	functionBody *StatementBlockNode,
	isFunctionLiteral bool,
) *UDF

func NewUnresolvedUDF

func NewUnresolvedUDF(
	functionName string,
	callsiteArity int,
) *UDF

For when a function is called before being defined. This gives us something to go back and fill in later once we've encountered the function definition.

type UDFCallsite

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

----------------------------------------------------------------

func NewUDFCallsite

func NewUDFCallsite(
	argumentNodes []IEvaluable,
	udf *UDF,
) *UDFCallsite

NewUDFCallsite is for the normal UDF callsites outside of sortaf/sortmf, e.g. $z = f($a+$b, $c/2). The argument nodes are evaluables since they need to be computed, e.g. binding the field names a,b,c, evaluating the arithmetic operators, etc.

func NewUDFCallsiteForHigherOrderFunction

func NewUDFCallsiteForHigherOrderFunction(
	udf *UDF,
	arity int,
) *UDFCallsite

NewUDFCallsiteForHigherOrderFunction is for UDF callsites such as sortaf/sortmf. Here, the array/map to be sorted has already been evaluated and is an array of *mlrval.Mlrval. The UDF needs to be invoked on pairs of array elements.

func (*UDFCallsite) Evaluate

func (site *UDFCallsite) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

Evaluate is for the normal UDF callsites outside of sortaf/sortmf. See comments above NewUDFCallsite.

func (*UDFCallsite) EvaluateWithArguments

func (site *UDFCallsite) EvaluateWithArguments(
	state *runtime.State,
	udf *UDF,
	arguments []*mlrval.Mlrval,
) *mlrval.Mlrval

EvaluateWithArguments is for UDF callsites in sortaf/sortmf, where the arguments are already evaluated. Or, for normal UDF callsites, as a helper function for Evaluate.

type UDFManager

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

UDFManager tracks named UDFs like 'func f(a, b) { return b - a }'

func NewUDFManager

func NewUDFManager() *UDFManager

NewUDFManager creates an empty UDFManager.

func (*UDFManager) ExistsByName

func (manager *UDFManager) ExistsByName(name string) bool

func (*UDFManager) Install

func (manager *UDFManager) Install(udf *UDF)

func (*UDFManager) LookUp

func (manager *UDFManager) LookUp(functionName string, callsiteArity int) (*UDF, error)

LookUp is for callsites invoking UDFs whose names are known at CST-build time.

func (*UDFManager) LookUpDisregardingArity

func (manager *UDFManager) LookUpDisregardingArity(functionName string) *UDF

LookUpDisregardingArity is used for evaluating right-hand sides of 'f = udf' where f will be a local variable of type funct and udf is an existing UDF.

type UDS

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

----------------------------------------------------------------

func NewUDS

func NewUDS(
	signature *Signature,
	subroutineBody *StatementBlockNode,
) *UDS

func NewUnresolvedUDS

func NewUnresolvedUDS(
	subroutineName string,
	callsiteArity int,
) *UDS

For when a subroutine is called before being defined. This gives us something to go back and fill in later once we've encountered the subroutine definition.

type UDSCallsite

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

----------------------------------------------------------------

func NewUDSCallsite

func NewUDSCallsite(
	argumentNodes []IEvaluable,
	uds *UDS,
) *UDSCallsite

func (*UDSCallsite) Execute

func (site *UDSCallsite) Execute(state *runtime.State) (*BlockExitPayload, error)

type UDSManager

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

----------------------------------------------------------------

func NewUDSManager

func NewUDSManager() *UDSManager

func (*UDSManager) ExistsByName

func (manager *UDSManager) ExistsByName(name string) bool

func (*UDSManager) Install

func (manager *UDSManager) Install(uds *UDS)

func (*UDSManager) LookUp

func (manager *UDSManager) LookUp(subroutineName string, callsiteArity int) (*UDS, error)

type UnaryFunctionCallsiteNode

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

----------------------------------------------------------------

func (*UnaryFunctionCallsiteNode) Evaluate

func (node *UnaryFunctionCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type UnaryFunctionWithContextCallsiteNode

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

----------------------------------------------------------------

func (*UnaryFunctionWithContextCallsiteNode) Evaluate

func (node *UnaryFunctionWithContextCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type UnnamedUDFNode

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

UnnamedUDFNode holds function literals like 'func (a, b) { return b - a }'.

func (*UnnamedUDFNode) Evaluate

func (node *UnnamedUDFNode) Evaluate(state *runtime.State) *mlrval.Mlrval

type UnsetNode

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

----------------------------------------------------------------

func NewUnsetNode

func NewUnsetNode(
	lvalueNodes []IAssignable,
) *UnsetNode

func (*UnsetNode) Execute

func (node *UnsetNode) Execute(state *runtime.State) (*BlockExitPayload, error)

type VariadicFuncWithState

type VariadicFuncWithState func(
	inputs []*mlrval.Mlrval,
	state *runtime.State,
) *mlrval.Mlrval

VariadicFuncWithState is for sort.

type VariadicFunctionCallsiteNode

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

----------------------------------------------------------------

func (*VariadicFunctionCallsiteNode) Evaluate

func (node *VariadicFunctionCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

type VariadicFunctionWithStateCallsiteNode

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

----------------------------------------------------------------

func (*VariadicFunctionWithStateCallsiteNode) Evaluate

type WhileLoopNode

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

================================================================

func NewWhileLoopNode

func NewWhileLoopNode(
	conditionNode IEvaluable,
	conditionToken *token.Token,
	statementBlockNode *StatementBlockNode,
) *WhileLoopNode

func (*WhileLoopNode) Execute

func (node *WhileLoopNode) Execute(state *runtime.State) (*BlockExitPayload, error)

----------------------------------------------------------------

type ZaryFunctionCallsiteNode

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

----------------------------------------------------------------

func (*ZaryFunctionCallsiteNode) Evaluate

func (node *ZaryFunctionCallsiteNode) Evaluate(
	state *runtime.State,
) *mlrval.Mlrval

Jump to

Keyboard shortcuts

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