<lexer>
  <config>
    <name>OCaml</name>
    <alias>ocaml</alias>
    <filename>*.ml</filename>
    <filename>*.mli</filename>
    <filename>*.mll</filename>
    <filename>*.mly</filename>
    <mime_type>text/x-ocaml</mime_type>
  </config>
  <rules>
    <state name="escape-sequence">
      <rule pattern="\\[\\&#34;\&#39;ntbr]">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\[0-9]{3}">
        <token type="LiteralStringEscape"/>
      </rule>
      <rule pattern="\\x[0-9a-fA-F]{2}">
        <token type="LiteralStringEscape"/>
      </rule>
    </state>
    <state name="root">
      <rule pattern="\s+">
        <token type="Text"/>
      </rule>
      <rule pattern="false|true|\(\)|\[\]">
        <token type="NameBuiltinPseudo"/>
      </rule>
      <rule pattern="\b([A-Z][\w\&#39;]*)(?=\s*\.)">
        <token type="NameNamespace"/>
        <push state="dotted"/>
      </rule>
      <rule pattern="\b([A-Z][\w\&#39;]*)">
        <token type="NameClass"/>
      </rule>
      <rule pattern="\(\*(?![)])">
        <token type="Comment"/>
        <push state="comment"/>
      </rule>
      <rule pattern="\b(as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|false|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|object|of|open|private|raise|rec|sig|struct|then|to|true|try|type|value|val|virtual|when|while|with)\b">
        <token type="Keyword"/>
      </rule>
      <rule pattern="({([a-z_]*)\|)([\s\S]+?)(?=\|\2})(\|\2})">
        <bygroups>
          <token type="LiteralStringAffix"/>
          <token type="Ignore"/>
          <token type="LiteralString"/>
          <token type="LiteralStringAffix"/>
        </bygroups>
      </rule>
      <rule pattern="(~|\}|\|]|\||\{&lt;|\{|`|_|]|\[\||\[&gt;|\[&lt;|\[|\?\?|\?|&gt;\}|&gt;]|&gt;|=|&lt;-|&lt;|;;|;|:&gt;|:=|::|:|\.\.|\.|-&gt;|-\.|-|,|\+|\*|\)|\(|&amp;&amp;|&amp;|#|!=)">
        <token type="Operator"/>
      </rule>
      <rule pattern="([=&lt;&gt;@^|&amp;+\*/$%-]|[!?~])?[!$%&amp;*+\./:&lt;=&gt;?@^|~-]">
        <token type="Operator"/>
      </rule>
      <rule pattern="\b(and|asr|land|lor|lsl|lxor|mod|or)\b">
        <token type="OperatorWord"/>
      </rule>
      <rule pattern="\b(unit|int|float|bool|string|char|list|array)\b">
        <token type="KeywordType"/>
      </rule>
      <rule pattern="[^\W\d][\w&#39;]*">
        <token type="Name"/>
      </rule>
      <rule pattern="-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)">
        <token type="LiteralNumberFloat"/>
      </rule>
      <rule pattern="0[xX][\da-fA-F][\da-fA-F_]*">
        <token type="LiteralNumberHex"/>
      </rule>
      <rule pattern="0[oO][0-7][0-7_]*">
        <token type="LiteralNumberOct"/>
      </rule>
      <rule pattern="0[bB][01][01_]*">
        <token type="LiteralNumberBin"/>
      </rule>
      <rule pattern="\d[\d_]*">
        <token type="LiteralNumberInteger"/>
      </rule>
      <rule pattern="&#39;(?:(\\[\\\&#34;&#39;ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))&#39;">
        <token type="LiteralStringChar"/>
      </rule>
      <rule pattern="&#39;.&#39;">
        <token type="LiteralStringChar"/>
      </rule>
      <rule pattern="&#39;">
        <token type="Keyword"/>
      </rule>
      <rule pattern="&#34;">
        <token type="LiteralStringDouble"/>
        <push state="string"/>
      </rule>
      <rule pattern="[~?][a-z][\w\&#39;]*:">
        <token type="NameVariable"/>
      </rule>
    </state>
    <state name="comment">
      <rule pattern="[^(*)]+">
        <token type="Comment"/>
      </rule>
      <rule pattern="\(\*">
        <token type="Comment"/>
        <push/>
      </rule>
      <rule pattern="\*\)">
        <token type="Comment"/>
        <pop depth="1"/>
      </rule>
      <rule pattern="[(*)]">
        <token type="Comment"/>
      </rule>
    </state>
    <state name="string">
      <rule pattern="[^\\&#34;]+">
        <token type="LiteralStringDouble"/>
      </rule>
      <rule>
        <include state="escape-sequence"/>
      </rule>
      <rule pattern="\\\n">
        <token type="LiteralStringDouble"/>
      </rule>
      <rule pattern="&#34;">
        <token type="LiteralStringDouble"/>
        <pop depth="1"/>
      </rule>
    </state>
    <state name="dotted">
      <rule pattern="\s+">
        <token type="Text"/>
      </rule>
      <rule pattern="\.">
        <token type="Punctuation"/>
      </rule>
      <rule pattern="[A-Z][\w\&#39;]*(?=\s*\.)">
        <token type="NameNamespace"/>
      </rule>
      <rule pattern="[A-Z][\w\&#39;]*">
        <token type="NameClass"/>
        <pop depth="1"/>
      </rule>
      <rule pattern="[a-z_][\w\&#39;]*">
        <token type="Name"/>
        <pop depth="1"/>
      </rule>
      <rule>
        <pop depth="1"/>
      </rule>
    </state>
  </rules>
</lexer>