# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassFSharp<RegexLexertitle"FSharp"desc'F# (fsharp.net)'tag'fsharp'filenames'*.fs','*.fsi','*.fsx'mimetypes'application/fsharp-script','text/x-fsharp','text/x-fsi'defself.keywords@keywords||=Set.new%w(
abstract and as assert base begin class default delegate do
done downcast downto elif else end exception extern false
finally for fun function global if in inherit inline interface
internal lazy let let! match member module mutable namespace
new not null of open or override private public rec return
return! select static struct then to true try type upcast
use use! val void when while with yield yield! sig atomic
break checked component const constraint constructor
continue eager event external fixed functor include method
mixin object parallel process protected pure sealed tailcall
trait virtual volatile
)enddefself.keyopts@keyopts||=Set.new%w(
!= # & && ( ) * \+ , - -. -> . .. : :: := :> ; ;; < <- =
> >] >} ? ?? [ [< [> [| ] _ ` { {< | |] } ~ |> <| <>
)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']*)|(``[^`\n\r\t]+``)/iupper_id=/[A-Z][\w']*/state:rootdorule%r/\s+/m,Textrule%r/false|true|[(][)]|\[\]/,Name::Builtin::Pseudorule%r/#{upper_id}(?=\s*[.])/,Name::Namespace,:dottedruleupper_id,Name::Classrule%r/[(][*](?![)])/,Comment,:commentrule%r(//.*?$),Comment::Singleruleiddo|m|match=m[0]ifself.class.keywords.include?matchtokenKeywordelsifself.class.word_operators.include?matchtokenOperator::Wordelsifself.class.primitives.include?matchtokenKeyword::TypeelsetokenNameendendruleoperatordo|m|match=m[0]ifself.class.keyopts.include?matchtokenPunctuationelsetokenOperatorendendrule%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::Integerrule%r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/,Str::Charrule%r/'[.]'/,Str::Charrule%r/'/,Keywordrule%r/"/,Str::Double,:stringrule%r/[~?]#{id}/,Name::Variableendstate:commentdorule%r/[^(*)]+/,Commentrule(/[(][*]/){tokenComment;push}rule%r/[*][)]/,Comment,:pop!rule%r/[(*)]/,Commentendstate:stringdorule%r/[^\\"]+/,Str::Doublemixin:escape_sequencerule%r/\\\n/,Str::Doublerule%r/"/,Str::Double,:pop!endstate:escape_sequencedorule%r/\\[\\"'ntbr]/,Str::Escaperule%r/\\\d{3}/,Str::Escaperule%r/\\x\h{2}/,Str::Escapeendstate:dotteddorule%r/\s+/m,Textrule%r/[.]/,Punctuationrule%r/#{upper_id}(?=\s*[.])/,Name::Namespaceruleupper_id,Name::Class,:pop!ruleid,Name,:pop!endendendend