<lexer>
  <config>
    <name>Protocol Buffer Text Format</name>
    <alias>txtpb</alias>
    <filename>*.txtpb</filename>
    <filename>*.textproto</filename>
    <filename>*.textpb</filename>
    <filename>*.pbtxt</filename>
    <mime_type>application/x-protobuf-text</mime_type>
    <case_insensitive>false</case_insensitive>
    <dot_all>false</dot_all>
    <ensure_nl>true</ensure_nl>
  </config>
  <rules>
    <state name="double-quote">
      <rule pattern="\\[abfnrtv\\\?&#39;&#34;]">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\[0-7]{1,3}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\x[0-9a-fA-F]{1,2}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\u[0-9a-fA-F]{4}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\U000[0-9a-fA-F]{5}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\U0010[0-9a-fA-F]{4}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="[^&#34;\\]+">
        <token type="LiteralStringDouble"/>
      </rule>
      <rule pattern="&#34;">
        <token type="LiteralStringDouble"/>
        <pop depth="1"/>
      </rule>
    </state>

    <state name="single-quote">
      <rule pattern="\\[abfnrtv\\\?&#39;&#34;]">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\[0-7]{1,3}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\x[0-9a-fA-F]{1,2}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\u[0-9a-fA-F]{4}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\U000[0-9a-fA-F]{5}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\U0010[0-9a-fA-F]{4}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="[^&#39;\\]+">
        <token type="LiteralStringSingle"/>
      </rule>
      <rule pattern="&#39;">
        <token type="LiteralStringSingle"/>
        <pop depth="1"/>
      </rule>
    </state>

    <state name="root">
      <!-- Comments -->
      <rule pattern="#.*\n">
        <token type="CommentSingle"/>
      </rule>

      <!-- Whitespace -->
      <rule pattern="[ \n\t\v\f\r]+">
        <token type="Text"/>
      </rule>

      <!-- Operators -->
      <rule pattern="-">
        <token type="Operator" />
      </rule>

      <!-- Special float literals -->
      <rule pattern="(?i)(?:inf|infinity)\b">
        <token type="LiteralNumberFloat"/>
      </rule>
      <rule pattern="(?i)nan\b">
        <token type="LiteralNumberFloat"/>
      </rule>

      <!-- Float literals with suffix (must come before decimal integers) -->
      <rule pattern="(?:0|[1-9][0-9]*)[fF]">
        <token type="LiteralNumberFloat"/>
      </rule>

      <!-- Float literals -->
      <rule pattern="\.[0-9]+(?:[eE][+-]?[0-9]+)?[fF]?">
        <token type="LiteralNumberFloat"/>
      </rule>
      <rule pattern="(?:0|[1-9][0-9]*)\.[0-9]*(?:[eE][+-]?[0-9]+)?[fF]?">
        <token type="LiteralNumberFloat"/>
      </rule>
      <rule pattern="(?:0|[1-9][0-9]*)[eE][+-]?[0-9]+[fF]?">
        <token type="LiteralNumberFloat"/>
      </rule>
      
      <!-- Hexadecimal integers -->
      <rule pattern="0[xX][0-9a-fA-F]+">
        <token type="LiteralNumberHex"/>
      </rule>
      
      <!-- Octal integers -->
      <rule pattern="0[0-7]+">
        <token type="LiteralNumberOct"/>
      </rule>
      
      <!-- Decimal integers -->
      <rule pattern="(?:0|[1-9][0-9]*)">
        <token type="LiteralNumberInteger"/>
      </rule>
      
      <!-- Boolean keywords -->
      <rule pattern="\b(?:[Tt]rue|[Ff]alse|t|f)\b">
        <token type="KeywordConstant"/>
      </rule>
      
      <!-- Strings -->
      <rule pattern="&#34;">
        <token type="LiteralStringDouble"/>
        <push state="double-quote"/>
      </rule>
      <rule pattern="&#39;">
        <token type="LiteralStringSingle"/>
        <push state="single-quote"/>
      </rule>
      
      <!-- Qualified names (with dots) for field paths and type URLs -->
      <rule pattern="[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)+">
        <token type="NameNamespace"/>
      </rule>
      
      <!-- Field names and identifiers (including enum values) -->
      <rule pattern="[a-zA-Z_][a-zA-Z0-9_]*">
        <token type="Name"/>
      </rule>
      
      <!-- URL paths in type URLs for Any expansion -->
      <rule pattern="/[a-zA-Z_][a-zA-Z0-9_/.]*">
        <token type="NameNamespace"/>
      </rule>
      
      <!-- Punctuation -->
      <rule pattern="[:;,&lt;&gt;\[\]{}]">
        <token type="Punctuation"/>
      </rule>
    </state>
  </rules>
</lexer>
