| 1 | == !TextMate language grammar == |
| 2 | |
| 3 | Converted to !TextMate syntax from [wiki:ETextEditor]. |
| 4 | |
| 5 | |
| 6 | {{{ |
| 7 | { name = 'Cobra'; |
| 8 | scopeName = 'source.cobra'; |
| 9 | firstLineMatch = '^#!/.*\bcobra\b'; |
| 10 | fileTypes = ( 'cobra' ); |
| 11 | foldingStartMarker = ''; |
| 12 | foldingStopMarker = ''; |
| 13 | patterns = ( |
| 14 | { name = 'comment.line.cobra'; |
| 15 | match = '(#).*$'; |
| 16 | }, |
| 17 | { name = 'constant.numeric.hexadecimal.cobra'; |
| 18 | match = '\b(?i:(0x\h*)L?)'; |
| 19 | }, |
| 20 | { name = 'constant.numeric.octal.cobra'; |
| 21 | match = '\b(?i:(0[0-7]+)L?)'; |
| 22 | }, |
| 23 | { name = 'constant.numeric.float.cobra'; |
| 24 | match = '\b(?i:(\d+\.\d*(e[\-\+]?\d+)?))(?=[^a-zA-Z_])'; |
| 25 | }, |
| 26 | { name = 'constant.numeric.float.cobra'; |
| 27 | match = '(?<=[^0-9a-zA-Z_])(?i:(\.\d+(e[\-\+]?\d+)?))'; |
| 28 | }, |
| 29 | { name = 'constant.numeric.float.cobra'; |
| 30 | match = '\b(?i:(\d+e[\-\+]?\d+))'; |
| 31 | }, |
| 32 | { name = 'constant.numeric.integer.long.decimal.cobra'; |
| 33 | match = '\b(?i:([1-9]+[0-9]*|0)L)'; |
| 34 | }, |
| 35 | { name = 'constant.numeric.integer.decimal.cobra'; |
| 36 | match = '\b([1-9]+[0-9]*|0)'; |
| 37 | }, |
| 38 | { name = 'keyword.control.cobra'; |
| 39 | match = '\b(branch|on|else|catch|finally|for|if|try|while|break|continue|pass|raise|return|using|yield)\b'; |
| 40 | }, |
| 41 | { name = 'keyword.operator.logical.cobra'; |
| 42 | match = '\b(and|in|not|or)\b'; |
| 43 | }, |
| 44 | { name = 'keyword.other.cobra'; |
| 45 | match = '\b(as|from|assert|print|var|invariant|is)\b'; |
| 46 | }, |
| 47 | { name = 'keyword.operator.comparison.cobra'; |
| 48 | match = '<\=|>\=|\=\=|<|>|<>'; |
| 49 | }, |
| 50 | { name = 'keyword.operator.assignment.cobra'; |
| 51 | match = '\=|\+\=|-\=|\*\=|/\=|//\=|%\=|&\=|\|\=|\^\=|>>\=|<<\=|\*\*\='; |
| 52 | }, |
| 53 | { name = 'keyword.operator.arithmetic.cobra'; |
| 54 | match = '\+|\-|\*|\*\*|/|//|%|<<|>>|&|\||\^|~'; |
| 55 | }, |
| 56 | { match = '\s*(use|namespace)\s+([a-zA-Z0-9_.]+)$'; |
| 57 | captures = { |
| 58 | 1 = { name = 'keyword.other.namespacing.cobra'; }; |
| 59 | 2 = { name = 'constant.class.cobra'; }; |
| 60 | }; |
| 61 | }, |
| 62 | { name = 'storage.type.function.cobra'; |
| 63 | match = '\b(def|cue|get|set|test|ensure|body|require)\b'; |
| 64 | }, |
| 65 | { name = 'support.type.primitive.cobra'; |
| 66 | match = '\b(nil|bool|char|int|uint|float|decimal|number|dynamic|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\b(\?)?'; |
| 67 | captures = { 2 = { name = 'support.type.nillible-marker.cobra'; }; }; |
| 68 | }, |
| 69 | { name = 'support.class.cobra'; |
| 70 | match = '\b(String|List|Dictionary|Set|Stack|Queue|TextWriter|TextReader|StringBuilder)(?:\?)?\s*(<of\s*[a-zA-Z0-9_]+>)\b'; |
| 71 | }, |
| 72 | { include = '#strings'; }, |
| 73 | { name = 'comment.block.cobra'; |
| 74 | begin = '^\s*(""")'; |
| 75 | end = '"""\s*$'; |
| 76 | }, |
| 77 | { match = '^\s+(var)\s+(_[\w_]+)\s+(as)?(\s+[\w_<>\s?]+)'; |
| 78 | captures = { |
| 79 | 1 = { name = 'keyword.operator.declaration.cobra'; }; |
| 80 | 2 = { name = 'support.private-variable.cobra'; }; |
| 81 | 3 = { name = 'keyword.operator.specifier.cobra'; }; |
| 82 | 4 = { name = 'support.other.type.cobra'; }; |
| 83 | }; |
| 84 | }, |
| 85 | { name = 'keyword.operator.enumeration.cobra'; |
| 86 | match = '\s*(?:enum|interface|struct|mixin)\s+([\w_]+)'; |
| 87 | captures = { 1 = { name = 'entity.name.enumeration.cobras'; }; }; |
| 88 | }, |
| 89 | { name = 'keyword.operator.enumeration.cobra'; |
| 90 | match = '\s*(is|has)\s+(shared|partial)\s*'; |
| 91 | captures = { |
| 92 | 1 = { name = 'operator.name.is.cobra'; }; |
| 93 | 2 = { name = 'constant.other.modifier.cobra'; }; |
| 94 | }; |
| 95 | }, |
| 96 | { name = 'keyword.operator.enumeration.cobra'; |
| 97 | match = '\s*(implements|inherits)\s+([a-zA-Z_][\w_]*)\s*'; |
| 98 | captures = { |
| 99 | 1 = { name = 'operator.name.is.cobra'; }; |
| 100 | 2 = { name = 'constant.other.interface.cobra'; }; |
| 101 | }; |
| 102 | }, |
| 103 | { name = 'meta.type.method.cobra'; |
| 104 | match = '^\s+(def|cue|get|pro|sig)\s+([a-zA-Z_]\w+)'; |
| 105 | captures = { |
| 106 | 1 = { name = 'keyword.operator.method.cobra'; }; |
| 107 | 2 = { name = 'entity.name.type.cobra'; }; |
| 108 | }; |
| 109 | }, |
| 110 | { match = '^\s*(class)\s+([a-zA-Z_][\w_]*)\s*'; |
| 111 | captures = { |
| 112 | 1 = { name = 'keyword.operator.class-definition.cobra'; }; |
| 113 | 2 = { name = 'entity.name.user-defined-type.cobra'; }; |
| 114 | }; |
| 115 | }, |
| 116 | ); |
| 117 | repository = { |
| 118 | escaped-characters = { |
| 119 | name = 'constant.character.escape.cobra'; |
| 120 | match = '(\\x[0-9A-F]{2})|(\\[0-7]{3})|(\\\n)|(\\\\)|(\\\")|(\\'')|(\\a)|(\\b)|(\\f)|(\\n)|(\\r)|(\\t)|(\\v)'; |
| 121 | }; |
| 122 | strings = { |
| 123 | patterns = ( |
| 124 | { name = 'string.quoted.single.cobra'; |
| 125 | begin = "(?<!')r?'(?!')"; |
| 126 | end = "'"; |
| 127 | patterns = ( |
| 128 | { include = '#escaped-characters'; }, |
| 129 | { include = '#varsub'; }, |
| 130 | ); |
| 131 | }, |
| 132 | { name = 'string.quoted.single.cobra'; |
| 133 | begin = '(?<!")r?"(?!")'; |
| 134 | end = '"'; |
| 135 | patterns = ( |
| 136 | { include = '#escaped-characters'; }, |
| 137 | { include = '#varsub'; }, |
| 138 | ); |
| 139 | }, |
| 140 | ); |
| 141 | }; |
| 142 | varsub = { |
| 143 | name = 'support.other.variable-substitution.cobra'; |
| 144 | match = '(\[[\w.]+\])'; |
| 145 | }; |
| 146 | }; |
| 147 | } |
| 148 | }}} |