pub struct DcSyntaxArena<'a> { /* private fields */ }Expand description
Flat, reusable arena holding parsed DcSyntaxNodes for a frame or document.
Calling DcSyntaxArena::clear resets the arena between records while
retaining allocated capacity, achieving $O(1)$ steady-state memory usage
when streaming across multi-gigabyte documents or journals.
Implementations§
Source§impl<'a> DcSyntaxArena<'a>
impl<'a> DcSyntaxArena<'a>
Sourcepub fn alloc(&mut self, span: DcByteSpan, kind: DcSyntaxKind<'a>) -> NodeId
pub fn alloc(&mut self, span: DcByteSpan, kind: DcSyntaxKind<'a>) -> NodeId
Allocates a node in the arena and returns its NodeId.
Sourcepub fn alloc_escaped_atom(&mut self, span: DcByteSpan, ch: DcChar) -> NodeId
pub fn alloc_escaped_atom(&mut self, span: DcByteSpan, ch: DcChar) -> NodeId
Allocates an escaped atom node in the arena and returns its NodeId.
Sourcepub fn alloc_literal(
&mut self,
span: DcByteSpan,
opener: DcChar,
closer: DcChar,
type_header: &[DcChar],
decoded: &DcMstr,
) -> NodeId
pub fn alloc_literal( &mut self, span: DcByteSpan, opener: DcChar, closer: DcChar, type_header: &[DcChar], decoded: &DcMstr, ) -> NodeId
Allocates a framed literal container node (Dc 260..261).
Sourcepub fn alloc_identifier(
&mut self,
span: DcByteSpan,
opener: DcChar,
closer: DcChar,
name: &DcMstr,
) -> NodeId
pub fn alloc_identifier( &mut self, span: DcByteSpan, opener: DcChar, closer: DcChar, name: &DcMstr, ) -> NodeId
Allocates a framed identifier container node (Dc 270..271).
Sourcepub fn alloc_number(
&mut self,
span: DcByteSpan,
opener: DcChar,
closer: DcChar,
format: DcChar,
digits: &[DcChar],
) -> NodeId
pub fn alloc_number( &mut self, span: DcByteSpan, opener: DcChar, closer: DcChar, format: DcChar, digits: &[DcChar], ) -> NodeId
Allocates a framed number container node (Dc 6..7).
Sourcepub fn has_opener_role_with_resolver(
&self,
id: NodeId,
role: DcRole,
resolver: &dyn SyntaxRuleResolver,
) -> bool
pub fn has_opener_role_with_resolver( &self, id: NodeId, role: DcRole, resolver: &dyn SyntaxRuleResolver, ) -> bool
Returns true if id is a Container whose opener fills role using resolver.
Sourcepub fn is_literal_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> bool
pub fn is_literal_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> bool
Returns true if id is a framed literal container (Dc 260..261) using resolver.
Sourcepub fn decode_literal_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> Option<(Vec<DcChar>, DcMstring)>
pub fn decode_literal_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> Option<(Vec<DcChar>, DcMstring)>
Decodes a framed literal container (Dc 260..261) into (type_header, decoded) using resolver.
Sourcepub fn is_identifier_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> bool
pub fn is_identifier_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> bool
Returns true if id is a framed identifier container (Dc 270..271) using resolver.
Sourcepub fn decode_identifier_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> Option<DcMstring>
pub fn decode_identifier_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> Option<DcMstring>
Decodes a framed identifier container (Dc 270..271) into its DcMstring name using resolver.
Sourcepub fn is_number_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> bool
pub fn is_number_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> bool
Returns true if id is a framed number container (Dc 6..7) using resolver.
Sourcepub fn decode_number_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> Option<(DcChar, Vec<DcChar>)>
pub fn decode_number_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> Option<(DcChar, Vec<DcChar>)>
Decodes a framed number container (Dc 6..7) into (format, digits) using resolver.
Sourcepub fn decode_assignment_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> Option<(DcMstring, NodeId)>
pub fn decode_assignment_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> Option<(DcMstring, NodeId)>
Decodes an assignment construct (Dc 269 or Dc 268) into (ident_name, value_node_id) using resolver.
Sourcepub fn node(&self, id: NodeId) -> Option<&DcSyntaxNode<'a>>
pub fn node(&self, id: NodeId) -> Option<&DcSyntaxNode<'a>>
Sourcepub fn nodes(&self) -> &[DcSyntaxNode<'a>]
pub fn nodes(&self) -> &[DcSyntaxNode<'a>]
Returns all nodes in the arena.
Sourcepub fn push_diagnostic(&mut self, diagnostic: SyntaxDiagnostic)
pub fn push_diagnostic(&mut self, diagnostic: SyntaxDiagnostic)
Records a syntax diagnostic encountered while parsing.
Sourcepub fn diagnostics(&self) -> &[SyntaxDiagnostic]
pub fn diagnostics(&self) -> &[SyntaxDiagnostic]
Returns all diagnostics recorded in this arena.
Sourcepub fn split_operands(&self, nodes: &[NodeId]) -> Vec<Vec<NodeId>>
pub fn split_operands(&self, nodes: &[NodeId]) -> Vec<Vec<NodeId>>
Splits a sequence of child NodeIds on [DC_LIST_ELEMENT_SEPARATOR] (Dc 312).
Sourcepub fn split_operands_with_resolver(
&self,
nodes: &[NodeId],
resolver: &dyn SyntaxRuleResolver,
) -> Vec<Vec<NodeId>>
pub fn split_operands_with_resolver( &self, nodes: &[NodeId], resolver: &dyn SyntaxRuleResolver, ) -> Vec<Vec<NodeId>>
Splits a sequence of child NodeIds on [DC_LIST_ELEMENT_SEPARATOR] using the provided resolver.
Sourcepub fn extract_kv_map_operand_entries_with_resolver(
&self,
id: NodeId,
require_object_headers: bool,
resolver: &dyn SyntaxRuleResolver,
) -> Result<(DcChar, Vec<NodeId>, Vec<(Vec<NodeId>, Vec<NodeId>)>)>
pub fn extract_kv_map_operand_entries_with_resolver( &self, id: NodeId, require_object_headers: bool, resolver: &dyn SyntaxRuleResolver, ) -> Result<(DcChar, Vec<NodeId>, Vec<(Vec<NodeId>, Vec<NodeId>)>)>
Extracts operands for each entry in a key-value map container using the
provided SyntaxRuleResolver.
Sourcepub fn extract_kv_map_node_pairs_with_resolver(
&self,
id: NodeId,
resolver: &dyn SyntaxRuleResolver,
) -> Result<(DcChar, Vec<(NodeId, NodeId)>)>
pub fn extract_kv_map_node_pairs_with_resolver( &self, id: NodeId, resolver: &dyn SyntaxRuleResolver, ) -> Result<(DcChar, Vec<(NodeId, NodeId)>)>
Extracts single-node (key_id, value_id) pairs from a map container
(Dc 559..560 or Dc 313..314) using the provided SyntaxRuleResolver.
Trait Implementations§
Source§impl<'a> Clone for DcSyntaxArena<'a>
impl<'a> Clone for DcSyntaxArena<'a>
Source§fn clone(&self) -> DcSyntaxArena<'a>
fn clone(&self) -> DcSyntaxArena<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for DcSyntaxArena<'a>
impl<'a> Debug for DcSyntaxArena<'a>
Source§impl<'a> Default for DcSyntaxArena<'a>
impl<'a> Default for DcSyntaxArena<'a>
Source§fn default() -> DcSyntaxArena<'a>
fn default() -> DcSyntaxArena<'a>
Auto Trait Implementations§
impl<'a> Freeze for DcSyntaxArena<'a>
impl<'a> RefUnwindSafe for DcSyntaxArena<'a>
impl<'a> Send for DcSyntaxArena<'a>
impl<'a> Sync for DcSyntaxArena<'a>
impl<'a> Unpin for DcSyntaxArena<'a>
impl<'a> UnwindSafe for DcSyntaxArena<'a>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);