| 657 | static bool any_field_contains_node(TSNode parent, const char *field, TSNode node); |
| 658 | |
| 659 | static bool is_tlaplus_binding(TSNode node) { |
| 660 | for (TSNode parent = ts_node_parent(node); !ts_node_is_null(parent); |
| 661 | parent = ts_node_parent(parent)) { |
| 662 | const char *kind = ts_node_type(parent); |
| 663 | if (strcmp(kind, "operator_definition") == 0) { |
| 664 | /* `name:` is the callable declaration, while every repeated |
| 665 | * `parameter:` field is a function-wide lexical binder. */ |
| 666 | return any_field_contains_node(parent, "parameter", node); |
| 667 | } |
| 668 | if (strcmp(kind, "function_definition") == 0) { |
| 669 | /* `F[x \in S] == ...`: only quantifier_bound.intro binds. The set |
| 670 | * expression S remains an ordinary identifier_ref usage. */ |
| 671 | for (TSNode bound = ts_node_parent(node); |
| 672 | !ts_node_is_null(bound) && !ts_node_eq(bound, parent); |
| 673 | bound = ts_node_parent(bound)) { |
| 674 | if (strcmp(ts_node_type(bound), "quantifier_bound") == 0) { |
| 675 | return any_field_contains_node(bound, "intro", node); |
| 676 | } |
| 677 | } |
| 678 | return false; |
| 679 | } |
| 680 | if (strcmp(kind, "bounded_quantification") == 0) { |
| 681 | for (TSNode bound = ts_node_parent(node); |
| 682 | !ts_node_is_null(bound) && !ts_node_eq(bound, parent); |
| 683 | bound = ts_node_parent(bound)) { |
| 684 | if (strcmp(ts_node_type(bound), "quantifier_bound") == 0) { |
| 685 | return any_field_contains_node(bound, "intro", node); |
| 686 | } |
| 687 | } |
| 688 | return false; |
| 689 | } |
| 690 | if (strcmp(kind, "unbounded_quantification") == 0) { |
| 691 | return any_field_contains_node(parent, "intro", node); |
| 692 | } |
| 693 | } |
| 694 | return false; |
| 695 | } |
| 696 | |
| 697 | static bool is_cobol_move_destination(TSNode node) { |
| 698 | for (TSNode parent = ts_node_parent(node); !ts_node_is_null(parent); |
no test coverage detected