E-TextEditor, InType, etc. TextMate-based language syntax
- Open the bundle editor: "Bundles" -> "Edit Bundles" -> "Show Bundle Editor"
- Add a bundle named "Cobra" (if you do not already have one)
- Add a language file name "Cobra"
- Paste the code below
- Save the language file
All files with the Cobra extension will now be highlighted per the grammars found in the file. At the moment enough grammars to get by is presented. Please discuss improvements or make them yourself using the guidelines at TextMate Manual Language Grammars.
{ "patterns" : [ { "name" : "comment.line.cobra", "match" : "(#).*$" }, { "name" : "constant.numeric.hexadecimal.cobra", "match" : "\\b(?i:(0x\\h*)L?)" }, { "name" : "constant.numeric.octal.cobra", "match" : "\\b(?i:(0[0-7]+)L?)" }, { "name" : "constant.numeric.float.cobra", "match" : "\\b(?i:(\\d+\\.\\d*(e[\\-\\+]?\\d+)?))(?=[^a-zA-Z_])" }, { "name" : "constant.numeric.float.cobra", "match" : "(?<=[^0-9a-zA-Z_])(?i:(\\.\\d+(e[\\-\\+]?\\d+)?))" }, { "name" : "constant.numeric.float.cobra", "match" : "\\b(?i:(\\d+e[\\-\\+]?\\d+))" }, { "name" : "constant.numeric.integer.long.decimal.cobra", "match" : "\\b(?i:([1-9]+[0-9]*|0)L)" }, { "name" : "constant.numeric.integer.decimal.cobra", "match" : "\\b([1-9]+[0-9]*|0)" }, { "name" : "keyword.control.cobra", "match" : "\\b(inherits|branch|on|else|catch|finally|for|if|try|while|break|continue|pass|raise|return|using|yield)\\b" }, { "name" : "keyword.operator.logical.cobra", "match" : "\\b(and|in|not|or)\\b" }, { "name" : "keyword.other.cobra", "match" : "\\b(as|assert|print|var|invariant|is|is\\s*shared)\\b" }, { "name" : "keyword.operator.comparison.cobra", "match" : "<\\=|>\\=|\\=\\=|<|>|<>" }, { "name" : "keyword.operator.assignment.cobra", "match" : "\\=|\\+\\=|-\\=|\\*\\=|/\\=|//\\=|%\\=|&\\=|\\|\\=|\\^\\=|>>\\=|<<\\=|\\*\\*\\=" }, { "name" : "keyword.operator.arithmetic.cobra", "match" : "\\+|\\-|\\*|\\*\\*|/|//|%|<<|>>|&|\\||\\^|~" }, { "match" : "\\s*(use|namespace)\\s+([a-zA-Z0-9_.]+)$", "captures" : { "1" : { "name" : "keyword.other.namespacing.cobra" }, "2" : { "name" : "constant.class.cobra" } } }, { "name" : "storage.type.function.cobra", "match" : "\\b(def|cue|get|set|test|ensure|body|require)\\b" }, { "name" : "support.function.cobra", "match" : "\\b(base|(?<!is\\s)shared)\\b" }, { "name" : "support.type.cobra", "match" : "\\b(bool|char|int|uint|float|decimal|number|dynamic|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\\b" }, { "name" : "support.class.cobra", "match" : "\\b(String|List|Dictionary|Set|Stack|Queue|TextWriter|TextReader|StringBuilder)(?:\\?)?\\s*(<of\\s*[a-zA-Z0-9_]+>)\\b" }, { "include" : "#types" }, { "include" : "#strings" }, { "begin" : "^\\s*(\"\"\")", "name" : "comment.block.cobra", "end" : "\"\"\"\\s*$" }, { "begin" : "^\\s*(?:class)\\s+(?=[a-zA-Z_][a-zA-Z0-9_]*)", "patterns" : [ { "name" : "keyword.operator.cobra", "match" : "(inherits|implements|is|partial)" }, { "name" : "entity.name.type.cobra", "match" : "[a-zA-Z0-9_]+" }, { "include" : "#types" } ], "name" : "storage.type.class.cobra", "end" : "$", "beginCaptures" : { "1" : { "name" : "entity.name.type.cobra" } } }, { "match" : "^\\s+(var|def|cue|get|pro|sig)\\s+([a-zA-Z_]\\w+)", "name" : "meta.type.method.cobra", "captures" : { "1" : { "name" : "keyword.operator.method.cobra" }, "2" : { "name" : "entity.name.type.cobra" } } } ], "name" : "Cobra", "scopeName" : "source.cobra", "fileTypes" : [ "cobra" ], "foldingStopMarker" : "", "foldingStartMarker" : "", "repository" : { "types" : { "match" : "(?<=as|\\=)\\s+([A-Z][a-zA-Z0-9_]+)\\s*(\\??|<\\s*of\\s+[a-zA-Z0-9]+>)?", "captures" : { "1" : { "name" : "entity.name.class.cobra" }, "2" : { "name" : "entity.name.generic.cobra" } } }, "escaped-characters" : { "name" : "constant.character.escape.cobra", "match" : "(\\\\x[0-9A-F]{2})|(\\\\[0-7]{3})|(\\\\\\n)|(\\\\\\\\)|(\\\\\\\")|(\\\\')|(\\\\a)|(\\\\b)|(\\\\f)|(\\\\n)|(\\\\r)|(\\\\t)|(\\\\v)" }, "strings" : { "patterns" : [ { "begin" : "r?'", "patterns" : [ { "include" : "#escaped-characters" } ], "name" : "string.quoted.single.cobra", "end" : "'" } ] } }, "firstLineMatch" : "^#!/.*\\bcobra\\b" }