I don't think I like the SDK way, and langV2 seems to be so simialr to V1 that I'm probably going to stick with V1 for now and see if i can get it to do what I need.
34 lines
578 B
Go
34 lines
578 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"masonry/langV2"
|
|
)
|
|
|
|
func main() {
|
|
// Read the example.masonry file
|
|
content, err := ioutil.ReadFile("example.masonry2")
|
|
if err != nil {
|
|
fmt.Printf("Error reading example.masonry: %v\n", err)
|
|
return
|
|
}
|
|
|
|
input := string(content)
|
|
|
|
ast, err := langV2.ParseInput(input)
|
|
if err != nil {
|
|
fmt.Printf("Error: %v\n", err)
|
|
} else {
|
|
fmt.Printf("🎉 Successfully parsed complete DSL with pages!\n\n")
|
|
|
|
out, err := json.MarshalIndent(ast, "", " ")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
println(string(out))
|
|
|
|
}
|
|
}
|