mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-29 02:30:12 +00:00
comment-neaten
This commit is contained in:
parent
5216662167
commit
73f60075bd
27 changed files with 142 additions and 144 deletions
|
|
@ -1,12 +1,6 @@
|
|||
! rrv --show
|
||||
|
||||
================================================================
|
||||
BUG:
|
||||
|
||||
rrv ./reg-test/cases/case-c-dsl-context-specific-validation.sh
|
||||
* mlr: filter expressions must end in a final boolean statement.
|
||||
-> abandon this requirement? doc if so.
|
||||
|
||||
rrv ./reg-test/cases/case-c-dsl-forbind-typedecl.sh
|
||||
rrv ./reg-test/cases/case-c-dsl-localvar-typedecl.sh
|
||||
rrv ./reg-test/cases/case-c-dsl-local-map-variable-typedecl.sh
|
||||
|
|
@ -25,13 +19,10 @@ MULTIPLE ISSUES:
|
|||
rrv ./reg-test/cases/case-c-dsl-functional-tests.sh
|
||||
* bug mlr filter $nosuchfield>.3 ./reg-test/input/abixy
|
||||
* ofmt
|
||||
* env
|
||||
-> split up this big case-file
|
||||
|
||||
* typeof prints different things -- regularize ...
|
||||
|
||||
* 'x=' -> MT_EMPTY vs MT_STRING
|
||||
|
||||
================================================================
|
||||
LF/CRLF ETC.
|
||||
|
||||
|
|
@ -121,6 +112,10 @@ rrv ./reg-test/cases/case-c-barred-pprint.sh
|
|||
================================================================
|
||||
BACKWARD INCOMPATIBILITIES:
|
||||
|
||||
rrv ./reg-test/cases/case-c-dsl-context-specific-validation.sh
|
||||
* mlr: filter expressions must end in a final boolean statement.
|
||||
-> abandon this requirement? doc if so.
|
||||
|
||||
rrv ./reg-test/cases/case-c-label.sh
|
||||
* handles old/new clashes differently from C impl :^/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// CST build/execute for assignment and unset statements.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -5,10 +9,6 @@ import (
|
|||
"miller/lib"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// CST build/execute for assignment and unset statements.
|
||||
// ================================================================
|
||||
|
||||
// ================================================================
|
||||
func (this *RootNode) BuildAssignmentNode(
|
||||
astNode *dsl.ASTNode,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// ================================================================
|
||||
// This is for things that get us out of statement blocks: break, continue,
|
||||
// return.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -7,11 +12,6 @@ import (
|
|||
"miller/lib"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This is for things that get us out of statement blocks: break, continue,
|
||||
// return.
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
type BreakNode struct {
|
||||
}
|
||||
|
|
@ -40,8 +40,6 @@ func (this *RootNode) BuildContinueNode(astNode *dsl.ASTNode) (*ContinueNode, er
|
|||
lib.InternalCodingErrorIf(astNode.Children == nil)
|
||||
lib.InternalCodingErrorIf(len(astNode.Children) != 0)
|
||||
|
||||
// TODO: get type-gate mask
|
||||
|
||||
return &ContinueNode{}, nil
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +79,7 @@ func (this *ReturnNode) Execute(state *State) (*BlockExitPayload, error) {
|
|||
nil,
|
||||
}, nil
|
||||
} else {
|
||||
// This can be of type MT_ERROR but there is no Go-level error return
|
||||
// This can be of type MT_ERROR but we do not use Go-level error return here
|
||||
returnValue := this.returnValueExpression.Evaluate(state) // TODO: TypeGatedMlrval
|
||||
return &BlockExitPayload{
|
||||
BLOCK_EXIT_RETURN_VALUE,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// ================================================================
|
||||
// This is for begin and end blocks, but not the main block which is direct
|
||||
// from the CST root.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -5,9 +10,6 @@ import (
|
|||
"miller/lib"
|
||||
)
|
||||
|
||||
// This is for begin and end blocks, but not the main block which is direct
|
||||
// from the CST root.
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func NewStatementBlockNode() *StatementBlockNode {
|
||||
return &StatementBlockNode{
|
||||
|
|
@ -107,10 +109,13 @@ func (this *StatementBlockNode) Execute(state *State) (*BlockExitPayload, error)
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Assumes the caller has wrapped PushStackFrame() / PopStackFrame(). That
|
||||
// could be done here, but is instead done in the caller to simplify the
|
||||
// binding of for-loop variables. In particular, in
|
||||
//
|
||||
// 'for (i = 0; i < 10; i += 1) {...}'
|
||||
//
|
||||
// the 'i = 0' and 'i += 1' are StatementBlocks and if they pushed their
|
||||
// own stack frame then the 'i=0' would be in an evanescent, isolated frame.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
// ================================================================
|
||||
// Adding a new builtin function:
|
||||
// * New entry in BUILTIN_FUNCTION_LOOKUP_TABLE
|
||||
// * Implement the function in mlrval_functions.go
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -6,12 +12,6 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// Adding a new builtin function:
|
||||
// * New entry in BUILTIN_FUNCTION_LOOKUP_TABLE
|
||||
// * Implement the function in mlrval_functions.go
|
||||
// ================================================================
|
||||
|
||||
// ================================================================
|
||||
type BuiltinFunctionInfo struct {
|
||||
name string
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// Methods for built-in functions
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -9,10 +13,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// Methods for built-in functions
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func (this *RootNode) BuildBuiltinFunctionCallsiteNode(
|
||||
astNode *dsl.ASTNode,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// ================================================================
|
||||
// CST build/execute for AST array-literal, map-literal, index-access, and
|
||||
// slice-access nodes
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -6,11 +11,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// CST build/execute for AST array-literal, map-literal, index-access, and
|
||||
// slice-access nodes
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
type ArrayLiteralNode struct {
|
||||
evaluables []IEvaluable
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// ================================================================
|
||||
// This is for awkish pattern-action-blocks, like mlr put 'NR > 10 { ... }'.
|
||||
// Just shorthand for if-statements without elif/else.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -8,11 +13,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This is for awkish pattern-action-blocks, like mlr put 'NR > 10 { ... }'.
|
||||
// Just shorthand for if-statements without elif/else.
|
||||
// ================================================================
|
||||
|
||||
type CondBlockNode struct {
|
||||
conditionNode IEvaluable
|
||||
statementBlockNode *StatementBlockNode
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// This handles emit statements.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -6,10 +10,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This handles emit statements.
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
type EmitStatementNode struct {
|
||||
emitEvaluable IEvaluable
|
||||
|
|
@ -46,8 +46,8 @@ func (this *EmitStatementNode) Execute(state *State) (*BlockExitPayload, error)
|
|||
)
|
||||
}
|
||||
|
||||
// xxx wip
|
||||
// xxx need to reshape rvalue mlvarls -> mlrmaps; publish w/ contexts; method for that
|
||||
// xxx WIP
|
||||
// xxx need to reshape rvalue mlrvals -> mlrmaps; publish w/ contexts; method for that
|
||||
|
||||
// outputChannel <- types.NewRecordAndContext(
|
||||
// mlrmap goes here,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
// ================================================================
|
||||
// This handles ENV["FOO"] on the right-hand side of an assignment. Note that
|
||||
// environment variables aren't arbitrarily indexable like maps are -- they're
|
||||
// only a single-level map from string to string, managed indirectly through
|
||||
// library routines.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -8,13 +15,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This handles ENV["FOO"] on the right-hand side of an assignment. Note that
|
||||
// environment variables aren't arbitrarily indexable like maps are -- they're
|
||||
// only a single-level map from string to string, managed indirectly through
|
||||
// library routines.
|
||||
// ================================================================
|
||||
|
||||
type EnvironmentVariableNode struct {
|
||||
nameEvaluable IEvaluable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
// ================================================================
|
||||
// This handles anything on the right-hand sides of assignment statements.
|
||||
// (Also, computed field names on the left-hand sides of assignment
|
||||
// statements.)
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -10,12 +16,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This handles anything on the right-hand sides of assignment statements.
|
||||
// (Also, computed field names on the left-hand sides of assignment
|
||||
// statements.)
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func (this *RootNode) BuildEvaluableNode(astNode *dsl.ASTNode) (IEvaluable, error) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// This handles filter statements.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -7,10 +11,6 @@ import (
|
|||
"miller/lib"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This handles filter statements.
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
type FilterStatementNode struct {
|
||||
filterEvaluable IEvaluable
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// This is for various flavors of for-loop
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -8,10 +12,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This is for various flavors of for-loop
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Sample AST:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,3 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"miller/dsl"
|
||||
"miller/lib"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// CST build/execute for AST operator/function nodes
|
||||
//
|
||||
|
|
@ -13,6 +6,13 @@ import (
|
|||
// prefix, like 'max(1,2)'. Both parse to the same AST shape.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
"miller/dsl"
|
||||
"miller/lib"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Function lookup:
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// This is for if/elif/elif/else chains.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -8,10 +12,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This is for if/elif/elif/else chains.
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
type IfChainNode struct {
|
||||
ifItems []*IfItem
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// CST build/execute for AST leaf nodes
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -9,10 +13,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// CST build/execute for AST leaf nodes
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func (this *RootNode) BuildLeafNode(
|
||||
astNode *dsl.ASTNode,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// ================================================================
|
||||
// This is for Lvalues, i.e. things on the left-hand-side of an assignment
|
||||
// statement.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -10,9 +15,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// This is for Lvalues, i.e. things on the left-hand-side of an assignment
|
||||
// statement.
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func (this *RootNode) BuildAssignableNode(
|
||||
astNode *dsl.ASTNode,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// This handles print and dump statements.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -8,10 +12,6 @@ import (
|
|||
"miller/lib"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This handles print and dump statements.
|
||||
// ================================================================
|
||||
|
||||
// ================================================================
|
||||
type DumpStatementNode struct {
|
||||
// TODO: redirect options
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// ================================================================
|
||||
// Top-level entry point for building a CST from an AST at parse time, and for
|
||||
// executing the CST at runtime.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -8,11 +13,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// Top-level entry point for building a CST from an AST at parse time, and for
|
||||
// executing the CST at runtime.
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func NewEmptyRoot() *RootNode {
|
||||
return &RootNode{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,3 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"fmt"
|
||||
|
||||
"miller/lib"
|
||||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// Stack frames for begin/end/if/for/function blocks
|
||||
//
|
||||
|
|
@ -33,6 +23,16 @@ import (
|
|||
// }
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"fmt"
|
||||
|
||||
"miller/lib"
|
||||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// STACK METHODS
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
// ================================================================
|
||||
// Tracks everything needed for statement evaluation/assignment in the Miller
|
||||
// DSL runtimne: current record/context (the latter being NF, NR, etc);
|
||||
// out-of-stream variables; local-variable stack; etc.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// ================================================================
|
||||
// CST build/execute for statements: assignments, bare booleans,
|
||||
// break/continue/return, etc.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -6,11 +11,6 @@ import (
|
|||
"miller/dsl"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// CST build/execute for statements: assignments, bare booleans,
|
||||
// break/continue/return, etc.
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func (this *RootNode) BuildStatementNode(
|
||||
astNode *dsl.ASTNode,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// Main type definitions for CST build/execute
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -7,23 +11,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// Main type definitions for CST build/execute
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// There are three CST roots: begin-block, body-block, and end-block.
|
||||
//
|
||||
// Next-level items are:
|
||||
// * srec assignments
|
||||
// * oosvar assignments
|
||||
// * localvar assignments
|
||||
// * emit et al.
|
||||
// * bare-boolean
|
||||
// * break/continue/return
|
||||
// * statement block (if-body, for-body, etc)
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// When we do mlr put '...DSL expression here...', this state is what is needed
|
||||
// to execute the expression. That includes the current record, AWK-like variables
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// Support for user-defined functions and subroutines
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -10,10 +14,6 @@ import (
|
|||
"miller/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// Support for user-defined functions and subroutines
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
type Signature struct {
|
||||
functionName string
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
// ================================================================
|
||||
// Checks for things that are syntax errors but not done in the AST for
|
||||
// pragmatic reasons. For example, $anything in begin/end blocks;
|
||||
// begin/end/func not at top level; etc.
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -7,12 +13,6 @@ import (
|
|||
"miller/dsl"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// Checks for things that are syntax errors but not done in the AST for
|
||||
// pragmatic reasons. For example, $anything in begin/end blocks;
|
||||
// begin/end/func not at top level; etc.
|
||||
// ================================================================
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
func ValidateAST(
|
||||
ast *dsl.AST,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// ================================================================
|
||||
// This is for while/do-while loops
|
||||
// ================================================================
|
||||
|
||||
package cst
|
||||
|
||||
import (
|
||||
|
|
@ -7,10 +11,6 @@ import (
|
|||
"miller/lib"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
// This is for while/do-while loops
|
||||
// ================================================================
|
||||
|
||||
// ================================================================
|
||||
type WhileLoopNode struct {
|
||||
conditionNode IEvaluable
|
||||
|
|
|
|||
|
|
@ -19,14 +19,19 @@ no need to bootstrap a parser for the parser-generator language
|
|||
|
||||
! still need functional put -S / put -F ... sigh.
|
||||
|
||||
! subr
|
||||
! emitp/emitf
|
||||
|
||||
! bug on set-var/bind-var
|
||||
- 'int x = 1; x = "abc"' doesn't gate -- needs type-mask within the stack.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
! int map keys: what to do with:
|
||||
o '{1:2}' treat as '{"1":2}'
|
||||
o 'm[1]' treat as 'm["1"]'
|
||||
o positional indexing for maps -- use [[]] [[[]]] ?
|
||||
o pothole: auto-extend of foo[NR] -- this now creates an array not a map
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
! --jvstack as no-op
|
||||
! reconsider OFMT -- %.6f is not really OK when inputs have far more digits.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue