func lexCommod(l *lex.Lexer) lex.StateFn { l.AcceptRun(indent) l.Ignore() if l.AcceptRunNot(whitespace+meta+at) > 0 { l.Emit(tokCommod) } return nil }
func lexStatus(l *lex.Lexer) lex.StateFn { l.AcceptRun(indent) l.Ignore() if l.Accept(statuss) { l.Emit(tokStatus) } return nil }
func lexMeta(l *lex.Lexer) lex.StateFn { l.AcceptRun(indent) l.Ignore() if l.Accept(";") { l.Emit(tokMeta) l.AcceptRun(indent) l.Ignore() return lexText } return lexNewline }
func lexBlankLine(l *lex.Lexer) lex.StateFn { l.AcceptRun(indent) l.Ignore() if l.AcceptRun(lineend) == 0 { l.Errorf("unexpected non-blank line at line %v", l.LineNumber()) return lexSkipLine } l.Ignore() return nil }
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 }
func lexAmount(l *lex.Lexer) lex.StateFn { l.AcceptRun(indent) l.Ignore() if l.Accept("$") { l.Emit(tokUnit) } l.AcceptRun(digit + ",") l.Accept(".") l.AcceptRun(digit) if l.Pos > l.Start { l.Emit(tokAmount) } return lexCommod }
func lexDate(l *lex.Lexer) lex.StateFn { fail := false if l.AcceptRun(digit) == 0 { fail = true } else if !l.Accept("/") { fail = true } else if l.AcceptRun(digit) == 0 { fail = true } else if !l.Accept("/") { fail = true } else if l.AcceptRun(digit) == 0 { fail = true } if fail { l.AcceptRunNot(whitespace + meta) l.Errorf("invalid date on line %v", l.LineNumber()) l.Ignore() } else { l.Emit(tokDate) } return nil }
func lexSkipLine(l *lex.Lexer) lex.StateFn { l.AcceptRunNot(lineend) l.AcceptRun(lineend) l.Ignore() return nil }