Created
April 7, 2012 16:25
-
-
Save sessa/2330118 to your computer and use it in GitHub Desktop.
Dump scopes used by a TextMate grammar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import plistlib | |
class Grammar(object): | |
def __init__(self, grammar): | |
self._grammar = grammar | |
self.names = [] | |
self.includes = [] | |
patterns = self._grammar['patterns'] | |
self._parse_patterns(patterns) | |
def _parse_patterns(self, patterns): | |
for p in patterns: | |
if 'name' in p: | |
self.names.append( ('name', p['name']) ) | |
if 'contentName' in p: | |
self.names.append( ('contentName', p['contentName']) ) | |
for x in ['captures', 'beginCaptures', 'endCaptures']: | |
if x not in p: | |
continue | |
group = p[x] | |
for match in group: | |
g = group[match] | |
self.names.append( ('name', g['name']) ) | |
if 'patterns' in x: | |
self._parse_patterns(x['patterns']) | |
def main(): | |
plist = plistlib.readPlist("./Python.tmLanguage") | |
g = Grammar(plist) | |
scopes = set(n[1] for n in g.names) | |
print "\n".join(sorted(scopes)) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comment.line.number-sign.python | |
constant.language.python | |
constant.numeric.complex.python | |
constant.numeric.float.python | |
constant.numeric.integer.decimal.python | |
constant.numeric.integer.hexadecimal.python | |
constant.numeric.integer.long.decimal.python | |
constant.numeric.integer.long.hexadecimal.python | |
constant.numeric.integer.long.octal.python | |
constant.numeric.integer.octal.python | |
entity.name.function.decorator.python | |
entity.name.type.class.python | |
invalid.deprecated.operator.python | |
invalid.illegal.missing-inheritance.python | |
invalid.illegal.missing-parameters.python | |
invalid.illegal.missing-section-begin.python | |
keyword.control.flow.python | |
keyword.control.import.from.python | |
keyword.control.import.python | |
keyword.operator.arithmetic.python | |
keyword.operator.assignment.augmented.python | |
keyword.operator.assignment.python | |
keyword.operator.comparison.python | |
keyword.operator.logical.python | |
keyword.other.python | |
meta.class.old-style.python | |
meta.class.python | |
meta.empty-dictionary.python | |
meta.empty-list.python | |
meta.empty-tuple.python | |
meta.function-call.arguments.python | |
meta.function-call.python | |
meta.function.decorator.python | |
meta.function.inline.python | |
meta.function.python | |
meta.item-access.arguments.python | |
meta.item-access.python | |
meta.structure.dictionary.python | |
meta.structure.list.python | |
meta.structure.tuple.python | |
punctuation.definition.arguments.begin.python | |
punctuation.definition.arguments.end.python | |
punctuation.definition.comment.python | |
punctuation.definition.dictionary.begin.python | |
punctuation.definition.dictionary.end.python | |
punctuation.definition.inheritance.begin.python | |
punctuation.definition.inheritance.end.python | |
punctuation.definition.list.begin.python | |
punctuation.definition.list.end.python | |
punctuation.definition.parameters.begin.python | |
punctuation.definition.parameters.end.python | |
punctuation.definition.tuple.begin.python | |
punctuation.definition.tuple.end.python | |
punctuation.section.class.begin.python | |
punctuation.section.function.begin.python | |
storage.modifier.global.python | |
storage.type.class.python | |
storage.type.function.inline.python | |
storage.type.function.python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment