Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wrap
gtwrap
interface_parser
declaration.py
Go to the documentation of this file.
1
"""
2
GTSAM Copyright 2010-2020, Georgia Tech Research Corporation,
3
Atlanta, Georgia 30332-0415
4
All Rights Reserved
5
6
See LICENSE for the license information
7
8
Classes and rules for declarations such as includes and forward declarations.
9
10
Author: Duy Nguyen Ta, Fan Jiang, Matthew Sklar, Varun Agrawal, and Frank Dellaert
11
"""
12
13
from
pyparsing
import
CharsNotIn, Optional
14
15
from
.tokens
import
(CLASS, COLON, INCLUDE, LOPBRACK, ROPBRACK, SEMI_COLON,
16
VIRTUAL)
17
from
.type
import
Typename
18
19
20
class
Include
:
21
"""
22
Rule to parse #include directives.
23
"""
24
rule = (INCLUDE + LOPBRACK + CharsNotIn(
'>'
)(
"header"
) +
25
ROPBRACK).setParseAction(
lambda
t:
Include
(t.header))
26
27
def
__init__
(self, header: CharsNotIn, parent: str =
''
):
28
self.
header
= header
29
self.
parent
= parent
30
31
def
__repr__
(self) -> str:
32
return
"#include <{}>"
.format(self.
header
)
33
34
35
class
ForwardDeclaration
:
36
"""
37
Rule to parse forward declarations in the interface file.
38
"""
39
rule = (Optional(
VIRTUAL
(
"is_virtual"
)) + CLASS + Typename.rule(
"name"
) +
40
Optional(COLON + Typename.rule(
"parent_type"
)) +
41
SEMI_COLON).setParseAction(
lambda
t:
ForwardDeclaration
(
42
t.name, t.parent_type, t.is_virtual))
43
44
def
__init__
(self,
45
name: Typename,
46
parent_type: str,
47
is_virtual: str,
48
parent: str =
''
):
49
self.
name
= name
50
if
parent_type:
51
self.
parent_type
= parent_type
52
else
:
53
self.
parent_type
=
''
54
55
self.
is_virtual
= is_virtual
56
self.
parent
= parent
57
58
def
__repr__
(self) -> str:
59
return
"ForwardDeclaration: {} {}({})"
.format(self.
is_virtual
,
60
self.
name
, self.
parent
)
gtwrap.interface_parser.declaration.Include.parent
parent
Definition:
declaration.py:29
gtwrap.interface_parser.declaration.Include.__init__
def __init__
Definition:
declaration.py:27
gtwrap.interface_parser.declaration.ForwardDeclaration.__repr__
def __repr__(self)
Definition:
declaration.py:58
gtwrap.interface_parser.declaration.Include
Definition:
declaration.py:20
gtwrap.interface_parser.declaration.ForwardDeclaration.name
name
Definition:
declaration.py:49
gtwrap.interface_parser.declaration.Include.__repr__
def __repr__(self)
Definition:
declaration.py:31
gtwrap.interface_parser.declaration.ForwardDeclaration.__init__
def __init__
Definition:
declaration.py:45
gtwrap.interface_parser.declaration.ForwardDeclaration.parent
parent
Definition:
declaration.py:56
gtwrap.interface_parser.declaration.ForwardDeclaration
Definition:
declaration.py:35
gtwrap.interface_parser.declaration.Include.header
header
Definition:
declaration.py:28
gtwrap.interface_parser.declaration.ForwardDeclaration.is_virtual
is_virtual
Definition:
declaration.py:55
gtwrap.interface_parser.declaration.ForwardDeclaration.parent_type
parent_type
Definition:
declaration.py:51
gtwrap.interface_parser.tokens.VIRTUAL
VIRTUAL
Definition:
tokens.py:36
gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:57