Skip to content

Instantly share code, notes, and snippets.

@sessa
Created April 7, 2012 16:25
Show Gist options
  • Select an option

  • Save sessa/2330118 to your computer and use it in GitHub Desktop.

Select an option

Save sessa/2330118 to your computer and use it in GitHub Desktop.

Revisions

  1. @adamv adamv revised this gist May 12, 2010. 2 changed files with 2 additions and 29 deletions.
    4 changes: 2 additions & 2 deletions dump_scopes.py
    Original file line number Diff line number Diff line change
    @@ -36,8 +36,8 @@ def _parse_patterns(self, patterns):
    def main():
    plist = plistlib.readPlist("./Python.tmLanguage")
    g = Grammar(plist)
    print "\n".join(sorted((n[1] for n in g.names)))
    scopes = set(n[1] for n in g.names)
    print "\n".join(sorted(scopes))


    if __name__ == '__main__':
    27 changes: 0 additions & 27 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,6 @@ comment.line.number-sign.python
    constant.language.python
    constant.numeric.complex.python
    constant.numeric.float.python
    constant.numeric.float.python
    constant.numeric.float.python
    constant.numeric.integer.decimal.python
    constant.numeric.integer.hexadecimal.python
    constant.numeric.integer.long.decimal.python
    @@ -16,8 +14,6 @@ invalid.deprecated.operator.python
    invalid.illegal.missing-inheritance.python
    invalid.illegal.missing-parameters.python
    invalid.illegal.missing-section-begin.python
    invalid.illegal.missing-section-begin.python
    invalid.illegal.missing-section-begin.python
    keyword.control.flow.python
    keyword.control.import.from.python
    keyword.control.import.python
    @@ -29,58 +25,35 @@ keyword.operator.logical.python
    keyword.other.python
    meta.class.old-style.python
    meta.class.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-call.python
    meta.function.decorator.python
    meta.function.decorator.python
    meta.function.inline.python
    meta.function.python
    meta.function.python
    meta.item-access.arguments.python
    meta.item-access.python
    meta.item-access.python
    meta.structure.dictionary.python
    meta.structure.dictionary.python
    meta.structure.list.python
    meta.structure.tuple.python
    punctuation.definition.arguments.begin.python
    punctuation.definition.arguments.begin.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.comment.python
    punctuation.definition.dictionary.begin.python
    punctuation.definition.dictionary.begin.python
    punctuation.definition.dictionary.end.python
    punctuation.definition.dictionary.end.python
    punctuation.definition.inheritance.begin.python
    punctuation.definition.inheritance.end.python
    punctuation.definition.list.begin.python
    punctuation.definition.list.begin.python
    punctuation.definition.list.end.python
    punctuation.definition.list.end.python
    punctuation.definition.parameters.begin.python
    punctuation.definition.parameters.end.python
    punctuation.definition.parameters.end.python
    punctuation.definition.tuple.begin.python
    punctuation.definition.tuple.end.python
    punctuation.section.class.begin.python
    punctuation.section.class.begin.python
    punctuation.section.function.begin.python
    punctuation.section.function.begin.python
    storage.modifier.global.python
    storage.type.class.python
    storage.type.class.python
    storage.type.class.python
    storage.type.class.python
    storage.type.function.inline.python
    storage.type.function.python
    storage.type.function.python
    storage.type.function.python
  2. @adamv adamv revised this gist May 12, 2010. 1 changed file with 86 additions and 0 deletions.
    86 changes: 86 additions & 0 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@
    comment.line.number-sign.python
    constant.language.python
    constant.numeric.complex.python
    constant.numeric.float.python
    constant.numeric.float.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
    invalid.illegal.missing-section-begin.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.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-call.python
    meta.function.decorator.python
    meta.function.decorator.python
    meta.function.inline.python
    meta.function.python
    meta.function.python
    meta.item-access.arguments.python
    meta.item-access.python
    meta.item-access.python
    meta.structure.dictionary.python
    meta.structure.dictionary.python
    meta.structure.list.python
    meta.structure.tuple.python
    punctuation.definition.arguments.begin.python
    punctuation.definition.arguments.begin.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.arguments.end.python
    punctuation.definition.comment.python
    punctuation.definition.dictionary.begin.python
    punctuation.definition.dictionary.begin.python
    punctuation.definition.dictionary.end.python
    punctuation.definition.dictionary.end.python
    punctuation.definition.inheritance.begin.python
    punctuation.definition.inheritance.end.python
    punctuation.definition.list.begin.python
    punctuation.definition.list.begin.python
    punctuation.definition.list.end.python
    punctuation.definition.list.end.python
    punctuation.definition.parameters.begin.python
    punctuation.definition.parameters.end.python
    punctuation.definition.parameters.end.python
    punctuation.definition.tuple.begin.python
    punctuation.definition.tuple.end.python
    punctuation.section.class.begin.python
    punctuation.section.class.begin.python
    punctuation.section.function.begin.python
    punctuation.section.function.begin.python
    storage.modifier.global.python
    storage.type.class.python
    storage.type.class.python
    storage.type.class.python
    storage.type.class.python
    storage.type.function.inline.python
    storage.type.function.python
    storage.type.function.python
    storage.type.function.python
  3. @adamv adamv created this gist May 12, 2010.
    44 changes: 44 additions & 0 deletions dump_scopes.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/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)

    print "\n".join(sorted((n[1] for n in g.names)))


    if __name__ == '__main__':
    main()