func lexItem(l *lex.Lexer) lex.StateFn { l.Push(lexMeta) l.Push(lexAmount) l.Push(lexAt) l.Push(lexAmount) l.Push(lexAccount) return lexStatus }
func lexTrans(l *lex.Lexer) lex.StateFn { l.Emit(tokBeginTrans) l.Push(lexEndTrans) l.Push(lexItems) l.Push(lexMeta) l.Push(lexPayee) l.Push(lexStatus) return lexDate }
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 } }