Skip to content

Sequence

bcql_py.models.sequence

AST nodes for sequence-level constructions.

These models represent sequences of tokens, repetition quantifiers, parenthesized groups, logical union/intersection/negation at the sequence level, and the _ underscore used in relation queries where applicable

SequenceNode

Bases: BCQLNode

An ordered sequence of adjacent tokens / sub-queries. A very high-level node type that can represent an entire query or a sub-sequence

Attributes:

Name Type Description
children list[BCQLNodeUnion]

The ordered list of child nodes in the sequence.

RepetitionNode

Bases: BCQLNode

A repetition quantifier applied to a sub-query.

Supports + (1+), * (0+), ? (0 or 1), {n}, {n,m}, {n,}. Note that "up to" quantifiers like {0,m} are exported as {,m} and may therefore be different in surface form from the original.

Attributes:

Name Type Description
child BCQLNodeUnion

The sub-query being repeated.

min_count int

Minimum number of repetitions (inclusive, min. 0).

max_count int | None

Maximum number of repetitions (inclusive), or None for unlimited.

GroupNode

Bases: BCQLNode

A parenthesized group of sub-queries.

Groups allow applying repetition operators or capture constraints to a complex sub-expression. We specify that there can only be one child node in a group, which typically would be a SequenceNode if there are multiple adjacent tokens or a token-level Node.

Attributes:

Name Type Description
child BCQLNodeUnion

The inner sub-query.

SequenceBoolNode

Bases: BCQLNode

Sequence-level boolean combination (&, |, ->).

Binary, left-associative node mirroring the booleanOperator rule in Bcql.g4: all three operators share the same precedence. For example, "a" | "b" & "c" parses as ("a" | "b") & "c".

Attributes:

Name Type Description
operator Literal['&', '|', '->']

The boolean operator.

left BCQLNodeUnion

The left operand.

right BCQLNodeUnion

The right operand.

NegationNode

Bases: BCQLNode

Sequence-level negation (!).

Negation sits at the span level in the precedence chain (above repetition), so !"man"+ parses as !("man"+) per Bcql.g4's sequencePartNoCapture rule. The child is always a single span-level node (never a bare sequence), so to_bcql just prepends ! without extra parentheses.

Attributes:

Name Type Description
child BCQLNodeUnion

The sub-query being negated.

UnderscoreNode

Bases: BCQLNode

The _ wildcard used in relation queries.

Distinct from [] (match-all token): _ means "any source or target" in a relation expression without constraining token count.