| 1 | = E-!TextEditor, !InType, etc. !TextMate-based language syntax = |
| 2 | |
| 3 | 1. Open the bundle editor: "Bundles" -> "Edit Bundles" -> "Show Bundle Editor" |
| 4 | 2. Add a bundle named "Cobra" (if you do not already have one) |
| 5 | 3. Add a language file name "Cobra" |
| 6 | 4. Paste the code below |
| 7 | 5. Save the language file |
| 8 | |
| 9 | All files with the Cobra extension will now be highlighted per the grammars found in the file. |
| 10 | At the moment enough grammars to get by is presented. Please discuss improvements or make them |
| 11 | yourself using the guidelines at [http://manual.macromates.com/en/language_grammars TextMate Manual Language Grammars]. |
| 12 | |
| 13 | {{{ |
| 14 | #!python |
| 15 | { |
| 16 | "patterns" : [ |
| 17 | { |
| 18 | "name" : "comment.line.cobra", |
| 19 | "match" : "(#).*$" |
| 20 | }, |
| 21 | { |
| 22 | "name" : "constant.numeric.hexadecimal.cobra", |
| 23 | "match" : "\\b(?i:(0x\\h*)L?)" |
| 24 | }, |
| 25 | { |
| 26 | "name" : "constant.numeric.octal.cobra", |
| 27 | "match" : "\\b(?i:(0[0-7]+)L?)" |
| 28 | }, |
| 29 | { |
| 30 | "name" : "constant.numeric.float.cobra", |
| 31 | "match" : "\\b(?i:(\\d+\\.\\d*(e[\\-\\+]?\\d+)?))(?=[^a-zA-Z_])" |
| 32 | }, |
| 33 | { |
| 34 | "name" : "constant.numeric.float.cobra", |
| 35 | "match" : "(?<=[^0-9a-zA-Z_])(?i:(\\.\\d+(e[\\-\\+]?\\d+)?))" |
| 36 | }, |
| 37 | { |
| 38 | "name" : "constant.numeric.float.cobra", |
| 39 | "match" : "\\b(?i:(\\d+e[\\-\\+]?\\d+))" |
| 40 | }, |
| 41 | { |
| 42 | "name" : "constant.numeric.integer.long.decimal.cobra", |
| 43 | "match" : "\\b(?i:([1-9]+[0-9]*|0)L)" |
| 44 | }, |
| 45 | { |
| 46 | "name" : "constant.numeric.integer.decimal.cobra", |
| 47 | "match" : "\\b([1-9]+[0-9]*|0)" |
| 48 | }, |
| 49 | { |
| 50 | "name" : "keyword.control.cobra", |
| 51 | "match" : "\\b(inherits|branch|on|else|catch|finally|for|if|try|while|break|continue|pass|raise|return|using|yield)\\b" |
| 52 | }, |
| 53 | { |
| 54 | "name" : "keyword.operator.logical.cobra", |
| 55 | "match" : "\\b(and|in|not|or)\\b" |
| 56 | }, |
| 57 | { |
| 58 | "name" : "keyword.other.cobra", |
| 59 | "match" : "\\b(as|assert|print|var|invariant|is|is\\s*shared)\\b" |
| 60 | }, |
| 61 | { |
| 62 | "name" : "keyword.operator.comparison.cobra", |
| 63 | "match" : "<\\=|>\\=|\\=\\=|<|>|<>" |
| 64 | }, |
| 65 | { |
| 66 | "name" : "keyword.operator.assignment.cobra", |
| 67 | "match" : "\\=|\\+\\=|-\\=|\\*\\=|/\\=|//\\=|%\\=|&\\=|\\|\\=|\\^\\=|>>\\=|<<\\=|\\*\\*\\=" |
| 68 | }, |
| 69 | { |
| 70 | "name" : "keyword.operator.arithmetic.cobra", |
| 71 | "match" : "\\+|\\-|\\*|\\*\\*|/|//|%|<<|>>|&|\\||\\^|~" |
| 72 | }, |
| 73 | { |
| 74 | "match" : "\\s*(use|namespace)\\s+([a-zA-Z0-9_.]+)$", |
| 75 | "captures" : { |
| 76 | "1" : { |
| 77 | "name" : "keyword.other.namespacing.cobra" |
| 78 | }, |
| 79 | "2" : { |
| 80 | "name" : "constant.class.cobra" |
| 81 | } |
| 82 | } |
| 83 | }, |
| 84 | { |
| 85 | "name" : "storage.type.function.cobra", |
| 86 | "match" : "\\b(def|cue|get|set|test|ensure|body|require)\\b" |
| 87 | }, |
| 88 | { |
| 89 | "name" : "support.function.cobra", |
| 90 | "match" : "\\b(base|(?<!is\\s)shared)\\b" |
| 91 | }, |
| 92 | { |
| 93 | "name" : "support.type.cobra", |
| 94 | "match" : "\\b(bool|char|int|uint|float|decimal|number|dynamic|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\\b" |
| 95 | }, |
| 96 | { |
| 97 | "name" : "support.class.cobra", |
| 98 | "match" : "\\b(String|List|Dictionary|Set|Stack|Queue|TextWriter|TextReader|StringBuilder)(?:\\?)?\\s*(<of\\s*[a-zA-Z0-9_]+>)\\b" |
| 99 | }, |
| 100 | { |
| 101 | "include" : "#types" |
| 102 | }, |
| 103 | { |
| 104 | "include" : "#strings" |
| 105 | }, |
| 106 | { |
| 107 | "begin" : "^\\s*(\"\"\")", |
| 108 | "name" : "comment.block.cobra", |
| 109 | "end" : "\"\"\"\\s*$" |
| 110 | }, |
| 111 | { |
| 112 | "begin" : "^\\s*(?:class)\\s+(?=[a-zA-Z_][a-zA-Z0-9_]*)", |
| 113 | "patterns" : [ |
| 114 | { |
| 115 | "name" : "keyword.operator.cobra", |
| 116 | "match" : "(inherits|implements|is|partial)" |
| 117 | }, |
| 118 | { |
| 119 | "name" : "entity.name.type.cobra", |
| 120 | "match" : "[a-zA-Z0-9_]+" |
| 121 | }, |
| 122 | { |
| 123 | "include" : "#types" |
| 124 | } |
| 125 | ], |
| 126 | "name" : "storage.type.class.cobra", |
| 127 | "end" : "$", |
| 128 | "beginCaptures" : { |
| 129 | "1" : { |
| 130 | "name" : "entity.name.type.cobra" |
| 131 | } |
| 132 | } |
| 133 | }, |
| 134 | { |
| 135 | "match" : "^\\s+(var|def|cue|get|pro|sig)\\s+([a-zA-Z_]\\w+)", |
| 136 | "name" : "meta.type.method.cobra", |
| 137 | "captures" : { |
| 138 | "1" : { |
| 139 | "name" : "keyword.operator.method.cobra" |
| 140 | }, |
| 141 | "2" : { |
| 142 | "name" : "entity.name.type.cobra" |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | ], |
| 147 | "name" : "Cobra", |
| 148 | "scopeName" : "source.cobra", |
| 149 | "fileTypes" : [ |
| 150 | "cobra" |
| 151 | ], |
| 152 | "foldingStopMarker" : "", |
| 153 | "foldingStartMarker" : "", |
| 154 | "repository" : { |
| 155 | "types" : { |
| 156 | "match" : "(?<=as|\\=)\\s+([A-Z][a-zA-Z0-9_]+)\\s*(\\??|<\\s*of\\s+[a-zA-Z0-9]+>)?", |
| 157 | "captures" : { |
| 158 | "1" : { |
| 159 | "name" : "entity.name.class.cobra" |
| 160 | }, |
| 161 | "2" : { |
| 162 | "name" : "entity.name.generic.cobra" |
| 163 | } |
| 164 | } |
| 165 | }, |
| 166 | "escaped-characters" : { |
| 167 | "name" : "constant.character.escape.cobra", |
| 168 | "match" : "(\\\\x[0-9A-F]{2})|(\\\\[0-7]{3})|(\\\\\\n)|(\\\\\\\\)|(\\\\\\\")|(\\\\')|(\\\\a)|(\\\\b)|(\\\\f)|(\\\\n)|(\\\\r)|(\\\\t)|(\\\\v)" |
| 169 | }, |
| 170 | "strings" : { |
| 171 | "patterns" : [ |
| 172 | { |
| 173 | "begin" : "r?'", |
| 174 | "patterns" : [ |
| 175 | { |
| 176 | "include" : "#escaped-characters" |
| 177 | } |
| 178 | ], |
| 179 | "name" : "string.quoted.single.cobra", |
| 180 | "end" : "'" |
| 181 | } |
| 182 | ] |
| 183 | } |
| 184 | }, |
| 185 | "firstLineMatch" : "^#!/.*\\bcobra\\b" |
| 186 | } |
| 187 | }}} |