| 1 | = Draft for TextMate-like editor syntax file = |
| 2 | Initial attempt at creating a syntax for use in editors such as E-TextEditor, and InType. These are windows editors that mimic TextMate hence it should be similar for TextMate. |
| 3 | |
| 4 | {{{ |
| 5 | { |
| 6 | "patterns" : [ |
| 7 | { |
| 8 | "name" : "comment.line.cobra", |
| 9 | "match" : "(#).*$" |
| 10 | }, |
| 11 | { |
| 12 | "name" : "constant.numeric.integer.long.hexadecimal.cobra", |
| 13 | "match" : "\\b(?i:(0x\\h*)L)" |
| 14 | }, |
| 15 | { |
| 16 | "name" : "constant.numeric.integer.hexadecimal.cobra", |
| 17 | "match" : "\\b(?i:(0x\\h*))" |
| 18 | }, |
| 19 | { |
| 20 | "name" : "constant.numeric.integer.long.octal.cobra", |
| 21 | "match" : "\\b(?i:(0[0-7]+)L)" |
| 22 | }, |
| 23 | { |
| 24 | "name" : "constant.numeric.integer.octal.cobra", |
| 25 | "match" : "\\b(0[0-7]+)" |
| 26 | }, |
| 27 | { |
| 28 | "name" : "constant.numeric.complex.cobra", |
| 29 | "match" : "\\b(?i:(((\\d+(\\.(?=[^a-zA-Z_])\\d*)?|(?<=[^0-9a-zA-Z_])\\.\\d+)(e[\\-\\+]?\\d+)?))J)" |
| 30 | }, |
| 31 | { |
| 32 | "name" : "constant.numeric.float.cobra", |
| 33 | "match" : "\\b(?i:(\\d+\\.\\d*(e[\\-\\+]?\\d+)?))(?=[^a-zA-Z_])" |
| 34 | }, |
| 35 | { |
| 36 | "name" : "constant.numeric.float.cobra", |
| 37 | "match" : "(?<=[^0-9a-zA-Z_])(?i:(\\.\\d+(e[\\-\\+]?\\d+)?))" |
| 38 | }, |
| 39 | { |
| 40 | "name" : "constant.numeric.float.cobra", |
| 41 | "match" : "\\b(?i:(\\d+e[\\-\\+]?\\d+))" |
| 42 | }, |
| 43 | { |
| 44 | "name" : "constant.numeric.integer.long.decimal.cobra", |
| 45 | "match" : "\\b(?i:([1-9]+[0-9]*|0)L)" |
| 46 | }, |
| 47 | { |
| 48 | "name" : "constant.numeric.integer.decimal.cobra", |
| 49 | "match" : "\\b([1-9]+[0-9]*|0)" |
| 50 | }, |
| 51 | { |
| 52 | "name" : "keyword.control.cobra", |
| 53 | "match" : "\\b(branch|on|else|except|finally|for|if|try|while|break|continue|pass|raise|return|yield)\\b" |
| 54 | }, |
| 55 | { |
| 56 | "name" : "keyword.operator.logical.cobra", |
| 57 | "match" : "\\b(and|in|not|or)\\b" |
| 58 | }, |
| 59 | { |
| 60 | "name" : "keyword.other.cobra", |
| 61 | "match" : "\\b(as|assert|print|var|use|inherits|is|shared)\\b" |
| 62 | }, |
| 63 | { |
| 64 | "name" : "keyword.operator.comparison.cobra", |
| 65 | "match" : "<\\=|>\\=|\\=\\=|<|>|<>" |
| 66 | }, |
| 67 | { |
| 68 | "name" : "keyword.operator.assignment.cobra", |
| 69 | "match" : "\\=|\\+\\=|-\\=|\\*\\=|/\\=|//\\=|%\\=|&\\=|\\|\\=|\\^\\=|>>\\=|<<\\=|\\*\\*\\=" |
| 70 | }, |
| 71 | { |
| 72 | "name" : "keyword.operator.arithmetic.cobra", |
| 73 | "match" : "\\+|\\-|\\*|\\*\\*|/|//|%|<<|>>|&|\\||\\^|~" |
| 74 | }, |
| 75 | { |
| 76 | "begin" : "^\\s*\"\"\"\\s+", |
| 77 | "name" : "comment.block.cobra", |
| 78 | "comment" : "comment blocks including docstrings", |
| 79 | "end" : "^\\s*\"\"\"$" |
| 80 | }, |
| 81 | { |
| 82 | "begin" : "(?<=\\)|\\])\\s*(\\[)", |
| 83 | "patterns" : [ |
| 84 | { |
| 85 | "include" : "$self" |
| 86 | } |
| 87 | ], |
| 88 | "name" : "meta.item-access.cobra", |
| 89 | "contentName" : "meta.item-access.arguments.cobra", |
| 90 | "endCaptures" : { |
| 91 | "1" : { |
| 92 | "name" : "punctuation.definition.arguments.end.cobra" |
| 93 | } |
| 94 | }, |
| 95 | "end" : "(\\])", |
| 96 | "beginCaptures" : { |
| 97 | "1" : { |
| 98 | "name" : "punctuation.definition.arguments.begin.cobra" |
| 99 | } |
| 100 | } |
| 101 | }, |
| 102 | { |
| 103 | "name" : "storage.type.class.cobra", |
| 104 | "match" : "\\b(class)\\b" |
| 105 | }, |
| 106 | { |
| 107 | "name" : "storage.type.function.cobra", |
| 108 | "match" : "\\b(def|cue|get)\\b" |
| 109 | }, |
| 110 | { |
| 111 | "name" : "support.function.cobra", |
| 112 | "match" : "\\b(base)\\b", |
| 113 | "comment" : "language variables that are builtin" |
| 114 | }, |
| 115 | { |
| 116 | "begin" : "(\\()", |
| 117 | "patterns" : [ |
| 118 | { |
| 119 | "include" : "$self" |
| 120 | } |
| 121 | ], |
| 122 | "end" : "(\\))" |
| 123 | }, |
| 124 | { |
| 125 | "match" : "(\\[)(\\s*(\\]))\\b", |
| 126 | "captures" : { |
| 127 | "3" : { |
| 128 | "name" : "punctuation.definition.list.end.cobra" |
| 129 | }, |
| 130 | "1" : { |
| 131 | "name" : "punctuation.definition.list.begin.cobra" |
| 132 | }, |
| 133 | "2" : { |
| 134 | "name" : "meta.empty-list.cobra" |
| 135 | } |
| 136 | } |
| 137 | }, |
| 138 | { |
| 139 | "begin" : "(\\[)", |
| 140 | "patterns" : [ |
| 141 | { |
| 142 | "begin" : "(?<=\\[|\\,)\\s*(?![\\],])", |
| 143 | "patterns" : [ |
| 144 | { |
| 145 | "include" : "$self" |
| 146 | } |
| 147 | ], |
| 148 | "contentName" : "meta.structure.list.item.cobra", |
| 149 | "endCaptures" : { |
| 150 | "1" : { |
| 151 | "name" : "punctuation.separator.list.cobra" |
| 152 | } |
| 153 | }, |
| 154 | "end" : "\\s*(?:(,)|(?=\\]))" |
| 155 | } |
| 156 | ], |
| 157 | "name" : "meta.structure.list.cobra", |
| 158 | "endCaptures" : { |
| 159 | "1" : { |
| 160 | "name" : "punctuation.definition.list.end.cobra" |
| 161 | } |
| 162 | }, |
| 163 | "end" : "(\\])", |
| 164 | "beginCaptures" : { |
| 165 | "1" : { |
| 166 | "name" : "punctuation.definition.list.begin.cobra" |
| 167 | } |
| 168 | } |
| 169 | }, |
| 170 | { |
| 171 | "name" : "meta.structure.tuple.cobra", |
| 172 | "match" : "(\\()(\\s*(\\)))", |
| 173 | "captures" : { |
| 174 | "3" : { |
| 175 | "name" : "punctuation.definition.tuple.end.cobra" |
| 176 | }, |
| 177 | "1" : { |
| 178 | "name" : "punctuation.definition.tuple.begin.cobra" |
| 179 | }, |
| 180 | "2" : { |
| 181 | "name" : "meta.empty-tuple.cobra" |
| 182 | } |
| 183 | } |
| 184 | }, |
| 185 | { |
| 186 | "name" : "meta.structure.dictionary.cobra", |
| 187 | "match" : "(\\{)(\\s*(\\}))", |
| 188 | "captures" : { |
| 189 | "3" : { |
| 190 | "name" : "punctuation.definition.dictionary.end.cobra" |
| 191 | }, |
| 192 | "1" : { |
| 193 | "name" : "punctuation.definition.dictionary.begin.cobra" |
| 194 | }, |
| 195 | "2" : { |
| 196 | "name" : "meta.empty-dictionary.cobra" |
| 197 | } |
| 198 | } |
| 199 | }, |
| 200 | { |
| 201 | "begin" : "(\\{)", |
| 202 | "patterns" : [ |
| 203 | { |
| 204 | "begin" : "(?<=\\{|\\,|^)\\s*(?![\\},])", |
| 205 | "patterns" : [ |
| 206 | { |
| 207 | "include" : "$self" |
| 208 | } |
| 209 | ], |
| 210 | "contentName" : "meta.structure.dictionary.key.cobra", |
| 211 | "endCaptures" : { |
| 212 | "1" : { |
| 213 | "name" : "punctuation.separator.valuepair.dictionary.cobra" |
| 214 | } |
| 215 | }, |
| 216 | "end" : "\\s*(?:(?=\\})|(\\:))" |
| 217 | }, |
| 218 | { |
| 219 | "begin" : "(?<=\\:|^)\\s*", |
| 220 | "patterns" : [ |
| 221 | { |
| 222 | "include" : "$self" |
| 223 | } |
| 224 | ], |
| 225 | "contentName" : "meta.structure.dictionary.value.cobra", |
| 226 | "endCaptures" : { |
| 227 | "1" : { |
| 228 | "name" : "punctuation.separator.dictionary.cobra" |
| 229 | } |
| 230 | }, |
| 231 | "end" : "\\s*(?:(?=\\})|(,))" |
| 232 | } |
| 233 | ], |
| 234 | "name" : "meta.structure.dictionary.cobra", |
| 235 | "endCaptures" : { |
| 236 | "1" : { |
| 237 | "name" : "punctuation.definition.dictionary.end.cobra" |
| 238 | } |
| 239 | }, |
| 240 | "end" : "(\\})", |
| 241 | "beginCaptures" : { |
| 242 | "1" : { |
| 243 | "name" : "punctuation.definition.dictionary.begin.cobra" |
| 244 | } |
| 245 | } |
| 246 | }, |
| 247 | { |
| 248 | "begin" : "'", |
| 249 | "name" : "string.quoted.single.cobra", |
| 250 | "comment" : "single quoted strings", |
| 251 | "end" : "'" |
| 252 | }, |
| 253 | { |
| 254 | "name" : "support.type.cobra", |
| 255 | "match" : "\\b(bool|char|int|uint|float|decimal|number|dynamic|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\\b", |
| 256 | "comment" : "list of native primitive types" |
| 257 | }, |
| 258 | { |
| 259 | "name" : "support.class.cobra", |
| 260 | "match" : "\\b(String|List|Dictionary|Set|Stack|Queue|TextWriter|TextReader|StringBuilder)(?:\\?)?\\s*(<of\\s*[a-zA-Z0-9_]+>)\\b", |
| 261 | |
| 262 | } |
| 263 | ], |
| 264 | "name" : "Cobra", |
| 265 | "scopeName" : "source.cobra", |
| 266 | "fileTypes" : [ |
| 267 | "cobra" |
| 268 | ], |
| 269 | "foldingStopMarker" : "^\\s*$", |
| 270 | "foldingStartMarker" : "^\\s*(def|class|cue)(.*)", |
| 271 | "repository" : { |
| 272 | "constant_placeholder" : { |
| 273 | "name" : "constant.other.placeholder.cobra", |
| 274 | "match" : "(?i:%(\\([a-z_]+\\))?#?0?\\-?[ ]?\\+?([0-9]*|\\*)(\\.([0-9]*|\\*))?[hL]?[a-z%])" |
| 275 | }, |
| 276 | "keyword_arguments" : { |
| 277 | "begin" : "\\b([a-zA-Z_][a-zA-Z_0-9]*)\\s*(=)(?!=)", |
| 278 | "patterns" : [ |
| 279 | { |
| 280 | "include" : "$self" |
| 281 | } |
| 282 | ], |
| 283 | "endCaptures" : { |
| 284 | "1" : { |
| 285 | "name" : "punctuation.separator.parameters.cobra" |
| 286 | } |
| 287 | }, |
| 288 | "end" : "\\s*(?:(,)|(?=$\\n?|[\\)]))", |
| 289 | "beginCaptures" : { |
| 290 | "1" : { |
| 291 | "name" : "variable.parameter.function.cobra" |
| 292 | }, |
| 293 | "2" : { |
| 294 | "name" : "keyword.operator.assignment.cobra" |
| 295 | } |
| 296 | } |
| 297 | }, |
| 298 | "generic_names" : { |
| 299 | "match" : "[A-Za-z_][A-Za-z0-9_]*" |
| 300 | } |
| 301 | }, |
| 302 | "firstLineMatch" : "^#!/.*\\bcobra\\b" |
| 303 | } |
| 304 | }}} |