func (pp *primitiveParser) Parse() map[string]*data {
	pp.loadTypeComments()
	pp.loadStructs()
	visible := make(map[string]*data)
	for k := range pp.structmap {
		if strings.ToUpper(string(k[0])) != string(k[0]) {  
			continue
		}
		pp.visitStruct(visible, k, false)
	}
	return visible
}
Parse performs the actual work of walking over all defined structs,
and building data representations of them for use in template rendering.
package main
import (
	"bytes"
	"fmt"
	"go/ast"
	"go/format"
	"go/parser"
	"go/token"
	"log"
	"os"
	"path/filepath"
	"sort"
	"strings"
	"text/template"
)
const (
	primitiveFile = "primitive/zz_generated_primitive.go"
	envelopeFile  = "envelope/zz_generated_envelope.go"
	cryptoFile    = "daemon/crypto/zz_generated_crypto.go"
)
var primitiveTmpl, envelopeTmpl, cryptoTmpl *template.Template
func init() {
	prefix := "tools/primitive-boilerplate/"
	primitiveName := filepath.Join(prefix, "primitive.tmpl")
	primitiveTmpl = template.Must(template.ParseFiles(primitiveName))
	envelopeName := filepath.Join(prefix, "envelope.tmpl")
	envelopeTmpl = template.Must(template.New("envelope.tmpl").Funcs(template.FuncMap{
		"add": func(a, b int) int {
			return a + b
		},
	}).ParseFiles(envelopeName))
	cryptoName := filepath.Join(prefix, "crypto.tmpl")
	cryptoTmpl = template.Must(template.ParseFiles(cryptoName))
}
type data struct {
	Name      string
	Fields    []field
	Byte      string  
	Version   uint8   
	Immutable bool    
	Visible   bool    
}
type field struct {
	Name  string  
	Field string  
}
type sortData []data
func (d sortData) Len() int      { return len(d) }
func (d sortData) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
func (d sortData) Less(i, j int) bool {
	v := strings.Compare(d[i].Byte, d[j].Byte)
	switch v {
	case -1:
		return true
	case 0:
		return d[i].Version < d[j].Version
	case 1:
		return false
	default:
		panic(fmt.Sprintf("unknown value: %d", v))
	}
}
type sortFields []field
func (s sortFields) Len() int           { return len(s) }
func (s sortFields) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortFields) Less(i, j int) bool { return strings.Compare(s[i].Name, s[j].Name) < 0 }
type sortDataByVersion []data
func (d sortDataByVersion) Len() int      { return len(d) }
func (d sortDataByVersion) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
func (d sortDataByVersion) Less(i, j int) bool {
	return d[i].Version < d[j].Version
}
type envTmplData struct {
	Name       string
	Mutability string
	Types      map[string][]data
}
type primitiveParser struct {
	fset *token.FileSet
	p    *ast.File
	typedecls map[int]string  
	structmap map[string]*ast.StructType
}