module.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 Rules and classes for parsing a module.
9 
10 Author: Duy Nguyen Ta, Fan Jiang, Matthew Sklar, Varun Agrawal, and Frank Dellaert
11 """
12 
13 # pylint: disable=unnecessary-lambda, unused-import, expression-not-assigned, no-else-return, protected-access, too-few-public-methods, too-many-arguments
14 
15 from pyparsing import ParseResults, ZeroOrMore, cppStyleComment, stringEnd
16 
17 from .classes import Class
18 from .declaration import ForwardDeclaration, Include
19 from .enum import Enum
20 from .function import GlobalFunction
21 from .namespace import Namespace
22 from .template import TypedefTemplateInstantiation
23 from .variable import Variable
24 
25 
26 class Module:
27  """
28  Module is just a global namespace.
29 
30  E.g.
31  ```
32  namespace gtsam {
33  ...
34  }
35  ```
36  """
37 
38  rule = (
39  ZeroOrMore(ForwardDeclaration.rule #
40  ^ Include.rule #
41  ^ Class.rule #
42  ^ TypedefTemplateInstantiation.rule #
43  ^ GlobalFunction.rule #
44  ^ Enum.rule #
45  ^ Variable.rule #
46  ^ Namespace.rule #
47  ).setParseAction(lambda t: Namespace('', t.asList())) +
48  stringEnd)
49 
50  rule.ignore(cppStyleComment)
51 
52  @staticmethod
53  def parseString(s: str) -> ParseResults:
54  """Parse the source string and apply the rules."""
55  return Module.rule.parseString(s)[0]


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:43:01