mirror of
https://github.com/johnkerl/miller.git
synced 2026-08-03 21:13:09 +00:00
mapper-put iterate
This commit is contained in:
parent
a81a26aa24
commit
b24a926df5
2 changed files with 19 additions and 4 deletions
|
|
@ -16,19 +16,30 @@ type MapperPut struct {
|
|||
}
|
||||
|
||||
func NewMapperPut(dslString string) *MapperPut {
|
||||
theLexer := lexer.NewLexer([]byte(dslString))
|
||||
theParser := parser.NewParser()
|
||||
interfaceAST, err := theParser.Parse(theLexer)
|
||||
ast, err := NewASTFromString(dslString)
|
||||
if err != nil {
|
||||
fmt.Println(err) // xxx error propagate to caller -- for all mapper constructors
|
||||
os.Exit(1)
|
||||
}
|
||||
ast := interfaceAST.(*dsl.AST)
|
||||
return &MapperPut{
|
||||
ast,
|
||||
}
|
||||
}
|
||||
|
||||
// xxx note (package cycle) why not a dsl.AST constructor :(
|
||||
// xxx maybe split out dsl into two package ... and/or put the ast.go into miller/parsing -- ?
|
||||
// depends on TBD split-out of AST and CST ...
|
||||
func NewASTFromString(dslString string) (*dsl.AST, error) {
|
||||
theLexer := lexer.NewLexer([]byte(dslString))
|
||||
theParser := parser.NewParser()
|
||||
interfaceAST, err := theParser.Parse(theLexer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ast := interfaceAST.(*dsl.AST)
|
||||
return ast, nil
|
||||
}
|
||||
|
||||
func (this *MapperPut) Name() string {
|
||||
return "put"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,3 +21,7 @@ long-term:
|
|||
o only requirement is that top-level be sequence of string-valued objects ...
|
||||
o json-to-json cat-mapping should be identical
|
||||
o json-like accessor syntax in the grammar: $field.foo[3].bar{"bar"}
|
||||
|
||||
gocc upstreams:
|
||||
* support "..." in the lexer part
|
||||
* research error-handling ...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue