| 1 | from __future__ import with_statement
|
|---|
| 2 |
|
|---|
| 3 | import keyword
|
|---|
| 4 | import exceptions
|
|---|
| 5 | import __builtin__
|
|---|
| 6 | from string import Template
|
|---|
| 7 |
|
|---|
| 8 | comment_header = """" Auto-generated Vim syntax file for Python
|
|---|
| 9 | "
|
|---|
| 10 | " To use: copy or symlink to ~/.vim/syntax/python.vim"""
|
|---|
| 11 |
|
|---|
| 12 | statement_header = """
|
|---|
| 13 | if exists("b:current_syntax")
|
|---|
| 14 | finish
|
|---|
| 15 | endif"""
|
|---|
| 16 |
|
|---|
| 17 | statement_footer = '''
|
|---|
| 18 | " Uncomment the 'minlines' statement line and comment out the 'maxlines'
|
|---|
| 19 | " statement line; changes behaviour to look at least 2000 lines previously for
|
|---|
| 20 | " syntax matches instead of at most 200 lines
|
|---|
| 21 | syn sync match pythonSync grouphere NONE "):$"
|
|---|
| 22 | syn sync maxlines=200
|
|---|
| 23 | "syn sync minlines=2000
|
|---|
| 24 |
|
|---|
| 25 | let b:current_syntax = "python"'''
|
|---|
| 26 |
|
|---|
| 27 | looping = ('for', 'while')
|
|---|
| 28 | conditionals = ('if', 'elif', 'else')
|
|---|
| 29 | boolean_ops = ('and', 'in', 'is', 'not', 'or')
|
|---|
| 30 | import_stmts = ('import', 'from')
|
|---|
| 31 | object_defs = ('def', 'class')
|
|---|
| 32 |
|
|---|
| 33 | exception_names = frozenset(exc for exc in dir(exceptions)
|
|---|
| 34 | if not exc.startswith('__'))
|
|---|
| 35 |
|
|---|
| 36 | # Need to include functions that start with '__' (e.g., __import__), but
|
|---|
| 37 | # nothing that comes with modules (e.g., __name__), so just exclude anything in
|
|---|
| 38 | # the 'exceptions' module since we want to ignore exceptions *and* what any
|
|---|
| 39 | # module would have
|
|---|
| 40 | builtin_names = frozenset(builtin for builtin in dir(__builtin__)
|
|---|
| 41 | if builtin not in dir(exceptions))
|
|---|
| 42 |
|
|---|
| 43 | escapes = (r'+\\[abfnrtv\'"\\]+', r'"\\\o\{1,3}"', r'"\\x\x\{2}"',
|
|---|
| 44 | r'"\(\\u\x\{4}\|\\U\x\{8}\)"', r'"\\$"')
|
|---|
| 45 |
|
|---|
| 46 | todos = ("TODO", "FIXME", "XXX")
|
|---|
| 47 |
|
|---|
|
|---|