MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / with_clause

Function with_clause

graphlite/src/ast/parser.rs:1431–1458  ·  view source on GitHub ↗

Parse WITH clause: WITH [DISTINCT|ALL] expr [AS alias] [, expr [AS alias]]* [WHERE condition] [ORDER BY ...] [LIMIT ...]

(tokens: &[Token])

Source from the content-addressed store, hash-verified

1429
1430/// Parse WITH clause: WITH [DISTINCT|ALL] expr [AS alias] [, expr [AS alias]]* [WHERE condition] [ORDER BY ...] [LIMIT ...]
1431fn with_clause(tokens: &[Token]) -> IResult<&[Token], WithClause> {
1432 map(
1433 tuple((
1434 expect_token(Token::With),
1435 opt(alt((
1436 value(DistinctQualifier::Distinct, expect_token(Token::Distinct)),
1437 value(DistinctQualifier::All, expect_token(Token::All)),
1438 ))),
1439 with_item,
1440 many0(tuple((expect_token(Token::Comma), with_item))),
1441 opt(where_clause),
1442 opt(order_clause),
1443 opt(limit_clause),
1444 )),
1445 |(_, distinct_opt, first, rest, where_clause, order_clause, limit_clause)| {
1446 let mut items = vec![first];
1447 items.extend(rest.into_iter().map(|(_, item)| item));
1448 WithClause {
1449 distinct: distinct_opt.unwrap_or(DistinctQualifier::None),
1450 items,
1451 where_clause,
1452 order_clause,
1453 limit_clause,
1454 location: Location::default(),
1455 }
1456 },
1457 )(tokens)
1458}
1459
1460/// Parse WITH item: expression [AS alias]
1461fn with_item(tokens: &[Token]) -> IResult<&[Token], WithItem> {

Callers

nothing calls this directly

Calls 1

expect_tokenFunction · 0.85

Tested by

no test coverage detected