diff options
Diffstat (limited to 'cmd/h/compile.go')
| -rw-r--r-- | cmd/h/compile.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd/h/compile.go b/cmd/h/compile.go index 7b4d6e3..a2077da 100644 --- a/cmd/h/compile.go +++ b/cmd/h/compile.go @@ -7,9 +7,11 @@ import ( "os" "os/exec" "path/filepath" + "strings" "text/template" "time" + "github.com/eaburns/peggy/peg" "within.website/x/h" ) @@ -33,6 +35,7 @@ type CompiledProgram struct { Source string `json:"src"` WebAssemblyText string `json:"wat"` Binary []byte `json:"bin"` + AST string `json:"ast"` } func compile(source string) (*CompiledProgram, error) { @@ -41,8 +44,12 @@ func compile(source string) (*CompiledProgram, error) { return nil, err } + var sb strings.Builder + err = peg.PrettyWrite(&sb, tree) + result := CompiledProgram{ Source: source, + AST: sb.String(), } dir, err := ioutil.TempDir("", "h") |
