Enable Function syntax for keyword seeding

This commit is contained in:
David\ Beitey 2014-05-21 13:30:26 +10:00
parent 8e02cedd8c
commit 3bef7977a9
2 changed files with 43 additions and 19 deletions

View File

@ -149,6 +149,7 @@ def _CreateInitialGroupMap():
AddToGroupMap( 'Operator' , statement_group )
AddToGroupMap( 'Keyword' , statement_group )
AddToGroupMap( 'Exception' , statement_group )
AddToGroupMap( 'Function' , statement_group )
AddToGroupMap( 'StorageClass', type_group )
AddToGroupMap( 'Structure' , type_group )

View File

@ -32,25 +32,38 @@ def ContentsOfTestFile( test_file ):
def KeywordsFromSyntaxListOutput_PythonSyntax_test():
eq_( set(['and', 'IndexError', 'elif', 'BytesWarning', 'ZeroDivisionError',
'ImportError', 'is', 'global', 'UnicodeTranslateError',
'GeneratorExit', 'BufferError', 'StopIteration', 'as',
'SystemError', 'UnicodeError', 'EnvironmentError', 'in', 'EOFError',
'LookupError', 'Exception', 'PendingDeprecationWarning', 'if',
'OSError', 'DeprecationWarning', 'raise', 'for',
'FloatingPointError', 'UnicodeWarning', 'VMSError', 'except',
'nonlocal', 'ReferenceError', 'NameError', 'pass', 'finally',
'Warning', 'UnboundLocalError', 'print', 'IOError',
'IndentationError', 'True', 'RuntimeError', 'FutureWarning',
'ImportWarning', 'SystemExit', 'None', 'return', 'StandardError',
'exec', 'ValueError', 'TabError', 'else', 'break', 'SyntaxError',
'UnicodeEncodeError', 'WindowsError', 'not', 'UnicodeDecodeError',
'with', 'class', 'KeyError', 'AssertionError', 'assert',
'TypeError', 'False', 'RuntimeWarning', 'KeyboardInterrupt',
'UserWarning', 'SyntaxWarning', 'yield', 'OverflowError', 'try',
'ArithmeticError', 'while', 'continue', 'del', 'MemoryError',
'NotImplementedError', 'BaseException', 'AttributeError', 'or',
'def', 'lambda', 'from', 'import']),
eq_( set(['bytearray', 'IndexError', 'all', 'help', 'vars',
'SyntaxError', 'global', 'elif', 'unicode', 'sorted', 'memoryview',
'isinstance', 'except', 'nonlocal', 'NameError', 'finally',
'BytesWarning', 'dict', 'IOError', 'pass', 'oct', 'match', 'bin',
'SystemExit', 'return', 'StandardError', 'format', 'TabError',
'break', 'next', 'not', 'UnicodeDecodeError', 'False',
'RuntimeWarning', 'list', 'iter', 'try', 'reload', 'Warning',
'round', 'dir', 'cmp', 'set', 'bytes', 'UnicodeTranslateError',
'intern', 'issubclass', 'yield', 'Ellipsis', 'hash', 'locals',
'BufferError', 'slice', 'for', 'FloatingPointError', 'sum',
'VMSError', 'getattr', 'abs', 'print', 'import', 'True',
'FutureWarning', 'ImportWarning', 'None', 'EOFError', 'len',
'frozenset', 'ord', 'super', 'raise', 'TypeError',
'KeyboardInterrupt', 'UserWarning', 'filter', 'range',
'staticmethod', 'SystemError', 'or', 'BaseException', 'pow',
'RuntimeError', 'float', 'MemoryError', 'StopIteration', 'globals',
'divmod', 'enumerate', 'apply', 'LookupError', 'open', 'basestring',
'from', 'UnicodeError', 'zip', 'hex', 'long', 'IndentationError',
'int', 'chr', '__import__', 'type', 'Exception', 'continue',
'tuple', 'reduce', 'reversed', 'else', 'assert',
'UnicodeEncodeError', 'input', 'with', 'hasattr', 'delattr',
'setattr', 'raw_input', 'PendingDeprecationWarning', 'compile',
'ArithmeticError', 'while', 'del', 'str', 'property', 'def', 'and',
'GeneratorExit', 'ImportError', 'xrange', 'is', 'EnvironmentError',
'KeyError', 'coerce', 'SyntaxWarning', 'file', 'in', 'unichr',
'ascii', 'any', 'as', 'if', 'OSError', 'DeprecationWarning', 'min',
'UnicodeWarning', 'execfile', 'id', 'complex', 'bool', 'ValueError',
'NotImplemented', 'map', 'exec', 'buffer', 'max', 'class', 'object',
'repr', 'callable', 'ZeroDivisionError', 'eval', '__debug__',
'ReferenceError', 'AssertionError', 'classmethod',
'UnboundLocalError', 'NotImplementedError', 'lambda',
'AttributeError', 'OverflowError', 'WindowsError'] ),
syntax_parse._KeywordsFromSyntaxListOutput(
ContentsOfTestFile( 'python_syntax' ) ) )
@ -108,6 +121,16 @@ foogroup xxx foo bar
)
def KeywordsFromSyntaxListOutput_Function_test():
eq_( set([ 'foo', 'bar', 'zoo', 'goo' ]),
syntax_parse._KeywordsFromSyntaxListOutput( """
foogroup xxx foo bar
zoo goo
links to Function"""
)
)
def KeywordsFromSyntaxListOutput_JunkIgnored_test():
eq_( set([ 'foo', 'bar', 'zoo', 'goo' ]),
syntax_parse._KeywordsFromSyntaxListOutput( """