package data import ( "strconv" "time" "github.com/nordsieck/defect" ) const ( ErrWrongNumFields = defect.Error("Wrong number of fields") ErrInvalidLeadFollow = defect.Error("Invalid lead of follow value") layout = "Jan 2006" ) type Parser interface { Parse([]string) error } type Dancer struct { Number uint32 First, Last string } var _ Parser = &Dancer{} func (d *Dancer) Parse(s []string) error { if len(s) != 3 { return ErrWrongNumFields }
//go:generate go tool yacc -o parse.go parse.y package v3 import ( "fmt" "strconv" "unicode/utf8" "github.com/nordsieck/defect" "github.com/nordsieck/lexandyacctutorial/util" ) const ( IllegalInteger = defect.Error("Illegal integer") literals = '+' | '-' | '*' | '/' | ';' | '(' | ')' | '{' | '}' ) type Token string type Lexer struct{ util.Lexer } func (l *Lexer) Token() (t Token, kind int, err error) { r, err := l.Scan() if err != nil { return "", 0, err } switch { case r == 'e': t = Token(r)