Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ast.py91 linesDownload Raw Back to jmespath
1# AST nodes have this structure:2# {"type": <node type>", children: [], "value": ""}3 4 5def comparator(name, first, second):6    return {'type': 'comparator', 'children': [first, second], 'value': name}7 8 9def current_node():10    return {'type': 'current', 'children': []}11 12 13def expref(expression):14    return {'type': 'expref', 'children': [expression]}15 16 17def function_expression(name, args):18    return {'type': 'function_expression', 'children': args, 'value': name}19 20 21def field(name):22    return {"type": "field", "children": [], "value": name}23 24 25def filter_projection(left, right, comparator):26    return {'type': 'filter_projection', 'children': [left, right, comparator]}27 28 29def flatten(node):30    return {'type': 'flatten', 'children': [node]}31 32 33def identity():34    return {"type": "identity", 'children': []}35 36 37def index(index):38    return {"type": "index", "value": index, "children": []}39 40 41def index_expression(children):42    return {"type": "index_expression", 'children': children}43 44 45def key_val_pair(key_name, node):46    return {"type": "key_val_pair", 'children': [node], "value": key_name}47 48 49def literal(literal_value):50    return {'type': 'literal', 'value': literal_value, 'children': []}51 52 53def multi_select_dict(nodes):54    return {"type": "multi_select_dict", "children": nodes}55 56 57def multi_select_list(nodes):58    return {"type": "multi_select_list", "children": nodes}59 60 61def or_expression(left, right):62    return {"type": "or_expression", "children": [left, right]}63 64 65def and_expression(left, right):66    return {"type": "and_expression", "children": [left, right]}67 68 69def not_expression(expr):70    return {"type": "not_expression", "children": [expr]}71 72 73def pipe(left, right):74    return {'type': 'pipe', 'children': [left, right]}75 76 77def projection(left, right):78    return {'type': 'projection', 'children': [left, right]}79 80 81def subexpression(children):82    return {"type": "subexpression", 'children': children}83 84 85def slice(start, end, step):86    return {"type": "slice", "children": [start, end, step]}87 88 89def value_projection(left, right):90    return {'type': 'value_projection', 'children': [left, right]}91 
codekingpro/portable-devtools · Team Ai