mapper-put iterate

This commit is contained in:
John Kerl 2020-08-30 15:58:54 -04:00
parent a81a26aa24
commit b24a926df5
2 changed files with 19 additions and 4 deletions

View file

@ -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"
}

View file

@ -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 ...