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:
James Shubin
2021-10-21 03:35:31 -04:00
parent 8ae47bd490
commit 23b5a4729f
23 changed files with 1212 additions and 1129 deletions

View File

@@ -20,7 +20,7 @@ package fuzz
import (
"bytes"
"github.com/purpleidea/mgmt/lang"
"github.com/purpleidea/mgmt/lang/parser"
)
// Fuzz is repeatedly called by go-fuzz with semi-random inputs in an attempt to
@@ -32,7 +32,7 @@ import (
// gives new coverage; and 0 otherwise; other values are reserved for future
// use.
func Fuzz(data []byte) int {
ast, err := lang.LexParse(bytes.NewReader(data))
ast, err := parser.LexParse(bytes.NewReader(data))
if err != nil {
if ast != nil {
panic("ast != nil on error")