cql3: grammar: remove duplication around columnCondition scalar/collection variants

columnCondition duplicates the grammar for scalar relations and subscripted
collection relations. Eliminate the duplication by introducing a
subscriptExpr production, which encapsulates the differences.
This commit is contained in:
Avi Kivity
2023-01-21 01:53:12 +02:00
parent 74da77f442
commit c47cf9858b

View File

@@ -1682,9 +1682,14 @@ columnRefExpr returns [expression e]
: column=cident { e = unresolved_identifier{column}; }
;
subscriptExpr returns [expression e]
: col=columnRefExpr { e = std::move(col); }
( '[' sub=term ']' { e = subscript{std::move(e), std::move(sub)}; } )?
;
columnCondition[conditions_type& conditions]
// Note: we'll reject duplicates later
: key=columnRefExpr
: key=subscriptExpr
( op=relationType t=term { conditions.emplace_back(
binary_operator(
key,
@@ -1705,37 +1710,6 @@ columnCondition[conditions_type& conditions]
marker1));
}
)
| '[' element=term ']'
( op=relationType t=term { conditions.emplace_back(
binary_operator(
subscript{
key,
element
},
op,
t));
}
| K_IN
( values=singleColumnInValues { conditions.emplace_back(
binary_operator(
subscript{
key,
element
},
oper_t::IN,
collection_constructor{collection_constructor::style_type::list, values}));
}
| marker1=marker { conditions.emplace_back(
binary_operator(
subscript{
key,
element
},
oper_t::IN,
marker1));
}
)
)
)
;