lang: Split lang package out into many subpackages
This is a giant refactor to split the giant lang package into many subpackages. The most difficult piece was figuring out how to extract the extra ast structs into their own package, because they needed to call two functions which also needed to import the ast. The solution was to separate out those functions into their own packages, and to pass them into the ast at the root when they're needed, and to let the relevant ast portions call a handle. This isn't terribly ugly because we already had a giant data struct woven through the ast. The bad part is rebasing any WIP work on top of this.
This commit is contained in:
@@ -19,6 +19,7 @@ package interfaces
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
"github.com/purpleidea/mgmt/engine"
|
||||
@@ -186,6 +187,16 @@ type Data struct {
|
||||
// deploys, however that is not blocked at the level of this interface.
|
||||
Downloader Downloader
|
||||
|
||||
// LexParser is a function that needs to get passed in to run the lexer
|
||||
// and parser to build the initial AST. This is passed in this way to
|
||||
// avoid dependency cycles.
|
||||
LexParser func(io.Reader) (Stmt, error)
|
||||
|
||||
// StrInterpolater is a function that needs to get passed in to run the
|
||||
// string interpolation. This is passed in this way to avoid dependency
|
||||
// cycles.
|
||||
StrInterpolater func(string, *Pos, *Data) (Expr, error)
|
||||
|
||||
//World engine.World // TODO: do we need this?
|
||||
|
||||
// Prefix provides a unique path prefix that we can namespace in. It is
|
||||
|
||||
Reference in New Issue
Block a user