# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersload_lexer'ocaml/common.rb'classReScript<OCamlCommontitle"ReScript"desc"The ReScript programming language (rescript-lang.org)"tag'rescript'filenames'*.res','*.resi'mimetypes'text/x-rescript'defself.keywords@keywords||=Set.new(%w(
open let rec and as exception assert lazy if else
for in to downto while switch when external type private
mutable constraint include module of with try import export
))enddefself.types@types||=Set.new(%w(
bool int float char string
unit list array option ref exn format
))enddefself.word_operators@word_operators||=Set.new(%w(mod land lor lxor lsl lsr asr or))endstate:rootdorule%r/\s+/m,Textrule%r([,.:?~\\]),Text# Boolean Literalrule%r/\btrue|false\b/,Keyword::Constant# Module chainrule%r/#{@@upper_id}(?=\s*[.])/,Name::Namespace,:dotted# Decoratorrule%r/@#{@@id}(\.#{@@id})*/,Name::Decorator# Poly variantrule%r/\##{@@id}/,Name::Class# Variant or Modulerule@@upper_id,Name::Class# Commentsrule%r(//.*),Comment::Singlerule%r(/\*),Comment::Multiline,:comment# Keywords and identifiersrule@@iddo|m|match=m[0]ifself.class.keywords.include?matchtokenKeywordelsifself.class.word_operators.include?matchtokenOperator::Wordelsifself.class.types.include?matchtokenKeyword::TypeelsetokenNameendend# Bracesrule%r/[(){}\[\];]+/,Punctuation# Operatorsrule%r([;_!$%&*+/<=>@^|-]+),Operator# Numbersrule%r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i,Num::Floatrule%r/0x\h[\h_]*/i,Num::Hexrule%r/0o[0-7][0-7_]*/i,Num::Octrule%r/0b[01][01_]*/i,Num::Binrule%r/\d[\d_]*/,Num::Integer# String and Charrule%r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/,Str::Charrule%r/'[^'\/]'/,Str::Charrule%r/'/,Keywordrule%r/"/,Str::Double,:string# Interpolated stringrule%r/`/dotokenStr::Doublepush:interpolated_stringendendstate:commentdorule%r([^/\*]+),Comment::Multilinerule%r(/\*),Comment::Multiline,:commentrule%r(\*/),Comment::Multiline,:pop!rule%r([*/]),Comment::Multilineendstate:interpolated_stringdorule%r/[$]{/,Punctuation,:interpolated_expressionrule%r/`/,Str::Double,:pop!rule%r/\\[$`]/,Str::Escaperule%r/[^$`\\]+/,Str::Doublerule%r/[\\$]/,Str::Doubleendstate:interpolated_expressiondorule%r/}/,Punctuation,:pop!mixin:rootendendendend