// CAUTION: Generated file - DO NOT EDIT. // Copyright 2017 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package textparse import ( "fmt" "math" "strconv" "github.com/prometheus/prometheus/pkg/value" ) // Lex is called by the parser generated by "go tool yacc" to obtain each // token. The method is opened before the matching rules block and closed at // the end of the file. func (l *lexer) Lex() int { const ( lstateInit = iota lstateValue lstateTimestamp lstateLabels lstateLName lstateLValue ) s := lstateInit if l.i >= len(l.b) { return eof } c := l.b[l.i] l.ts = nil l.mstart = l.nextMstart l.offsets = l.offsets[:0] yystate0: switch yyt := s; yyt { default: panic(fmt.Errorf(`invalid start condition %d`, yyt)) case 0: // start condition: INITIAL goto yystart1 case 1: // start condition: lstateValue goto yystart8 case 2: // start condition: lstateTimestamp goto yystart14 case 3: // start condition: lstateLabels goto yystart19 case 4: // start condition: lstateLName goto yystart23 case 5: // start condition: lstateLValue goto yystart26 } goto yystate0 // silence unused label error goto yystate1 // silence unused label error yystate1: c = l.next() yystart1: switch { default: goto yyabort case c == '#': goto yystate4 case c == '\t' || c == '\n' || c == '\r' || c == ' ': goto yystate3 case c == '\x00': goto yystate2 case c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z': goto yystate6 } yystate2: c = l.next() goto yyrule1 yystate3: c = l.next() switch { default: goto yyrule3 case c == '\t' || c == '\n' || c == '\r' || c == ' ': goto yystate3 } yystate4: c = l.next() switch { default: goto yyabort case c == '\n': goto yystate5 case c >= '\x01' && c <= '\t' || c == '\v' || c == '\f' || c >= '\x0e' && c <= 'ÿ': goto yystate4 } yystate5: c = l.next() goto yyrule2 yystate6: c = l.next() switch { default: goto yyrule5 case c == '{': goto yystate7 case c >= '0' && c <= ':' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate6 } yystate7: c = l.next() goto yyrule4 goto yystate8 // silence unused label error yystate8: c = l.next() yystart8: switch { default: goto yyabort case c == 'N': goto yystate11 case c == '\t' || c == ' ': goto yystate10 case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c >= '!' && c <= 'M' || c >= 'O' && c <= 'ÿ': goto yystate9 } yystate9: c = l.next() switch { default: goto yyrule14 case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate9 } yystate10: c = l.next() switch { default: goto yyrule12 case c == '\t' || c == ' ': goto yystate10 } yystate11: c = l.next() switch { default: goto yyrule14 case c == 'a': goto yystate12 case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c >= '!' && c <= '`' || c >= 'b' && c <= 'ÿ': goto yystate9 } yystate12: c = l.next() switch { default: goto yyrule14 case c == 'N': goto yystate13 case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c >= '!' && c <= 'M' || c >= 'O' && c <= 'ÿ': goto yystate9 } yystate13: c = l.next() switch { default: goto yyrule13 case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate9 } goto yystate14 // silence unused label error yystate14: c = l.next() yystart14: switch { default: goto yyabort case c == '\n' || c == '\r': goto yystate17 case c == '\t' || c == ' ': goto yystate16 case c == '\x00': goto yystate15 case c >= '0' && c <= '9': goto yystate18 } yystate15: c = l.next() goto yyrule18 yystate16: c = l.next() switch { default: goto yyrule15 case c == '\t' || c == ' ': goto yystate16 } yystate17: c = l.next() switch { default: goto yyrule17 case c == '\n' || c == '\r': goto yystate17 } yystate18: c = l.next() switch { default: goto yyrule16 case c >= '0' && c <= '9': goto yystate18 } goto yystate19 // silence unused label error yystate19: c = l.next() yystart19: switch { default: goto yyrule8 case c == ',': goto yystate21 case c == '\t' || c == ' ': goto yystate20 case c == '}': goto yystate22 } yystate20: c = l.next() switch { default: goto yyrule6 case c == '\t' || c == ' ': goto yystate20 } yystate21: c = l.next() switch { default: goto yyrule8 case c == '}': goto yystate22 } yystate22: c = l.next() goto yyrule7 goto yystate23 // silence unused label error yystate23: c = l.next() yystart23: switch { default: goto yyabort case c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z': goto yystate24 } yystate24: c = l.next() switch { default: goto yyabort case c == '=': goto yystate25 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate24 } yystate25: c = l.next() goto yyrule9 goto yystate26 // silence unused label error yystate26: c = l.next() yystart26: switch { default: goto yyabort case c == '"': goto yystate27 case c == '\'': goto yystate30 } yystate27: c = l.next() switch { default: goto yyabort case c == '"': goto yystate28 case c == '\\': goto yystate29 case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': goto yystate27 } yystate28: c = l.next() goto yyrule10 yystate29: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': goto yystate27 } yystate30: c = l.next() switch { default: goto yyabort case c == '\'': goto yystate31 case c == '\\': goto yystate32 case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': goto yystate30 } yystate31: c = l.next() goto yyrule11 yystate32: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': goto yystate30 } yyrule1: // \0 { return eof } yyrule2: // #[^\r\n]*\n { l.mstart = l.i goto yystate0 } yyrule3: // [\r\n \t]+ { l.mstart = l.i goto yystate0 } yyrule4: // {S}({M}|{D})*\{ { s = lstateLabels l.offsets = append(l.offsets, l.i-1) goto yystate0 } yyrule5: // {S}({M}|{D})* { s = lstateValue l.mend = l.i l.offsets = append(l.offsets, l.i) goto yystate0 } yyrule6: // [ \t]+ goto yystate0 yyrule7: // ,?\} { s = lstateValue l.mend = l.i goto yystate0 } yyrule8: // ,? { s = lstateLName l.offsets = append(l.offsets, l.i) goto yystate0 } yyrule9: // {S}({L}|{D})*= { s = lstateLValue l.offsets = append(l.offsets, l.i-1) goto yystate0 } yyrule10: // \"(\\.|[^\\"])*\" { s = lstateLabels l.offsets = append(l.offsets, l.i-1) goto yystate0 } yyrule11: // \'(\\.|[^\\'])*\' { s = lstateLabels l.offsets = append(l.offsets, l.i-1) goto yystate0 } yyrule12: // [ \t]+ { l.vstart = l.i goto yystate0 } yyrule13: // (NaN) { l.val = math.Float64frombits(value.NormalNaN) s = lstateTimestamp goto yystate0 } yyrule14: // [^\n \t\r]+ { // We don't parse strictly correct floats as the conversion // repeats the effort anyway. l.val, l.err = strconv.ParseFloat(yoloString(l.b[l.vstart:l.i]), 64) if l.err != nil { return -1 } s = lstateTimestamp goto yystate0 } yyrule15: // [ \t]+ { l.tstart = l.i goto yystate0 } yyrule16: // {D}+ { ts, err := strconv.ParseInt(yoloString(l.b[l.tstart:l.i]), 10, 64) if err != nil { l.err = err return -1 } l.ts = &ts goto yystate0 } yyrule17: // [\r\n]+ { l.nextMstart = l.i return 1 } yyrule18: // \0 { return 1 } panic("unreachable") goto yyabort // silence unused label error yyabort: // no lexem recognized l.err = fmt.Errorf("no token found") return -1 }