You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.1 KiB

4 years ago
  1. # AST nodes have this structure:
  2. # {"type": <node type>", children: [], "value": ""}
  3. def comparator(name, first, second):
  4. return {'type': 'comparator', 'children': [first, second], 'value': name}
  5. def current_node():
  6. return {'type': 'current', 'children': []}
  7. def expref(expression):
  8. return {'type': 'expref', 'children': [expression]}
  9. def function_expression(name, args):
  10. return {'type': 'function_expression', 'children': args, 'value': name}
  11. def field(name):
  12. return {"type": "field", "children": [], "value": name}
  13. def filter_projection(left, right, comparator):
  14. return {'type': 'filter_projection', 'children': [left, right, comparator]}
  15. def flatten(node):
  16. return {'type': 'flatten', 'children': [node]}
  17. def identity():
  18. return {"type": "identity", 'children': []}
  19. def index(index):
  20. return {"type": "index", "value": index, "children": []}
  21. def index_expression(children):
  22. return {"type": "index_expression", 'children': children}
  23. def key_val_pair(key_name, node):
  24. return {"type": "key_val_pair", 'children': [node], "value": key_name}
  25. def literal(literal_value):
  26. return {'type': 'literal', 'value': literal_value, 'children': []}
  27. def multi_select_dict(nodes):
  28. return {"type": "multi_select_dict", "children": nodes}
  29. def multi_select_list(nodes):
  30. return {"type": "multi_select_list", "children": nodes}
  31. def or_expression(left, right):
  32. return {"type": "or_expression", "children": [left, right]}
  33. def and_expression(left, right):
  34. return {"type": "and_expression", "children": [left, right]}
  35. def not_expression(expr):
  36. return {"type": "not_expression", "children": [expr]}
  37. def pipe(left, right):
  38. return {'type': 'pipe', 'children': [left, right]}
  39. def projection(left, right):
  40. return {'type': 'projection', 'children': [left, right]}
  41. def subexpression(children):
  42. return {"type": "subexpression", 'children': children}
  43. def slice(start, end, step):
  44. return {"type": "slice", "children": [start, end, step]}
  45. def value_projection(left, right):
  46. return {'type': 'value_projection', 'children': [left, right]}