MCPcopy Create free account
hub / github.com/SplootCode/splootcode / generateExpressionTokens

Function generateExpressionTokens

python/convert_ast.py:168–200  ·  view source on GitHub ↗
(expr, tokens=None)

Source from the content-addressed store, hash-verified

166 tokens.append(SplootNode('PY_IDENTIFIER', {}, {'identifier': name.id}))
167
168def generateExpressionTokens(expr, tokens=None):
169 if tokens is None:
170 tokens = []
171
172 if type(expr) == ast.Call:
173 appendCallToken(expr, tokens)
174 elif type(expr) == ast.Constant:
175 appendConstantToken(expr, tokens)
176 elif type(expr) == ast.Name:
177 appendIdentifier(expr, tokens)
178 elif type(expr) == ast.Attribute:
179 appendAttribute(expr, tokens)
180 elif type(expr) == ast.BinOp:
181 appendBinaryOperatorExpression(expr, tokens)
182 elif type(expr) == ast.BoolOp:
183 appendBooleanOperatorExpression(expr, tokens)
184 elif type(expr) == ast.UnaryOp:
185 appendUnaryOperatorExpression(expr, tokens)
186 elif type(expr) == ast.Compare:
187 appendCompareOperatorExpression(expr, tokens)
188 elif type(expr) == ast.List:
189 appendListToken(expr, tokens)
190 elif type(expr) == ast.Set:
191 appendSetToken(expr, tokens)
192 elif type(expr) == ast.Tuple:
193 appendTupleToken(expr, tokens)
194 elif type(expr) == ast.Dict:
195 appendDictToken(expr, tokens)
196 elif type(expr) == ast.Subscript:
197 appendSubscriptExpression(expr, tokens)
198 else:
199 raise Exception(f'Unrecognised expression type: {ast.dump(expr)}')
200 return tokens
201
202def generateExpression(expr, tokens=None):
203 tokens = generateExpressionTokens(expr, tokens)

Callers 5

appendCallTokenFunction · 0.85
appendAttributeFunction · 0.85
generateExpressionFunction · 0.85
splootNodesFromPythonFunction · 0.85

Calls 13

appendCallTokenFunction · 0.85
appendConstantTokenFunction · 0.85
appendIdentifierFunction · 0.85
appendAttributeFunction · 0.85
appendListTokenFunction · 0.85
appendSetTokenFunction · 0.85
appendTupleTokenFunction · 0.85
appendDictTokenFunction · 0.85

Tested by

no test coverage detected