package main

import (
	"code.squareroundforest.org/arpio/treerack"
	"log"
	"os"
)

func main() {
	packageName := "wand"
	if len(os.Args) > 1 {
		packageName = os.Args[1]
	}

	syntax := &treerack.Syntax{}
	if err := syntax.ReadSyntax(os.Stdin); err != nil {
		log.Fatalln(err)
	}

	if err := syntax.Init(); err != nil {
		log.Fatalln(err)
	}

	options := treerack.GeneratorOptions{
		PackageName: packageName,
	}

	if err := syntax.Generate(options, os.Stdout); err != nil {
		log.Fatalln(err)
	}
}
