Version 2 (modified by webnov8, 15 years ago) |
---|
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(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|from|assert|print|var|invariant|is)\\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.type.primitive.cobra", "match" : "\\b(nil|bool|char|int|uint|float|decimal|number|dynamic|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\\b(\\?)?", "captures" : { "2" : { "name" : "support.type.nillible-marker.cobra" } } }, { "name" : "support.class.cobra", "match" : "\\b(String|List|Dictionary|Set|Stack|Queue|TextWriter|TextReader|StringBuilder)(?:\\?)?\\s*(<of\\s*[a-zA-Z0-9_]+>)\\b" }, { "include" : "#strings" }, { "begin" : "^\\s*(\"\"\")", "name" : "comment.block.cobra", "end" : "\"\"\"\\s*$" }, { "match" : "^\\s+(var)\\s+(_[\\w_]+)\\s+(as)?(\\s+[\\w_<>\\s?]+)", "captures" : { "3" : { "name" : "keyword.operator.specifier.cobra" }, "1" : { "name" : "keyword.operator.declaration.cobra" }, "4" : { "name" : "support.other.type.cobra" }, "2" : { "name" : "support.private-variable.cobra" } } }, { "name" : "keyword.operator.enumeration.cobra", "match" : "\\s*(?:enum|interface|struct|mixin)\\s+([\\w_]+)", "captures" : { "1" : { "name" : "entity.name.enumeration.cobras" } } }, { "name" : "keyword.operator.enumeration.cobra", "match" : "\\s*(is|has)\\s+(shared|partial)\\s*", "captures" : { "1" : { "name" : "operator.name.is.cobra" }, "2" : { "name" : "constant.other.modifier.cobra" } } }, { "name" : "keyword.operator.enumeration.cobra", "match" : "\\s*(implements|inherits)\\s+([a-zA-Z_][\\w_]*)\\s*", "captures" : { "1" : { "name" : "operator.name.is.cobra" }, "2" : { "name" : "constant.other.interface.cobra" } } }, { "name" : "meta.type.method.cobra", "match" : "^\\s+(def|cue|get|pro|sig)\\s+([a-zA-Z_]\\w+)", "captures" : { "1" : { "name" : "keyword.operator.method.cobra" }, "2" : { "name" : "entity.name.type.cobra" } } }, { "match" : "^\\s*(class)\\s+([a-zA-Z_][\\w_]*)\\s*", "captures" : { "1" : { "name" : "keyword.operator.class-definition.cobra" }, "2" : { "name" : "entity.name.user-defined-type.cobra" } } } ], "name" : "Cobra", "scopeName" : "source.cobra", "fileTypes" : [ "cobra" ], "foldingStopMarker" : "", "foldingStartMarker" : "", "repository" : { "escaped-characters" : { "name" : "constant.character.escape.cobra", "match" : "(\\\\x[0-9A-F]{2})|(\\\\[0-7]{3})|(\\\\\\n)|(\\\\\\\\)|(\\\\\\\")|(\\\\')|(\\\\a)|(\\\\b)|(\\\\f)|(\\\\n)|(\\\\r)|(\\\\t)|(\\\\v)" }, "varsub" : { "name" : "support.other.variable-substitution.cobra", "match" : "(\\[[\\w.]+\\])" }, "strings" : { "patterns" : [ { "begin" : "(?<!')r?'(?!')", "patterns" : [ { "include" : "#escaped-characters" }, { "include" : "#varsub" } ], "name" : "string.quoted.single.cobra", "end" : "'" }, { "begin" : "(?<!\")r?\"(?!\")", "patterns" : [ { "include" : "#escaped-characters" }, { "include" : "#varsub" } ], "name" : "string.quoted.single.cobra", "end" : "\"" } ] } }, "firstLineMatch" : "^#!/.*\\bcobra\\b" }