本文整理匯總了Golang中github.com/rwcarlsen/goledger/lex.Lexer.AcceptRun方法的典型用法代碼示例。如果您正苦於以下問題:Golang Lexer.AcceptRun方法的具體用法?Golang Lexer.AcceptRun怎麽用?Golang Lexer.AcceptRun使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/rwcarlsen/goledger/lex.Lexer
的用法示例。
在下文中一共展示了Lexer.AcceptRun方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: lexCommod
func lexCommod(l *lex.Lexer) lex.StateFn {
l.AcceptRun(indent)
l.Ignore()
if l.AcceptRunNot(whitespace+meta+at) > 0 {
l.Emit(tokCommod)
}
return nil
}
示例2: lexStatus
func lexStatus(l *lex.Lexer) lex.StateFn {
l.AcceptRun(indent)
l.Ignore()
if l.Accept(statuss) {
l.Emit(tokStatus)
}
return nil
}
示例3: lexNewline
func lexNewline(l *lex.Lexer) lex.StateFn {
l.AcceptRun(indent)
if l.AcceptRun(lineend) == 0 {
l.Errorf("lexer error - missing expected newline")
} else {
l.Emit(tokNewline)
}
return nil
}
示例4: lexMeta
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
}
示例5: lexBlankLine
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
}
示例6: lexAt
func lexAt(l *lex.Lexer) lex.StateFn {
if n := l.AcceptRun(at); n > 2 {
l.Errorf("invalid token on line %v", l.LineNumber())
return lexSkipLine
} else if n == 1 {
l.Emit(tokAt)
} else if n == 2 {
l.Emit(tokAtAt)
}
return nil
}
示例7: lexAccount
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
}
}
}
示例8: lexItems
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
}
示例9: lexAmount
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
}
示例10: lexDate
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
}
示例11: lexSkipLine
func lexSkipLine(l *lex.Lexer) lex.StateFn {
l.AcceptRunNot(lineend)
l.AcceptRun(lineend)
l.Ignore()
return nil
}