Esempio n. 1
0
func main() {
	gen := gen.NewPackage("debug")
	gen(valueStr, "value.gen.go", []interface{}{
		&valuer{"Double", "float64", "0"},
		&valuer{"Int", "int64", "0"},
		&valuer{"Uint", "uint64", "0"},
		&valuer{"Bool", "bool", "false"},
		&valuer{"String", "string", `""`},
		&valuer{"Bytes", "[]byte", "nil"},
	}, `"github.com/katydid/katydid/parser"`)
}
Esempio n. 2
0
func main() {
	gen := gen.NewPackage("parser")
	gen(valueStr, "err.gen.go", []interface{}{
		&valuer{"Double", "float64", "0"},
		&valuer{"Int", "int64", "0"},
		&valuer{"Uint", "uint64", "0"},
		&valuer{"Bool", "bool", "false"},
		&valuer{"String", "string", `""`},
		&valuer{"Bytes", "[]byte", "nil"},
	}, `"fmt"`)
}
Esempio n. 3
0
func main() {
	gen := gen.NewPackage("compose")
	gen(composeStr, "compose.gen.go", []interface{}{
		&composer{"Double", "SINGLE_DOUBLE", "Double", "Doubles", "LIST_DOUBLE"},
		&composer{"Int", "SINGLE_INT", "Int", "Ints", "LIST_INT"},
		&composer{"Uint", "SINGLE_UINT", "Uint", "Uints", "LIST_UINT"},
		&composer{"Bool", "SINGLE_BOOL", "Bool", "Bools", "LIST_BOOL"},
		&composer{"String", "SINGLE_STRING", "String", "Strings", "LIST_STRING"},
		&composer{"Bytes", "SINGLE_BYTES", "Bytes", "ListOfBytes", "LIST_BYTES"},
	},
		`"github.com/katydid/katydid/relapse/ast"`,
		`"github.com/katydid/katydid/relapse/funcs"`,
		`"github.com/katydid/katydid/relapse/types"`)
}
Esempio n. 4
0
func main() {
	gen := gen.NewPackage("funcs")
	gen(compareStr, "compare.gen.go", []interface{}{
		&compare{"ge", ">=", "double", "", "Double", "false", "greater than or equal"},
		&compare{"ge", ">=", "int", "", "Int", "false", "greater than or equal"},
		&compare{"ge", ">=", "uint", "", "Uint", "false", "greater than or equal"},
		&compare{"ge", "", "bytes", "return bytes.Compare(v1, v2) >= 0, nil", "Bytes", "false", "greater than or equal"},
		&compare{"gt", ">", "double", "", "Double", "false", "greater than"},
		&compare{"gt", ">", "int", "", "Int", "false", "greater than"},
		&compare{"gt", ">", "uint", "", "Uint", "false", "greater than"},
		&compare{"gt", "", "bytes", "return bytes.Compare(v1, v2) > 0, nil", "Bytes", "false", "greater than"},
		&compare{"le", "<=", "double", "", "Double", "false", "less than or equal"},
		&compare{"le", "<=", "int", "", "Int", "false", "less than or equal"},
		&compare{"le", "<=", "uint", "", "Uint", "false", "less than or equal"},
		&compare{"le", "", "bytes", "return bytes.Compare(v1, v2) <= 0, nil", "Bytes", "false", "less than or equal"},
		&compare{"lt", "<", "double", "", "Double", "false", "less than"},
		&compare{"lt", "<", "int", "", "Int", "false", "less than"},
		&compare{"lt", "<", "uint", "", "Uint", "false", "less than"},
		&compare{"lt", "", "bytes", "return bytes.Compare(v1, v2) < 0, nil", "Bytes", "false", "less than"},
		&compare{"eq", "==", "double", "", "Double", "false", "equal"},
		&compare{"eq", "==", "int", "", "Int", "false", "equal"},
		&compare{"eq", "==", "uint", "", "Uint", "false", "equal"},
		&compare{"eq", "==", "bool", "", "Bool", "false", "equal"},
		&compare{"eq", "==", "string", "", "String", "false", "equal"},
		&compare{"eq", "", "bytes", "return bytes.Equal(v1, v2), nil", "Bytes", "false", "equal"},
		&compare{"ne", "!=", "double", "", "Double", "false", "not equal"},
		&compare{"ne", "!=", "int", "", "Int", "false", "not equal"},
		&compare{"ne", "!=", "uint", "", "Uint", "false", "not equal"},
		&compare{"ne", "!=", "bool", "", "Bool", "false", "not equal"},
		&compare{"ne", "!=", "string", "", "String", "false", "not equal"},
		&compare{"ne", "", "bytes", "return !bytes.Equal(v1, v2), nil", "Bytes", "false", "not equal"},
	}, `"bytes"`)
	gen(newFuncStr, "newfunc.gen.go", []interface{}{
		"Double",
		"Int",
		"Uint",
		"Bool",
		"String",
		"Bytes",
		"Doubles",
		"Ints",
		"Uints",
		"Bools",
		"Strings",
		"ListOfBytes",
	})
	gen(constStr, "const.gen.go", []interface{}{
		&conster{"Double", "float64", "double(%f)", ""},
		&conster{"Int", "int64", "int(%d)", ""},
		&conster{"Uint", "uint64", "uint(%d)", ""},
		&conster{"Bool", "bool", "%v", ""},
		&conster{"String", "string", "`%s`", ""},
		&conster{"Bytes", "[]byte", "%#v", ""},
		&conster{"Doubles", "[]float64", "double(%f)", "double"},
		&conster{"Ints", "[]int64", "int(%d)", "int"},
		&conster{"Uints", "[]uint64", "uint(%d)", "uint"},
		&conster{"Bools", "[]bool", "%v", "bool"},
		&conster{"Strings", "[]string", "`%s`", "string"},
		&conster{"ListOfBytes", "[][]byte", "%#v", "[]byte"},
	}, `"fmt"`, `"strings"`, `"reflect"`)
	gen(listStr, "list.gen.go", []interface{}{
		&list{"Doubles", "Double", "float64"},
		&list{"Ints", "Int", "int64"},
		&list{"Uints", "Uint", "uint64"},
		&list{"Bools", "Bool", "bool"},
		&list{"Strings", "String", "string"},
		&list{"ListOfBytes", "Bytes", "[]byte"},
	}, `"strings"`)
	gen(printStr, "print.gen.go", []interface{}{
		&printer{"Double", "float64"},
		&printer{"Int", "int64"},
		&printer{"Uint", "uint64"},
		&printer{"Bool", "bool"},
		&printer{"String", "string"},
		&printer{"Bytes", "[]byte"},
		&printer{"Doubles", "[]float64"},
		&printer{"Ints", "[]int64"},
		&printer{"Uints", "[]uint64"},
		&printer{"Bools", "[]bool"},
		&printer{"Strings", "[]string"},
		&printer{"ListOfBytes", "[][]byte"},
	}, `"fmt"`)
	gen(lengthStr, "length.gen.go", []interface{}{
		"Doubles",
		"Ints",
		"Uints",
		"Bools",
		"Strings",
		"ListOfBytes",
		"String",
		"Bytes",
	})
	gen(elemStr, "elem.gen.go", []interface{}{
		&elemer{"Doubles", "float64", "Double", "0"},
		&elemer{"Ints", "int64", "Int", "0"},
		&elemer{"Uints", "uint64", "Uint", "0"},
		&elemer{"Bools", "bool", "Bool", "false"},
		&elemer{"Strings", "string", "String", `""`},
		&elemer{"ListOfBytes", "[]byte", "Bytes", "nil"},
	})
	gen(rangeStr, "range.gen.go", []interface{}{
		&ranger{"Doubles", "[]float64"},
		&ranger{"Ints", "[]int64"},
		&ranger{"Uints", "[]uint64"},
		&ranger{"Bools", "[]bool"},
		&ranger{"Strings", "[]string"},
		&ranger{"ListOfBytes", "[][]byte"},
	})
	gen(variableStr, "variable.gen.go", []interface{}{
		&varer{"Double", "double", "float64", "0"},
		&varer{"Int", "int", "int64", "0"},
		&varer{"Uint", "uint", "uint64", "0"},
		&varer{"Bool", "bool", "bool", "false"},
		&varer{"String", "string", "string", `""`},
		&varer{"Bytes", "[]byte", "[]byte", "nil"},
	}, `"github.com/katydid/katydid/parser"`)
	gen(typStr, "type.gen.go", []interface{}{
		&typer{"Double"},
		&typer{"Int"},
		&typer{"Uint"},
		&typer{"Bool"},
		&typer{"String"},
		&typer{"Bytes"},
	})
	gen(inSetStr, "inset.gen.go", []interface{}{
		&inSeter{"Int", "ConstInts", "int64"},
		&inSeter{"Uint", "ConstUints", "uint64"},
		&inSeter{"String", "ConstStrings", "string"},
	})
}