(tokens, currentIndex)
| 132 | |
| 133 | |
| 134 | def parseLeaf(tokens, currentIndex): |
| 135 | if currentIndex >= len(tokens): |
| 136 | print("Index out of bounds, attempting to parse leaf") |
| 137 | return currentIndex |
| 138 | |
| 139 | lookahead = tokens[currentIndex] |
| 140 | if lookahead["type"] == "PYTHON_BINARY_OPERATOR": |
| 141 | op = lookahead["properties"]["operator"] |
| 142 | if op in UNARY_OPERATORS: |
| 143 | # treat RHS as it's own expression, depending on precedence. |
| 144 | lhs, index = parseLeaf(tokens, currentIndex + 1) |
| 145 | top_expr, index = parseExpression( |
| 146 | lhs, tokens, index, getUnaryPrecedence(op) |
| 147 | ) |
| 148 | # Create Unary expression |
| 149 | return [ast.UnaryOp(getAstUnaryOperator(op), top_expr), index] |
| 150 | return [generateAstExpressionToken(tokens[currentIndex]), currentIndex + 1] |
| 151 | |
| 152 | |
| 153 | UNARY_OPERATORS = { |
no test coverage detected