Merge branch 'master' of git+ssh://github.com/johnkerl/miller

This commit is contained in:
John Kerl 2020-12-20 12:59:37 -05:00
commit f74bbd104d
6 changed files with 9313 additions and 9277 deletions

View file

@ -144,27 +144,43 @@ func (this *EmitPStatementNode) Execute(state *State) (*BlockExitPayload, error)
}
// ================================================================
// Examples:
// emitf @a
// emitf @a, @b
// Each argument must be a non-indexed oosvar/localvar/fieldname.
// These restrictions are enforced here in the CST logic, to keep the
// parser/AST logic simpler.
type EmitFStatementNode struct {
emitfEvaluable IEvaluable
// xxx to do:
// array of names
emitfEvaluables []IEvaluable
}
// ----------------------------------------------------------------
// $ mlr -n put -v 'emitf @a,@b,@c'
// DSL EXPRESSION:
// emitf @a,@b,@c
// RAW AST:
// * statement block
// * dump statement "emitf"
// * direct oosvar value "a"
// * direct oosvar value "b"
// * direct oosvar value "c"
func (this *RootNode) BuildEmitFStatementNode(astNode *dsl.ASTNode) (IExecutable, error) {
lib.InternalCodingErrorIf(astNode.Type != dsl.NodeTypeEmitFStatement)
lib.InternalCodingErrorIf(len(astNode.Children) < 1)
emitfEvaluable, err := this.BuildEvaluableNode(astNode.Children[0])
emitfEvaluables[i], err := this.BuildEvaluableNode(astNode.Children[0])
if err != nil {
return nil, err
}
return &EmitFStatementNode{
emitfEvaluable: emitfEvaluable,
emitfEvaluables: emitfEvaluables,
}, nil
}
func (this *EmitFStatementNode) Execute(state *State) (*BlockExitPayload, error) {
xxx
emitfResult := this.emitfEvaluable.Evaluate(state)
if emitfResult.IsAbsent() {
@ -174,17 +190,9 @@ func (this *EmitFStatementNode) Execute(state *State) (*BlockExitPayload, error)
if emitfResult.IsMap() {
state.OutputChannel <- types.NewRecordAndContext(
emitfResult.Copy().GetMap(),
state.Context, // xxx clone ?
state.Context.Copy(),
)
}
// xxx WIP
// xxx need to reshape rvalue mlrvals -> mlrmaps; publish w/ contexts; method for that
// outputChannel <- types.NewRecordAndContext(
// mlrmap goes here,
// &context,
// )
return nil, nil
}

View file

@ -460,9 +460,21 @@ EmitPStatement
<< dsl.NewASTNodeUnary($0, $1, dsl.NodeTypeEmitPStatement) >>
;
// Examples:
// emitf @a
// emitf @a, @b
// Each argument must be a non-indexed oosvar/localvar/fieldname.
// These restrictions are enforced in the CST logic, to keep this parser/AST
// logic simpler.
EmitFStatement
: emitf Rvalue // xxx more to do
<< dsl.NewASTNodeUnary($0, $1, dsl.NodeTypeEmitFStatement) >>
: emitf FcnArgs
<< dsl.AdoptChildren(
dsl.NewASTNodeNestable(
$0,
dsl.NodeTypeDumpStatement,
),
$1,
) >>
;
DumpStatement

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -421,13 +421,25 @@ var productionsTable = ProdTab{
},
},
ProdTabEntry{
String: `EmitFStatement : emitf Rvalue << dsl.NewASTNodeUnary(X[0], X[1], dsl.NodeTypeEmitFStatement) >>`,
String: `EmitFStatement : emitf FcnArgs << dsl.AdoptChildren(
dsl.NewASTNodeNestable(
X[0],
dsl.NodeTypeDumpStatement,
),
X[1],
) >>`,
Id: "EmitFStatement",
NTType: 13,
Index: 40,
NumSymbols: 2,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeUnary(X[0], X[1], dsl.NodeTypeEmitFStatement)
return dsl.AdoptChildren(
dsl.NewASTNodeNestable(
X[0],
dsl.NodeTypeDumpStatement,
),
X[1],
)
},
},
ProdTabEntry{

View file

@ -4,6 +4,7 @@ TOP OF LIST:
! emitp/emitf
* stats1 verb
! mlrrc
* pprint emit at schema-change or EOS
!! fix all typemasks!!
! fix var/any type-mask
@ -144,6 +145,7 @@ no need to bootstrap a parser for the parser-generator language
- how with whitespace regex -- ?
! quoted DKVP
- what about csvlite-style -- ? needs a --dkvplite ?
! pprint emit on schema change, not all-at-end.
* mlr -f / -F flags
o others in mlrcli_parse.go
@ -313,6 +315,8 @@ NITS/NON-IMMEDIATE:
o also document pre/post conditions for flag and non-flag usages x all mappers
* need to fix up ;; and start-with-; handling in the grammar so multiple put -f/-e work right :^/
? emit @x or emit x -- should make k/v pairs w/ "x" & value -- ? check against C impl
i emitp/emitf -- note for-loops didn't appear until 4.1.0 & emits are much older (emitp 3.5.0).
if i were starting clean-slate, i'd have had just a single `emit`.
* doc one-variable for is over keys for maps, elements for arrays
* asserting_{type}: os.Exit(1) -> return nil, err flow?
* test put/filter w/ various combinations of -s/-e/-f