# -*- coding: utf-8 -*- #moduleRougemoduleLexersclassFSharp<RegexLexertitle"FSharp"desc'F# (fsharp.net)'tag'fsharp'filenames'*.fs','*.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']*/iupper_id=/[A-Z][\w']*/state:rootdorule/\s+/m,Textrule/false|true|[(][)]|\[\]/,Name::Builtin::Pseudorule/#{upper_id}(?=\s*[.])/,Name::Namespace,:dottedruleupper_id,Name::Classrule/[(][*](?![)])/,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/-?\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!endendendend