# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassOCaml<RegexLexertitle"OCaml"desc'Objective Caml (ocaml.org)'tag'ocaml'filenames'*.ml','*.mli','*.mll','*.mly'mimetypes'text/x-ocaml'defself.keywords@keywords||=Set.new%w(
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
nonrec object of open private raise rec sig struct then to true
try type val virtual when while with
)enddefself.word_operators@word_operators||=Set.new%w(and asr land lor lsl lxor mod or)enddefself.primitives@primitives||=Set.new%w(unit int float bool string char list array)endoperator=%r([;,_!$%&*+./:<=>?@^|~#-]+)id=/[a-z_][\w']*/iupper_id=/[A-Z][\w']*/state:rootdorule/\s+/m,Textrule/false|true|[(][)]|\[\]/,Name::Builtin::Pseudorule/#{upper_id}(?=\s*[.])/,Name::Namespace,:dottedrule/`#{id}/,Name::Tagruleupper_id,Name::Classrule/[(][*](?![)])/,Comment,:commentruleiddo|m|match=m[0]ifself.class.keywords.include?matchtokenKeywordelsifself.class.word_operators.include?matchtokenOperator::Wordelsifself.class.primitives.include?matchtokenKeyword::TypeelsetokenNameendendrule/[(){}\[\];]+/,Punctuationruleoperator,Operatorrule/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i,Num::Floatrule/0x\h[\h_]*/i,Num::Hexrule/0o[0-7][0-7_]*/i,Num::Octrule/0b[01][01_]*/i,Num::Binrule/\d[\d_]*/,Num::Integerrule/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/,Str::Charrule/'[.]'/,Str::Charrule/'/,Keywordrule/"/,Str::Double,:stringrule/[~?]#{id}/,Name::Variableendstate:commentdorule/[^(*)]+/,Commentrule(/[(][*]/){tokenComment;push}rule/[*][)]/,Comment,:pop!rule/[(*)]/,Commentendstate:stringdorule/[^\\"]+/,Str::Doublemixin:escape_sequencerule/\\\n/,Str::Doublerule/"/,Str::Double,:pop!endstate:escape_sequencedorule/\\[\\"'ntbr]/,Str::Escaperule/\\\d{3}/,Str::Escaperule/\\x\h{2}/,Str::Escapeendstate:dotteddorule/\s+/m,Textrule/[.]/,Punctuationrule/#{upper_id}(?=\s*[.])/,Name::Namespaceruleupper_id,Name::Class,:pop!ruleid,Name,:pop!rule/[({\[]/,Punctuation,:pop!endendendend