Parse the expression. :param data: str for the input to be parsed :param signature: ``dict `` that maps variable names to type strings :returns: a parsed Expression
(self, data, signature=None)
| 137 | self.right_associated_operations = [APP] |
| 138 | |
| 139 | def parse(self, data, signature=None): |
| 140 | """ |
| 141 | Parse the expression. |
| 142 | |
| 143 | :param data: str for the input to be parsed |
| 144 | :param signature: ``dict<str, str>`` that maps variable names to type |
| 145 | strings |
| 146 | :returns: a parsed Expression |
| 147 | """ |
| 148 | data = data.rstrip() |
| 149 | |
| 150 | self._currentIndex = 0 |
| 151 | self._buffer, mapping = self.process(data) |
| 152 | |
| 153 | try: |
| 154 | result = self.process_next_expression(None) |
| 155 | if self.inRange(0): |
| 156 | raise UnexpectedTokenException(self._currentIndex + 1, self.token(0)) |
| 157 | except LogicalExpressionException as e: |
| 158 | msg = "{}\n{}\n{}^".format(e, data, " " * mapping[e.index - 1]) |
| 159 | raise LogicalExpressionException(None, msg) from e |
| 160 | |
| 161 | if self.type_check: |
| 162 | result.typecheck(signature) |
| 163 | |
| 164 | return result |
| 165 | |
| 166 | def process(self, data): |
| 167 | """Split the data into tokens""" |
no test coverage detected