-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Labels
Description
Is it possible to mix instances of var and nested patterns in the binding part of a constructor pattern? For example, is the following code allowed:
Case(C<ExpLogical>(
C<ExpRelation>(
C<ExpCharacter>(charVal),
C<ExpName>(name),
relOp),
C<ExpAttribute>(attrName),
logOp)){where attrName, name, charVal, logOp and relOp are instances of the var template and Exp* have the layout:
namespace mch {
template <> struct bindings<ExpUNot> {
Members(ExpUNot::operand1_);
};
template <> struct bindings<ExpCharacter> {
Members(ExpCharacter::value_);
};
template <> struct bindings<ExpAttribute> {
Members(ExpAttribute::name_);
};
template <> struct bindings<ExpLogical> {
Members(ExpLogical::operand1_,
ExpLogical::operand2_,
ExpLogical::fun_);
};
template <> struct bindings<ExpFunc> {
Members(ExpFunc::name_,
ExpFunc::argv_);
};
template <> struct bindings<ExpName> {
//TODO: add prefix
Members(//ExpName::prefix_, // unique_ptr<ExpName>
ExpName::name_,
ExpName::indices_);
};
template <> struct bindings<ExpRelation> {
Members(ExpRelation::operand1_,
ExpRelation::operand2_,
ExpRelation::fun_);
};
};Here some Context. I need to search an Expression AST for a very specific pattern. Without the ExpRelation::fun_ and ExpLogical::fun_ bindings it worked quite well, but when I first began to experiment with the first code snippet instead of the simpler
Case(C<ExpLogical>(
C<ExpRelation>(
C<ExpCharacter>(charVal),
C<ExpName>(name)),
C<ExpAttribute>(attrName))){no pattern seemed to match anymore.