(input: ParseStream)
| 1184 | } |
| 1185 | |
| 1186 | pub fn parse_join_equivalences(input: ParseStream) -> syn::Result<Vec<Vec<MirScalarExpr>>> { |
| 1187 | let mut equivalences = vec![]; |
| 1188 | while !input.is_empty() { |
| 1189 | let mut equivalence = vec![]; |
| 1190 | loop { |
| 1191 | let mut worklist = vec![parse_operand(input)?]; |
| 1192 | while let Some(operand) = worklist.pop() { |
| 1193 | // Be more lenient and support parenthesized equivalences, |
| 1194 | // e.g. `... AND (x = u + v = z + 1) AND ...`. |
| 1195 | if let MirScalarExpr::CallBinary { |
| 1196 | func: BinaryFunc::Eq(_), |
| 1197 | expr1, |
| 1198 | expr2, |
| 1199 | } = operand |
| 1200 | { |
| 1201 | // We reverse the order in the worklist in order to get |
| 1202 | // the correct order in the equivalence class. |
| 1203 | worklist.push(*expr2); |
| 1204 | worklist.push(*expr1); |
| 1205 | } else { |
| 1206 | equivalence.push(operand); |
| 1207 | } |
| 1208 | } |
| 1209 | if !input.eat(syn::Token![=]) { |
| 1210 | break; |
| 1211 | } |
| 1212 | } |
| 1213 | equivalences.push(equivalence); |
| 1214 | input.eat(kw::AND); |
| 1215 | } |
| 1216 | Ok(equivalences) |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | /// Support for parsing [mz_expr::AggregateExpr]. |
no test coverage detected