tesseract
v5.3.3.20231005
keywords.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
#
3
# Copyright 2007 Neal Norwitz
4
# Portions Copyright 2007 Google Inc.
5
#
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
# you may not use this file except in compliance with the License.
8
# You may obtain a copy of the License at
9
#
10
# http://www.apache.org/licenses/LICENSE-2.0
11
#
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
17
18
"""C++ keywords and helper utilities for determining keywords."""
19
20
try
:
21
# Python 3.x
22
import
builtins
23
except
ImportError:
24
# Python 2.x
25
import
__builtin__
as
builtins
26
27
28
if
not
hasattr(builtins,
'set'
):
29
# Nominal support for Python 2.3.
30
from
sets
import
Set
as
set
31
32
33
TYPES =
set
(
'bool char int long short double float void wchar_t unsigned signed'
.
split
())
34
TYPE_MODIFIERS =
set
(
'auto register const inline extern static virtual volatile mutable'
.
split
())
35
ACCESS =
set
(
'public protected private friend'
.
split
())
36
37
CASTS =
set
(
'static_cast const_cast dynamic_cast reinterpret_cast'
.
split
())
38
39
OTHERS =
set
(
'true false asm class namespace using explicit this operator sizeof'
.
split
())
40
OTHER_TYPES =
set
(
'new delete typedef struct union enum typeid typename template'
.
split
())
41
42
CONTROL =
set
(
'case switch default if else return goto'
.
split
())
43
EXCEPTION =
set
(
'try catch throw'
.
split
())
44
LOOP =
set
(
'while do for break continue'
.
split
())
45
46
ALL = TYPES | TYPE_MODIFIERS | ACCESS | CASTS | OTHERS | OTHER_TYPES | CONTROL | EXCEPTION | LOOP
47
48
49
def
IsKeyword
(token):
50
return
token
in
ALL
51
52
def
IsBuiltinType
(token):
53
if
token
in
(
'virtual'
,
'inline'
):
54
# These only apply to methods, they can't be types by themselves.
55
return
False
56
return
token
in
TYPES
or
token
in
TYPE_MODIFIERS
tesseract::split
const std::vector< std::string > split(const std::string &s, char c)
Definition:
helpers.h:43
cpp.gmock_class.set
set
Definition:
gmock_class.py:42
cpp.keywords.IsKeyword
def IsKeyword(token)
Definition:
keywords.py:49
cpp.keywords.IsBuiltinType
def IsBuiltinType(token)
Definition:
keywords.py:52
unittest
third_party
googletest
googlemock
scripts
generator
cpp
keywords.py
Generated on Thu Oct 5 2023 22:10:28 for tesseract by
1.9.4