1package m 2 3import ( 4 . "github.com/alecthomas/chroma" // nolint 5 "github.com/alecthomas/chroma/lexers/internal" 6) 7 8var MonkeyC = internal.Register(MustNewLazyLexer( 9 &Config{ 10 Name: "MonkeyC", 11 Aliases: []string{"monkeyc"}, 12 Filenames: []string{"*.mc"}, 13 MimeTypes: []string{"text/x-monkeyc"}, 14 }, 15 monkeyCRules, 16)) 17 18func monkeyCRules() Rules { 19 return Rules{ 20 "root": { 21 {`[^\S\n]+`, Text, nil}, 22 {`\n`, Text, nil}, 23 {`//(\n|[\w\W]*?[^\\]\n)`, CommentSingle, nil}, 24 {`/(\\\n)?[*][\w\W]*?[*](\\\n)?/`, CommentMultiline, nil}, 25 {`/(\\\n)?[*][\w\W]*`, CommentMultiline, nil}, 26 {`:[a-zA-Z_][\w_\.]*`, StringSymbol, nil}, 27 {`[{}\[\]\(\),;:\.]`, Punctuation, nil}, 28 {`[&~\|\^!+\-*\/%=?]`, Operator, nil}, 29 {`=>|[+-]=|&&|\|\||>>|<<|[<>]=?|[!=]=`, Operator, nil}, 30 {`\b(and|or|instanceof|has|extends|new)`, OperatorWord, nil}, 31 {Words(``, `\b`, `NaN`, `null`, `true`, `false`), KeywordConstant, nil}, 32 {`(using)((?:\s|\\\\s)+)`, ByGroups(KeywordNamespace, Text), Push("import")}, 33 {`(class)((?:\s|\\\\s)+)`, ByGroups(KeywordDeclaration, Text), Push("class")}, 34 {`(function)((?:\s|\\\\s)+)`, ByGroups(KeywordDeclaration, Text), Push("function")}, 35 {`(module)((?:\s|\\\\s)+)`, ByGroups(KeywordDeclaration, Text), Push("module")}, 36 {`\b(if|else|for|switch|case|while|break|continue|default|do|try|catch|finally|return|throw|extends|function)\b`, Keyword, nil}, 37 {`\b(const|enum|hidden|public|protected|private|static)\b`, KeywordType, nil}, 38 {`\bvar\b`, KeywordDeclaration, nil}, 39 {`\b(Activity(Monitor|Recording)?|Ant(Plus)?|Application|Attention|Background|Communications|Cryptography|FitContributor|Graphics|Gregorian|Lang|Math|Media|Persisted(Content|Locations)|Position|Properties|Sensor(History|Logging)?|Storage|StringUtil|System|Test|Time(r)?|Toybox|UserProfile|WatchUi|Rez|Drawables|Strings|Fonts|method)\b`, NameBuiltin, nil}, 40 {`\b(me|self|\$)\b`, NameBuiltinPseudo, nil}, 41 {`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, 42 {`'(\\\\|\\'|[^''])*'`, LiteralStringSingle, nil}, 43 {`-?(0x[0-9a-fA-F]+l?)`, NumberHex, nil}, 44 {`-?([0-9]+(\.[0-9]+[df]?|[df]))\b`, NumberFloat, nil}, 45 {`-?([0-9]+l?)`, NumberInteger, nil}, 46 {`[a-zA-Z_]\w*`, Name, nil}, 47 }, 48 "import": { 49 {`([a-zA-Z_][\w_\.]*)(?:(\s+)(as)(\s+)([a-zA-Z_][\w_]*))?`, ByGroups(NameNamespace, Text, KeywordNamespace, Text, NameNamespace), nil}, 50 Default(Pop(1)), 51 }, 52 "class": { 53 {`([a-zA-Z_][\w_\.]*)(?:(\s+)(extends)(\s+)([a-zA-Z_][\w_\.]*))?`, ByGroups(NameClass, Text, KeywordDeclaration, Text, NameClass), nil}, 54 Default(Pop(1)), 55 }, 56 "function": { 57 {`initialize`, NameFunctionMagic, nil}, 58 {`[a-zA-Z_][\w_\.]*`, NameFunction, nil}, 59 Default(Pop(1)), 60 }, 61 "module": { 62 {`[a-zA-Z_][\w_\.]*`, NameNamespace, nil}, 63 Default(Pop(1)), 64 }, 65 } 66} 67