MCPcopy Index your code
hub / github.com/expr-lang/expr / scanNumber

Method scanNumber

parser/lexer/state.go:80–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78}
79
80func (l *Lexer) scanNumber() bool {
81 digits := "0123456789_"
82 // Is it hex?
83 if l.accept("0") {
84 // Note: Leading 0 does not mean octal in floats.
85 if l.accept("xX") {
86 digits = "0123456789abcdefABCDEF_"
87 } else if l.accept("oO") {
88 digits = "01234567_"
89 } else if l.accept("bB") {
90 digits = "01_"
91 }
92 }
93 l.acceptRun(digits)
94 end := l.end
95 if l.accept(".") {
96 // Lookup for .. operator: if after dot there is another dot (1..2), it maybe a range operator.
97 if l.peek() == '.' {
98 // We can't backup() here, as it would require two backups,
99 // and backup() func supports only one for now. So, save and
100 // restore it here.
101 l.end = end
102 return true
103 }
104 l.acceptRun(digits)
105 }
106 if l.accept("eE") {
107 l.accept("+-")
108 l.acceptRun(digits)
109 }
110 // Next thing mustn't be alphanumeric.
111 if utils.IsAlphaNumeric(l.peek()) {
112 l.next()
113 return false
114 }
115 return true
116}
117
118func dot(l *Lexer) stateFn {
119 l.next()

Callers 1

numberFunction · 0.80

Calls 5

acceptMethod · 0.95
acceptRunMethod · 0.95
peekMethod · 0.95
nextMethod · 0.95
IsAlphaNumericFunction · 0.92

Tested by

no test coverage detected