func lexAccount(l *lex.Lexer) lex.StateFn { for { nr := l.Next() nnr := l.Peek() if isSpace(nr) && isSpace(nnr) || isNewline(nr) { l.Backup() l.Emit(tokAccount) l.AcceptRun(indent) l.Ignore() return nil } } }
func lexItems(l *lex.Lexer) lex.StateFn { if l.AcceptRun(indent) == 0 { return nil } else if string(l.Peek()) == meta { l.Push(lexItems) return lexMeta } l.Ignore() l.Push(lexItems) return lexItem }
// lexStart looks for a comment or a transaction, it emits everything // inbetween as tokText func lexStart(l *lex.Lexer) lex.StateFn { switch r := l.Peek(); { case string(r) == meta: l.Push(lexStart) return lexMeta case unicode.IsDigit(r): l.Push(lexStart) return lexTrans case isSpace(r) || isNewline(r): l.Push(lexStart) return lexBlankLine case r == lex.EOF: l.Emit(lex.TokEOF) return nil default: l.Errorf("unexpected text on line %v", l.LineNumber()) l.Push(lexStart) return lexSkipLine } }