本文整理汇总了Golang中text/scanner.Scanner.IsIdentRune方法的典型用法代码示例。如果您正苦于以下问题:Golang Scanner.IsIdentRune方法的具体用法?Golang Scanner.IsIdentRune怎么用?Golang Scanner.IsIdentRune使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类text/scanner.Scanner
的用法示例。
在下文中一共展示了Scanner.IsIdentRune方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newScanner
func newScanner(r io.Reader) *scmScanner {
var s scanner.Scanner
s.Init(r)
s.Mode = scanner.ScanIdents | scanner.ScanStrings | scanner.ScanFloats
s.IsIdentRune = func(ch rune, i int) bool {
if i == 0 && unicode.IsDigit(ch) {
return false
}
return ch != '\'' &&
ch != '"' &&
ch != '(' &&
ch != ')' &&
ch != ';' &&
!unicode.IsSpace(ch) &&
unicode.IsPrint(ch)
}
return &scmScanner{Scanner: s}
}
示例2: NewTokenizer
func NewTokenizer(name string, r io.Reader, file *os.File) *Tokenizer {
var s scanner.Scanner
s.Init(r)
// Newline is like a semicolon; other space characters are fine.
s.Whitespace = 1<<'\t' | 1<<'\r' | 1<<' '
// Don't skip comments: we need to count newlines.
s.Mode = scanner.ScanChars |
scanner.ScanFloats |
scanner.ScanIdents |
scanner.ScanInts |
scanner.ScanStrings |
scanner.ScanComments
s.Position.Filename = name
s.IsIdentRune = isIdentRune
if file != nil {
linkCtxt.LineHist.Push(histLine, name)
}
return &Tokenizer{
s: &s,
line: 1,
fileName: name,
file: file,
}
}