pub struct BuildGraph<'src> { /* private fields */ }Expand description
Build-time graph for query compilation.
Nodes are stored in a flat vector, referenced by NodeId.
Definitions map names to their entry points.
Implementations§
Source§impl<'src> BuildGraph<'src>
impl<'src> BuildGraph<'src>
pub fn new() -> Self
pub fn add_node(&mut self, node: BuildNode<'src>) -> NodeId
pub fn add_epsilon(&mut self) -> NodeId
Clone a node, creating a new node with the same matcher, effects, and ref_marker, but with the specified nav and copying the successors list.
pub fn add_matcher(&mut self, matcher: BuildMatcher<'src>) -> NodeId
pub fn add_definition(&mut self, name: &'src str, entry: NodeId)
pub fn definition(&self, name: &str) -> Option<NodeId>
pub fn definitions(&self) -> impl Iterator<Item = (&'src str, NodeId)> + '_
pub fn node(&self, id: NodeId) -> &BuildNode<'src>
pub fn node_mut(&mut self, id: NodeId) -> &mut BuildNode<'src>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> impl Iterator<Item = (NodeId, &BuildNode<'src>)>
pub fn connect(&mut self, from: NodeId, to: NodeId)
pub fn connect_exit(&mut self, fragment: Fragment, to: NodeId)
pub fn matcher_fragment(&mut self, matcher: BuildMatcher<'src>) -> Fragment
pub fn epsilon_fragment(&mut self) -> Fragment
Sourcepub fn sequence(&mut self, fragments: &[Fragment]) -> Fragment
pub fn sequence(&mut self, fragments: &[Fragment]) -> Fragment
Connect fragments in sequence: f1 → f2 → … → fn
Sourcepub fn alternation(&mut self, fragments: &[Fragment]) -> Fragment
pub fn alternation(&mut self, fragments: &[Fragment]) -> Fragment
Connect fragments in parallel (alternation): entry → [f1|f2|…|fn] → exit
Sourcepub fn zero_or_more(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn zero_or_more(&mut self, inner: Fragment, nav: Nav) -> Fragment
Zero or more (greedy): inner*
Sourcepub fn zero_or_more_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn zero_or_more_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
Zero or more (non-greedy): inner*?
Sourcepub fn one_or_more(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn one_or_more(&mut self, inner: Fragment, nav: Nav) -> Fragment
One or more (greedy): inner+
Sourcepub fn one_or_more_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn one_or_more_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
One or more (non-greedy): inner+?
Sourcepub fn optional_lazy(&mut self, inner: Fragment) -> Fragment
pub fn optional_lazy(&mut self, inner: Fragment) -> Fragment
Optional (non-greedy): inner??
Sourcepub fn zero_or_more_array(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn zero_or_more_array(&mut self, inner: Fragment, nav: Nav) -> Fragment
Zero or more with array collection (greedy): inner*
Sourcepub fn zero_or_more_array_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn zero_or_more_array_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
Zero or more with array collection (non-greedy): inner*?
Sourcepub fn one_or_more_array(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn one_or_more_array(&mut self, inner: Fragment, nav: Nav) -> Fragment
One or more with array collection (greedy): inner+
Sourcepub fn one_or_more_array_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn one_or_more_array_lazy(&mut self, inner: Fragment, nav: Nav) -> Fragment
One or more with array collection (non-greedy): inner+?
Sourcepub fn zero_or_more_array_qis(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn zero_or_more_array_qis(&mut self, inner: Fragment, nav: Nav) -> Fragment
Zero or more with QIS object wrapping (greedy): inner*
Each iteration is wrapped in StartObject/EndObject to keep multiple captures coupled per-iteration.
Sourcepub fn zero_or_more_array_qis_lazy(
&mut self,
inner: Fragment,
nav: Nav,
) -> Fragment
pub fn zero_or_more_array_qis_lazy( &mut self, inner: Fragment, nav: Nav, ) -> Fragment
Zero or more with QIS object wrapping (non-greedy): inner*?
Sourcepub fn one_or_more_array_qis(&mut self, inner: Fragment, nav: Nav) -> Fragment
pub fn one_or_more_array_qis(&mut self, inner: Fragment, nav: Nav) -> Fragment
One or more with QIS object wrapping (greedy): inner+
Sourcepub fn one_or_more_array_qis_lazy(
&mut self,
inner: Fragment,
nav: Nav,
) -> Fragment
pub fn one_or_more_array_qis_lazy( &mut self, inner: Fragment, nav: Nav, ) -> Fragment
One or more with QIS object wrapping (non-greedy): inner+?
Sourcepub fn optional_qis(&mut self, inner: Fragment) -> Fragment
pub fn optional_qis(&mut self, inner: Fragment) -> Fragment
Optional with QIS object wrapping: inner?
Wraps the optional value in an object scope.
Sourcepub fn optional_qis_lazy(&mut self, inner: Fragment) -> Fragment
pub fn optional_qis_lazy(&mut self, inner: Fragment) -> Fragment
Optional with QIS object wrapping (non-greedy): inner??
Sourcepub fn wrap_definitions_with_root(&mut self, root_kind: &'src str)
pub fn wrap_definitions_with_root(&mut self, root_kind: &'src str)
Wrap definitions that don’t already match the root node kind.
For each definition whose entry matcher doesn’t match root_kind,
prepends a transition that matches the root and descends into children.
This allows queries like (function_declaration) to work when the
interpreter starts at tree root (e.g., program).