Skip to content

Commit 562dc55

Browse files
committed
Clean up obsolete code
1 parent 0b35f6d commit 562dc55

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

rascal-textmate-core/src/main/rascal/lang/rascal/grammar/Util.rsc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ bool tryParse(Grammar g, Symbol s, str input, bool allowAmbiguity = false) {
3737
Checks if symbol `s` is recursive in grammar `g`
3838
}
3939

40-
// TODO: Compute a map and memoize the results
4140
bool isRecursive(Grammar g, Symbol s, set[Symbol] checking = {})
4241
= s in checking
4342
? true

rascal-textmate-core/src/main/rascal/lang/rascal/grammar/analyze/Dependencies.rsc

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Grammar;
1616
import ParseTree;
1717
import Relation;
1818
import Set;
19-
import util::Maybe;
2019

2120
import lang::rascal::grammar::Util;
2221

@@ -50,7 +49,7 @@ Dependencies deps(Graph[Production] g) {
5049
= deps(removeNodes(g, getNodes(g, p, getAncestors = removeAncestors)));
5150
list[Production] getProds()
5251
= toList(g.nodes);
53-
52+
5453
return deps(retainProds, removeProds, getProds);
5554
}
5655

@@ -82,10 +81,14 @@ alias Graph[&Node] = tuple[
8281
rel[&Node, &Node] edges];
8382
8483
@synopsis {
85-
Representation of predicates to select nodes in a graph
84+
Representation of predicates to select nodes in a graph based on their own
85+
properties, their ancestors, and their descendants
8686
}
8787
88-
alias Predicate[&Node] = bool(&Node n);
88+
alias Predicate[&Node] = bool(
89+
&Node n,
90+
set[&Node] ancestors /* of `n` in the graph */,
91+
set[&Node] descendants /* of `n` in the graph */);
8992
9093
@synopsis{
9194
Gets the nodes of graph `g` that satisfy predicate `p`, optionally including
@@ -94,13 +97,13 @@ alias Predicate[&Node] = bool(&Node n);
9497
9598
set[&Node] getNodes(Graph[&Node] g, Predicate[&Node] p,
9699
bool getAncestors = false, bool getDescendants = false) {
97-
100+
98101
// Compute ancestors/descendants of nodes
99102
rel[&Node, &Node] descendants = g.edges+;
100103
rel[&Node, &Node] ancestors = invert(descendants);
101104
102105
// Select nodes
103-
nodes = {n | n <- g.nodes, p(n)};
106+
nodes = {n | n <- g.nodes, p(n, ancestors[n] ? {}, descendants[n] ? {})};
104107
nodes += ({} | it + (ancestors[n] ? {}) | getAncestors, n <- nodes);
105108
nodes += ({} | it + (descendants[n] ? {}) | getDescendants, n <- nodes);
106109
return nodes;
@@ -118,27 +121,4 @@ Graph[&Node] retainNodes(Graph[&Node] g, set[&Node] nodes)
118121
}
119122
120123
Graph[&Node] removeNodes(Graph[&Node] g, set[&Node] nodes)
121-
= <g.nodes - nodes, carrierX(g.edges, nodes)>;
122-
123-
@synopsis{
124-
Gets the closest ancestors that satisfy predicate `p` in each branch upward
125-
from node `n` in graph `g`, optionally including `\default` when none of the
126-
ancestors in a branch satisfy `p`
127-
}
128-
129-
set[&Node] getClosestAncestors(
130-
Graph[&Node] g, Predicate[&Node] p, &Node n,
131-
set[&Node] getting = {}, Maybe[&Node] \default = nothing()) {
132-
133-
if (n in getting) {
134-
return {};
135-
} else {
136-
set[&Node] parents = invert(g.edges)[n];
137-
if ({} == parents && just(_) := \default) {
138-
return {\default.val};
139-
} else {
140-
set[&Node] recur(&Node parent) = getClosestAncestors(g, p, parent, getting = getting + n, \default = \default);
141-
return {*(p(parent) ? {parent} : recur(parent)) | parent <- parents};
142-
}
143-
}
144-
}
124+
= <g.nodes - nodes, carrierX(g.edges, nodes)>;

0 commit comments

Comments
 (0)