Skip to content

Commit 52297f1

Browse files
committed
Add a new function to get the parents of a symbol in a grammar
1 parent 4a209dd commit 52297f1

File tree

1 file changed

+11
-0
lines changed
  • rascal-textmate-core/src/main/rascal/lang/rascal/grammar

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ list[Pointer] find(Grammar g, Production p, Symbol s, Direction dir = forward())
108108
return doFind({}, p, s);
109109
}
110110
111+
@synopsis{
112+
Lookdowns a list of productions for symbol `s` in grammar `g`
113+
}
114+
115+
// TODO: Rename this function because the current name makes little sense in
116+
// isolation (it's supposed to be the opposite of `lookup`, but in that sense,
117+
// the directions are illogical)
118+
119+
set[Production] lookdown(Grammar g, Symbol s)
120+
= {parent | /parent: prod(_, /Symbol _: s, _) := g};
121+
111122
@synopsis{
112123
Lookups a list of productions for symbol `s` in grammar `g`, replacing
113124
formal parameters with actual parameters when needed

0 commit comments

Comments
 (0)