use of org.whole.lang.grammars.model.Concatenate in project whole by wholeplatform.
the class ParserTemplateFactory method propagateActivation.
protected void propagateActivation(Set<ActiveRule> terminalSet, Set<NonTerminal> recursiveSet, ListIterator<ActiveRule> activeRules, ActiveRule ar) {
Rule dotRule = ar.getDotRule();
switch(dotRule.wGetEntityOrd()) {
case GrammarsEntityDescriptorEnum.DataTerminal_ord:
case GrammarsEntityDescriptorEnum.LiteralTerminal_ord:
terminalSet.add(ar);
break;
case GrammarsEntityDescriptorEnum.NonTerminal_ord:
NonTerminal nt = (NonTerminal) dotRule;
if (recursiveSet.add(nt)) {
activeRules.add(ar = createActiveRule(nt));
propagateActivation(terminalSet, recursiveSet, activeRules, ar);
} else
ar.setRecursive(true);
break;
case GrammarsEntityDescriptorEnum.Concatenate_ord:
Concatenate c = (Concatenate) dotRule;
if (c.wSize() > 0) {
ar.setDotRule((Rule) c.wGet(0));
propagateActivation(terminalSet, recursiveSet, activeRules, ar);
}
break;
case GrammarsEntityDescriptorEnum.Optional_ord:
Optional o = (Optional) dotRule;
ar.setDotRule(o.getRule());
propagateActivation(terminalSet, recursiveSet, activeRules, ar);
// TODO add also the rule after the optional
break;
case GrammarsEntityDescriptorEnum.Repeat_ord:
Repeat r = (Repeat) dotRule;
// TODO check lower bound and split active state for repeat continuation if 0
ar.setDotRule(r.getRule());
propagateActivation(terminalSet, recursiveSet, activeRules, ar);
break;
case GrammarsEntityDescriptorEnum.As_ord:
As as = (As) dotRule;
ar.setDotRule(as.getRule());
propagateActivation(terminalSet, recursiveSet, activeRules, ar);
break;
}
}
Aggregations