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

Function is_predicate

graphlite/src/ast/parser.rs:3737–3812  ·  view source on GitHub ↗

Parse IS predicate: expression IS [NOT] predicate_type [target]

(tokens: &[Token])

Source from the content-addressed store, hash-verified

3735
3736/// Parse IS predicate: expression IS [NOT] predicate_type [target]
3737fn is_predicate(tokens: &[Token]) -> IResult<&[Token], Expression> {
3738 map(
3739 tuple((
3740 additive_expression,
3741 expect_token(Token::Is),
3742 opt(expect_token(Token::Not)),
3743 alt((
3744 // Value state predicates
3745 map(expect_token(Token::Null), |_| {
3746 (IsPredicateType::Null, None, None)
3747 }),
3748 map(expect_token(Token::Boolean(true)), |_| {
3749 (IsPredicateType::True, None, None)
3750 }),
3751 map(expect_token(Token::Boolean(false)), |_| {
3752 (IsPredicateType::False, None, None)
3753 }),
3754 map(expect_token(Token::Unknown), |_| {
3755 (IsPredicateType::Unknown, None, None)
3756 }),
3757 // Graph element predicates
3758 map(expect_token(Token::Normalized), |_| {
3759 (IsPredicateType::Normalized, None, None)
3760 }),
3761 map(expect_token(Token::Directed), |_| {
3762 (IsPredicateType::Directed, None, None)
3763 }),
3764 // Topology predicates with optional targets
3765 map(
3766 tuple((
3767 expect_token(Token::Source),
3768 opt(tuple((expect_token(Token::Of), additive_expression))),
3769 )),
3770 |(_, target)| {
3771 (
3772 IsPredicateType::Source,
3773 target.map(|(_, expr)| Box::new(expr)),
3774 None,
3775 )
3776 },
3777 ),
3778 map(
3779 tuple((
3780 expect_token(Token::Destination),
3781 opt(tuple((expect_token(Token::Of), additive_expression))),
3782 )),
3783 |(_, target)| {
3784 (
3785 IsPredicateType::Destination,
3786 target.map(|(_, expr)| Box::new(expr)),
3787 None,
3788 )
3789 },
3790 ),
3791 // Type predicates
3792 map(tuple((expect_token(Token::Typed), type_spec)), |(_, ts)| {
3793 (IsPredicateType::Typed, None, Some(ts))
3794 }),

Callers

nothing calls this directly

Calls 1

expect_tokenFunction · 0.85

Tested by

no test coverage detected