Пример #1
0
func t_res(raw string, expect interface{}, parser parsec.Parser, t *testing.T) {
	r, err := syntax.Parse(parser, strings.NewReader(raw))
	assert.NoError(t, err)
	assert.Equal(t, expect, r, raw)
	//	fmt.Println(raw)
	//	fmt.Println(basic.Dump(r, 0))
}
Пример #2
0
func getGen(t *testing.T) gen.GenRoot {
	opts := options.NewGenOptions(
		23,
		"mock",
		"github.com/tamtam-im/teleport/lib/go/tl",
	)
	prog, err := syntax.Parse(program.Program, strings.NewReader(src))
	assert.NoError(t, err)
	g := gen.NewGenRoot(
		prog.(syntax.Program), opts)
	assert.NotNil(t, g)
	return g
}
Пример #3
0
// Parse multiple files
func ParseFiles(filenames ...string) (res syntax.Program, err error) {
	for _, n := range filenames {
		r, err := os.Open(n)
		if err != nil {
			return res, err
		}
		p, err := syntax.Parse(Program, r)
		if err != nil {
			return res, err
		}
		if p != nil {
			res = append(res, p.(syntax.Program)...)
		}
	}
	return
}
Пример #4
0
func match(raw string, expect interface{}, parser parsec.Parser, t *testing.T) {
	r, err := syntax.Parse(parser, strings.NewReader(raw))
	assert.NoError(t, err)
	assert.Equal(t, expect, r, raw)
}
Пример #5
0
func match(raw string, expect interface{}, parser parsec.Parser, t *testing.T) {
	r, err := syntax.Parse(parser, strings.NewReader(raw))
	//	t.Log("!!!", basic.Dump(r, 0))
	assert.NoError(t, err)
	assert.Equal(t, expect, r.(syntax.Declaration).String(), raw)
}