package lexers import ( . "github.com/alecthomas/chroma" // nolint ) // Fsharp lexer. var Fsharp = Register(MustNewLexer( &Config{ Name: "FSharp", Aliases: []string{"fsharp"}, Filenames: []string{"*.fs", "*.fsi"}, MimeTypes: []string{"text/x-fsharp"}, }, Rules{ "escape-sequence": { {`\\[\\"\'ntbrafv]`, LiteralStringEscape, nil}, {`\\[0-9]{3}`, LiteralStringEscape, nil}, {`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil}, {`\\U[0-9a-fA-F]{8}`, LiteralStringEscape, nil}, }, "root": { {`\s+`, Text, nil}, {`\(\)|\[\]`, NameBuiltinPseudo, nil}, {`\b(?|-|\\.\\.|\\.|::|:=|:>|:|;;|;|<-|<\\]|<|>\\]|>|\\?\\?|\\?|\\[<|\\[\\||\\[|\\]|_|`|\\{|\\|\\]|\\||\\}|~|<@@|<@|=|@>|@@>)", Operator, nil}, {`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil}, {`\b(and|or|not)\b`, OperatorWord, nil}, {`\b(sbyte|byte|char|nativeint|unativeint|float32|single|float|double|int8|uint8|int16|uint16|int32|uint32|int64|uint64|decimal|unit|bool|string|list|exn|obj|enum)\b`, KeywordType, nil}, {`#[ \t]*(if|endif|else|line|nowarn|light|\d+)\b.*?\n`, CommentPreproc, nil}, {`[^\W\d][\w']*`, Name, nil}, {`\d[\d_]*[uU]?[yslLnQRZINGmM]?`, LiteralNumberInteger, nil}, {`0[xX][\da-fA-F][\da-fA-F_]*[uU]?[yslLn]?[fF]?`, LiteralNumberHex, nil}, {`0[oO][0-7][0-7_]*[uU]?[yslLn]?`, LiteralNumberOct, nil}, {`0[bB][01][01_]*[uU]?[yslLn]?`, LiteralNumberBin, nil}, {`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)[fFmM]?`, LiteralNumberFloat, nil}, {`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'B?`, LiteralStringChar, nil}, {`'.'`, LiteralStringChar, nil}, {`'`, Keyword, nil}, {`@?"`, LiteralStringDouble, Push("string")}, {`[~?][a-z][\w\']*:`, NameVariable, nil}, }, "dotted": { {`\s+`, Text, nil}, {`\.`, Punctuation, nil}, {`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil}, {`[A-Z][\w\']*`, Name, Pop(1)}, {`[a-z_][\w\']*`, Name, Pop(1)}, Default(Pop(1)), }, "comment": { {`[^(*)@"]+`, Comment, nil}, {`\(\*`, Comment, Push()}, {`\*\)`, Comment, Pop(1)}, {`@"`, LiteralString, Push("lstring")}, {`"""`, LiteralString, Push("tqs")}, {`"`, LiteralString, Push("string")}, {`[(*)@]`, Comment, nil}, }, "string": { {`[^\\"]+`, LiteralString, nil}, Include("escape-sequence"), {`\\\n`, LiteralString, nil}, {`\n`, LiteralString, nil}, {`"B?`, LiteralString, Pop(1)}, }, "lstring": { {`[^"]+`, LiteralString, nil}, {`\n`, LiteralString, nil}, {`""`, LiteralString, nil}, {`"B?`, LiteralString, Pop(1)}, }, "tqs": { {`[^"]+`, LiteralString, nil}, {`\n`, LiteralString, nil}, {`"""B?`, LiteralString, Pop(1)}, {`"`, LiteralString, nil}, }, }, ))