File indexing completed on 2025-08-09 08:19:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 """C++ keywords and helper utilities for determining keywords."""
0019
0020 __author__ = 'nnorwitz@google.com (Neal Norwitz)'
0021
0022
0023 try:
0024
0025 import builtins
0026 except ImportError:
0027
0028 import __builtin__ as builtins
0029
0030
0031 if not hasattr(builtins, 'set'):
0032
0033 from sets import Set as set
0034
0035
0036 TYPES = set('bool char int long short double float void wchar_t unsigned signed'.split())
0037 TYPE_MODIFIERS = set('auto register const inline extern static virtual volatile mutable'.split())
0038 ACCESS = set('public protected private friend'.split())
0039
0040 CASTS = set('static_cast const_cast dynamic_cast reinterpret_cast'.split())
0041
0042 OTHERS = set('true false asm class namespace using explicit this operator sizeof'.split())
0043 OTHER_TYPES = set('new delete typedef struct union enum typeid typename template'.split())
0044
0045 CONTROL = set('case switch default if else return goto'.split())
0046 EXCEPTION = set('try catch throw'.split())
0047 LOOP = set('while do for break continue'.split())
0048
0049 ALL = TYPES | TYPE_MODIFIERS | ACCESS | CASTS | OTHERS | OTHER_TYPES | CONTROL | EXCEPTION | LOOP
0050
0051
0052 def IsKeyword(token):
0053 return token in ALL
0054
0055 def IsBuiltinType(token):
0056 if token in ('virtual', 'inline'):
0057
0058 return False
0059 return token in TYPES or token in TYPE_MODIFIERS