Version 2 (modified by Charles, 14 years ago) |
---|
TextMate language grammar
Converted to TextMate syntax from ETextEditor.
See also: Forum post about TextMate
{ name = 'Cobra'; scopeName = 'source.cobra'; firstLineMatch = '^#!/.*\bcobra\b'; fileTypes = ( 'cobra' ); foldingStartMarker = ''; foldingStopMarker = ''; 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'; }, { name = 'comment.block.cobra'; begin = '^\s*(""")'; end = '"""\s*$'; }, { match = '^\s+(var)\s+(_[\w_]+)\s+(as)?(\s+[\w_<>\s?]+)'; captures = { 1 = { name = 'keyword.operator.declaration.cobra'; }; 2 = { name = 'support.private-variable.cobra'; }; 3 = { name = 'keyword.operator.specifier.cobra'; }; 4 = { name = 'support.other.type.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'; }; }; }, ); 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)'; }; strings = { patterns = ( { name = 'string.quoted.single.cobra'; begin = "(?<!')r?'(?!')"; end = "'"; patterns = ( { include = '#escaped-characters'; }, { include = '#varsub'; }, ); }, { name = 'string.quoted.single.cobra'; begin = '(?<!")r?"(?!")'; end = '"'; patterns = ( { include = '#escaped-characters'; }, { include = '#varsub'; }, ); }, ); }; varsub = { name = 'support.other.variable-substitution.cobra'; match = '(\[[\w.]+\])'; }; }; }