tokens.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 All the token definitions.
9 
10 Author: Duy Nguyen Ta, Fan Jiang, Matthew Sklar, Varun Agrawal, and Frank Dellaert
11 """
12 
13 from pyparsing import (Keyword, Literal, Or, QuotedString, Suppress, Word,
14  alphanums, alphas, delimitedList, nums,
15  pyparsing_common)
16 
17 # rule for identifiers (e.g. variable names)
18 IDENT = Word(alphas + '_', alphanums + '_') ^ Word(nums)
19 
20 RAW_POINTER, SHARED_POINTER, REF = map(Literal, "@*&")
21 
22 LPAREN, RPAREN, LBRACE, RBRACE, COLON, SEMI_COLON = map(Suppress, "(){}:;")
23 LOPBRACK, ROPBRACK, COMMA, EQUAL = map(Suppress, "<>,=")
24 
25 # Encapsulating type for numbers, and single and double quoted strings.
26 # The pyparsing_common utilities ensure correct coversion to the corresponding type.
27 # E.g. pyparsing_common.number will convert 3.1415 to a float type.
28 NUMBER_OR_STRING = (pyparsing_common.number ^ QuotedString('"') ^ QuotedString("'"))
29 
30 # A python tuple, e.g. (1, 9, "random", 3.1415)
31 TUPLE = (LPAREN + delimitedList(NUMBER_OR_STRING) + RPAREN)
32 
33 # Default argument passed to functions/methods.
34 DEFAULT_ARG = (NUMBER_OR_STRING ^ pyparsing_common.identifier ^ TUPLE)
35 
36 CONST, VIRTUAL, CLASS, STATIC, PAIR, TEMPLATE, TYPEDEF, INCLUDE = map(
37  Keyword,
38  [
39  "const",
40  "virtual",
41  "class",
42  "static",
43  "pair",
44  "template",
45  "typedef",
46  "#include",
47  ],
48 )
49 ENUM = Keyword("enum") ^ Keyword("enum class") ^ Keyword("enum struct")
50 NAMESPACE = Keyword("namespace")
51 BASIS_TYPES = map(
52  Keyword,
53  [
54  "void",
55  "bool",
56  "unsigned char",
57  "char",
58  "int",
59  "size_t",
60  "double",
61  "float",
62  ],
63 )
64 
65 OPERATOR = Or(
66  map(
67  Literal,
68  [
69  '+', # __add__, __pos__
70  '-', # __sub__, __neg__
71  '*', # __mul__
72  '/', # __truediv__
73  '%', # __mod__
74  '^', # __xor__
75  '&', # __and__
76  '|', # __or__
77  # '~', # __invert__
78  '+=', # __iadd__
79  '-=', # __isub__
80  '*=', # __imul__
81  '/=', # __itruediv__
82  '%=', # __imod__
83  '^=', # __ixor__
84  '&=', # __iand__
85  '|=', # __ior__
86  '<<', # __lshift__
87  '<<=', # __ilshift__
88  '>>', # __rshift__
89  '>>=', # __irshift__
90  '==', # __eq__
91  '!=', # __ne__
92  '<', # __lt__
93  '>', # __gt__
94  '<=', # __le__
95  '>=', # __ge__
96  # '!', # Use `not` in python
97  # '&&', # Use `and` in python
98  # '||', # Use `or` in python
99  '()', # __call__
100  '[]', # __getitem__
101  ],
102  ))


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:04