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 
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)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:57