示例#1
0
func TestParse(t *testing.T) {
	l := lex.New("testlex", journal1, lexStart)
	pp := &Parser{}
	p := parse.New(l, pp.Start)
	p.Run()
	for _, trans := range pp.Journal {
		t.Logf("%+v", trans)
	}
}
示例#2
0
func BenchmarkHello(b *testing.B) {
	data, err := ioutil.ReadFile("/home/robert/git/money/rwc-finances.ledger")
	if err != nil {
		b.Fatal(err)
	}
	s := string(data)

	for i := 0; i < b.N; i++ {
		l := lex.New("testlex", s, lexStart)
		for _ = range l.Tokens {
		}
	}
}
示例#3
0
func Decode(name string, data []byte) (*Journal, error) {
	l := lex.New(name, string(data), lexStart)
	return parse(l)
}
示例#4
0
func TestLex(t *testing.T) {
	l := lex.New("testlex", journal1, lexStart)
	for tok := range l.Tokens {
		t.Logf("%v: '%v'", tokNames[tok.Type], tok.Val)
	}
}
示例#5
0
func TestJournalLex(t *testing.T) {
	l := lex.New("trans2", trans2, lexStart)
	for tok := range l.Tokens {
		t.Logf("------ token %v -------\n'''%v'''\n", tokNames[tok.Type], tok.Val)
	}
}