// Code generated by golex. DO NOT EDIT. // Copyright 2025 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" ) // 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 *openMetrics2Lexer) Lex() token { if l.i >= len(l.b) { return tEOF } c := l.b[l.i] l.start = l.i yystate0: switch yyt := l.state; yyt { default: panic(fmt.Errorf(`invalid start condition %d`, yyt)) case 0: // start condition: INITIAL goto yystart1 case 1: // start condition: sComment goto yystart6 case 2: // start condition: sMeta1 goto yystart26 case 3: // start condition: sMeta2 goto yystart31 case 4: // start condition: sLabels goto yystart34 case 5: // start condition: sLValue goto yystart42 case 6: // start condition: sValue goto yystart46 case 7: // start condition: sTimestamp goto yystart51 case 8: // start condition: sExemplar goto yystart62 case 9: // start condition: sEValue goto yystart70 case 10: // start condition: sETimestamp goto yystart76 case 11: // start condition: sComplexValue goto yystart80 } yystate1: c = l.next() yystart1: switch { default: goto yyabort case c == '#': goto yystate2 case c == ':' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate4 case c == '{': goto yystate5 } yystate2: c = l.next() switch { default: goto yyabort case c == ' ': goto yystate3 } yystate3: c = l.next() goto yyrule1 yystate4: c = l.next() switch { default: goto yyrule9 case c >= '0' && c <= ':' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate4 } yystate5: c = l.next() goto yyrule11 yystate6: c = l.next() yystart6: switch { default: goto yyabort case c == 'E': goto yystate7 case c == 'H': goto yystate11 case c == 'T': goto yystate16 case c == 'U': goto yystate21 } yystate7: c = l.next() switch { default: goto yyabort case c == 'O': goto yystate8 } yystate8: c = l.next() switch { default: goto yyabort case c == 'F': goto yystate9 } yystate9: c = l.next() switch { default: goto yyrule5 case c == '\n': goto yystate10 } yystate10: c = l.next() goto yyrule5 yystate11: c = l.next() switch { default: goto yyabort case c == 'E': goto yystate12 } yystate12: c = l.next() switch { default: goto yyabort case c == 'L': goto yystate13 } yystate13: c = l.next() switch { default: goto yyabort case c == 'P': goto yystate14 } yystate14: c = l.next() switch { default: goto yyabort case c == ' ': goto yystate15 } yystate15: c = l.next() goto yyrule2 yystate16: c = l.next() switch { default: goto yyabort case c == 'Y': goto yystate17 } yystate17: c = l.next() switch { default: goto yyabort case c == 'P': goto yystate18 } yystate18: c = l.next() switch { default: goto yyabort case c == 'E': goto yystate19 } yystate19: c = l.next() switch { default: goto yyabort case c == ' ': goto yystate20 } yystate20: c = l.next() goto yyrule3 yystate21: c = l.next() switch { default: goto yyabort case c == 'N': goto yystate22 } yystate22: c = l.next() switch { default: goto yyabort case c == 'I': goto yystate23 } yystate23: c = l.next() switch { default: goto yyabort case c == 'T': goto yystate24 } yystate24: c = l.next() switch { default: goto yyabort case c == ' ': goto yystate25 } yystate25: c = l.next() goto yyrule4 yystate26: c = l.next() yystart26: switch { default: goto yyabort case c == '"': goto yystate27 case c == ':' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': 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 yyrule6 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 yyrule7 case c >= '0' && c <= ':' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate30 } yystate31: c = l.next() yystart31: switch { default: goto yyabort case c == ' ': goto yystate32 } yystate32: c = l.next() switch { default: goto yyabort case c == '\n': goto yystate33 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': goto yystate32 } yystate33: c = l.next() goto yyrule8 yystate34: c = l.next() yystart34: switch { default: goto yyabort case c == '"': goto yystate35 case c == ',': goto yystate38 case c == '=': goto yystate39 case c == '}': goto yystate41 case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate40 } yystate35: c = l.next() switch { default: goto yyabort case c == '"': goto yystate36 case c == '\\': goto yystate37 case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': goto yystate35 } yystate36: c = l.next() goto yyrule13 yystate37: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': goto yystate35 } yystate38: c = l.next() goto yyrule16 yystate39: c = l.next() goto yyrule15 yystate40: c = l.next() switch { default: goto yyrule12 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate40 } yystate41: c = l.next() goto yyrule14 yystate42: c = l.next() yystart42: switch { default: goto yyabort case c == '"': goto yystate43 } yystate43: c = l.next() switch { default: goto yyabort case c == '"': goto yystate44 case c == '\\': goto yystate45 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': goto yystate43 } yystate44: c = l.next() goto yyrule17 yystate45: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': goto yystate43 } yystate46: c = l.next() yystart46: switch { default: goto yyabort case c == ' ': goto yystate47 case c == '{': goto yystate50 } yystate47: c = l.next() switch { default: goto yyabort case c == '{': goto yystate49 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'z' || c >= '|' && c <= 'ÿ': goto yystate48 } yystate48: c = l.next() switch { default: goto yyrule27 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'z' || c >= '|' && c <= 'ÿ': goto yystate48 } yystate49: c = l.next() goto yyrule18 yystate50: c = l.next() goto yyrule10 yystate51: c = l.next() yystart51: switch { default: goto yyabort case c == ' ': goto yystate53 case c == '\n': goto yystate52 } yystate52: c = l.next() goto yyrule30 yystate53: c = l.next() switch { default: goto yyabort case c == '#': goto yystate55 case c == 's': goto yystate58 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c == '!' || c == '"' || c >= '$' && c <= 'r' || c >= 't' && c <= 'ÿ': goto yystate54 } yystate54: c = l.next() switch { default: goto yyrule29 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate54 } yystate55: c = l.next() switch { default: goto yyrule29 case c == ' ': goto yystate56 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate54 } yystate56: c = l.next() switch { default: goto yyabort case c == '{': goto yystate57 } yystate57: c = l.next() goto yyrule31 yystate58: c = l.next() switch { default: goto yyrule29 case c == 't': goto yystate59 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 's' || c >= 'u' && c <= 'ÿ': goto yystate54 } yystate59: c = l.next() switch { default: goto yyrule29 case c == '@': goto yystate60 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= '?' || c >= 'A' && c <= 'ÿ': goto yystate54 } yystate60: c = l.next() switch { default: goto yyrule29 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate61 } yystate61: c = l.next() switch { default: goto yyrule28 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate61 } yystate62: c = l.next() yystart62: switch { default: goto yyabort case c == '"': goto yystate63 case c == ',': goto yystate66 case c == '=': goto yystate67 case c == '}': goto yystate69 case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate68 } yystate63: c = l.next() switch { default: goto yyabort case c == '"': goto yystate64 case c == '\\': goto yystate65 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': goto yystate63 } yystate64: c = l.next() goto yyrule33 yystate65: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': goto yystate63 } yystate66: c = l.next() goto yyrule37 yystate67: c = l.next() goto yyrule35 yystate68: c = l.next() switch { default: goto yyrule32 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate68 } yystate69: c = l.next() goto yyrule34 yystate70: c = l.next() yystart70: switch { default: goto yyabort case c == ' ': goto yystate71 case c == '"': goto yystate73 } yystate71: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate72 } yystate72: c = l.next() switch { default: goto yyrule38 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate72 } yystate73: c = l.next() switch { default: goto yyabort case c == '"': goto yystate74 case c == '\\': goto yystate75 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': goto yystate73 } yystate74: c = l.next() goto yyrule36 yystate75: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': goto yystate73 } yystate76: c = l.next() yystart76: switch { default: goto yyabort case c == ' ': goto yystate78 case c == '\n': goto yystate77 } yystate77: c = l.next() goto yyrule40 yystate78: c = l.next() switch { default: goto yyabort case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate79 } yystate79: c = l.next() switch { default: goto yyrule39 case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ': goto yystate79 } yystate80: c = l.next() yystart80: switch { default: goto yyabort case c == ',': goto yystate83 case c == ':': goto yystate84 case c == '[': goto yystate86 case c == '\t' || c == ' ': goto yystate82 case c == ']': goto yystate87 case c == '}': goto yystate88 case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate85 case c >= '\x01' && c <= '\b' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= '+' || c >= '-' && c <= '9' || c >= ';' && c <= '@' || c == '\\' || c == '^' || c == '`' || c == '|' || c >= '~' && c <= 'ÿ': goto yystate81 } yystate81: c = l.next() switch { default: goto yyrule25 case c >= '\x01' && c <= '\b' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= '+' || c >= '-' && c <= '9' || c >= ';' && c <= 'Z' || c == '\\' || c >= '^' && c <= 'z' || c == '|' || c >= '~' && c <= 'ÿ': goto yystate81 } yystate82: c = l.next() switch { default: goto yyrule24 case c == '\t' || c == ' ': goto yystate82 } yystate83: c = l.next() goto yyrule23 yystate84: c = l.next() goto yyrule20 yystate85: c = l.next() switch { default: goto yyrule19 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': goto yystate85 case c >= '\x01' && c <= '\b' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= '+' || c >= '-' && c <= '/' || c >= ';' && c <= '@' || c == '\\' || c == '^' || c == '`' || c == '|' || c >= '~' && c <= 'ÿ': goto yystate81 } yystate86: c = l.next() goto yyrule21 yystate87: c = l.next() goto yyrule22 yystate88: c = l.next() goto yyrule26 yyrule1: // #{S} { l.state = sComment goto yystate0 } yyrule2: // HELP{S} { l.state = sMeta1 return tHelp goto yystate0 } yyrule3: // TYPE{S} { l.state = sMeta1 return tType goto yystate0 } yyrule4: // UNIT{S} { l.state = sMeta1 return tUnit goto yystate0 } yyrule5: // "EOF"\n? { l.state = sInit return tEOFWord goto yystate0 } yyrule6: // \"(\\.|[^\\"])*\" { l.state = sMeta2 return tMName goto yystate0 } yyrule7: // {M}({M}|{D})* { l.state = sMeta2 return tMName goto yystate0 } yyrule8: // {S}{C}*\n { l.state = sInit return tText goto yystate0 } yyrule9: // {M}({M}|{D})* { l.state = sValue return tMName goto yystate0 } yyrule10: // \{ { l.state = sLabels return tBraceOpen goto yystate0 } yyrule11: // \{ { l.state = sLabels return tBraceOpen goto yystate0 } yyrule12: // {L}({L}|{D})* { return tLName } yyrule13: // \"(\\.|[^\\"])*\" { l.state = sLabels return tQString goto yystate0 } yyrule14: // \} { l.state = sValue return tBraceClose goto yystate0 } yyrule15: // = { l.state = sLValue return tEqual goto yystate0 } yyrule16: // , { return tComma } yyrule17: // \"(\\.|[^\\"\n])*\" { l.state = sLabels return tLValue goto yystate0 } yyrule18: // {S}\{ { l.state = sComplexValue return tBraceOpen goto yystate0 } yyrule19: // {L}({L}|{D})* { return tLName } yyrule20: // : { return tColon } yyrule21: // \[ { return tBracketOpen } yyrule22: // \] { return tBracketClose } yyrule23: // , { return tComma } yyrule24: // [ \t]+ { // Skip whitespace inside the block goto yystate0 } yyrule25: // [^ \n\t,\[\]{}:]+ { return tValue } yyrule26: // \} { l.state = sTimestamp return tBraceClose goto yystate0 } yyrule27: // {S}[^{ \n]+ { l.state = sTimestamp return tValue goto yystate0 } yyrule28: // {S}st@[^ \n]+ { return tStartTimestamp } yyrule29: // {S}[^ \n]+ { return tTimestamp } yyrule30: // \n { l.state = sInit return tLinebreak goto yystate0 } yyrule31: // {S}#{S}\{ { l.state = sExemplar return tComment goto yystate0 } yyrule32: // {L}({L}|{D})* { return tLName } yyrule33: // \"(\\.|[^\\"\n])*\" { l.state = sExemplar return tQString goto yystate0 } yyrule34: // \} { l.state = sEValue return tBraceClose goto yystate0 } yyrule35: // = { l.state = sEValue return tEqual goto yystate0 } yyrule36: // \"(\\.|[^\\"\n])*\" { l.state = sExemplar return tLValue goto yystate0 } yyrule37: // , { return tComma } yyrule38: // {S}[^ \n]+ { l.state = sETimestamp return tValue goto yystate0 } yyrule39: // {S}[^ \n]+ { return tTimestamp } yyrule40: // \n if true { // avoid go vet determining the below panic will not be reached l.state = sInit return tLinebreak goto yystate0 } panic("unreachable") yyabort: // no lexem recognized // silence unused label errors for build and satisfy go vet reachability analysis { if false { goto yyabort } if false { goto yystate0 } if false { goto yystate1 } if false { goto yystate6 } if false { goto yystate26 } if false { goto yystate31 } if false { goto yystate34 } if false { goto yystate42 } if false { goto yystate46 } if false { goto yystate51 } if false { goto yystate62 } if false { goto yystate70 } if false { goto yystate76 } if false { goto yystate80 } } return tInvalid }