Automatic context accessors detect closures

This commit is contained in:
Sam Harwell 2012-08-09 16:38:01 -05:00
parent 199e9892dc
commit 5dacfc9554
1 changed files with 13 additions and 1 deletions

View File

@ -170,7 +170,19 @@ public class RuleFunction extends OutputModelObject {
FrequencySet<String> altFreq = getElementFrequenciesForAlt(ast); FrequencySet<String> altFreq = getElementFrequenciesForAlt(ast);
for (GrammarAST t : refs) { for (GrammarAST t : refs) {
String refLabelName = t.getText(); String refLabelName = t.getText();
if ( altFreq.count(t.getText())>1 ) needsList.add(refLabelName); if (needsList.contains(refLabelName)) {
continue;
}
if ( altFreq.count(t.getText())>1 ) {
needsList.add(refLabelName);
}
else {
boolean inLoop = t.hasAncestor(CLOSURE) || t.hasAncestor(POSITIVE_CLOSURE);
if (inLoop) {
needsList.add(refLabelName);
}
}
} }
} }
Set<Decl> decls = new HashSet<Decl>(); Set<Decl> decls = new HashSet<Decl>();