mergeChildrenTo(parent, cur, list);
}
else if (cur instanceof BnfParenOptExpression && isTrivialOrSingular(((BnfParenOptExpression)cur).getExpression())) {
// currently <expr> + ? expressions are not supported, thus:
BnfExpression child = ((BnfParenOptExpression)cur).getExpression();
IElementType type = ParserGeneratorUtil.getEffectiveType(child);
if (type == BnfTypes.BNF_OP_OPT || type == BnfTypes.BNF_OP_ZEROMORE) {
list.add(cur.replace(child));
}
else if (type == BnfTypes.BNF_OP_ONEMORE) {
String replacement = ((BnfQuantified)child).getExpression().getText() + "*";
list.add(cur.replace(BnfElementFactory.createExpressionFromText(element.getProject(), replacement)));
}
else {
String replacement = child.getText() + "?";
list.add(cur.replace(BnfElementFactory.createExpressionFromText(element.getProject(), replacement)));
}
}
else if (cur instanceof BnfChoice &&
!(parent instanceof BnfParenthesized) &&
(parent instanceof BnfSequence || parent instanceof BnfQuantified)) {
String replacement = "(" + cur.getText() + ")";
cur.replace(BnfElementFactory.createExpressionFromText(element.getProject(), replacement));
}
else if (isOptMany(cur) && isOptMany(PsiTreeUtil.getChildOfType(cur, BnfExpression.class))) {
BnfExpression child = PsiTreeUtil.getChildOfType(cur, BnfExpression.class);
IElementType type1 = ParserGeneratorUtil.getEffectiveType(cur);
IElementType type2 = ParserGeneratorUtil.getEffectiveType(child);
if (type1 == type2) {
list.add(cur.replace(child));
}
else if (type1 == BnfTypes.BNF_OP_OPT && type2 == BnfTypes.BNF_OP_ONEMORE ||
type2 == BnfTypes.BNF_OP_OPT && type1 == BnfTypes.BNF_OP_ONEMORE ||