pub struct BasicParser {Show 23 fields
scanner: BasicScanner,
events: Vec<Event>,
event_index: usize,
state: ParserState,
state_stack: Vec<ParserState>,
position: Position,
pending_anchor: Option<String>,
pending_anchor_line: Option<usize>,
last_key_marker_line: Option<usize>,
last_key_marker_column: Option<usize>,
just_closed_inline_wrap: bool,
inline_wrap_column: Option<usize>,
pending_tag: Option<String>,
pending_tag_line: Option<usize>,
last_token_type: Option<TokenType>,
scanning_error: Option<Error>,
yaml_version: Option<(u8, u8)>,
tag_directives: Vec<(String, String)>,
tag_resolver: TagResolver,
defined_anchors: HashSet<String>,
last_value_token_line: Option<usize>,
explicit_key_pending: bool,
implicit_flow_pair_depth: usize,
}Expand description
Basic parser implementation that converts tokens to events
Fields§
§scanner: BasicScanner§events: Vec<Event>§event_index: usize§state: ParserState§state_stack: Vec<ParserState>§position: Position§pending_anchor: Option<String>§pending_anchor_line: Option<usize>Line where pending_anchor was set. Used to distinguish a
“freestanding” anchor (alone on its own line — belongs to the
upcoming collection) from an “inline” anchor (same line as the
next key — belongs to that key). yaml-test-suite 6BFJ, 9KAX.
last_key_marker_line: Option<usize>Line of the most recent ? Key marker. Used to detect when
an explicit-key construct has an inline single-pair mapping as
its key (yaml-test-suite M2N8/00, M2N8/01, V9D5).
last_key_marker_column: Option<usize>Column of the most recent ? Key marker. Used in V9D5: when
a : arrives at the same column as the most recent ? on
a later line, it’s the explicit value separator — close any
inline-wrapped inner mapping first.
just_closed_inline_wrap: boolSet when an explicit value separator just closed an inline-
wrapped key. The next <scalar>:<scalar> on the same line
should also be wrapped in an inner mapping (V9D5’s value side).
inline_wrap_column: Option<usize>Column of an open inline-wrap mapping (V9D5). Used to detect the matching explicit-value separator and close it.
pending_tag: Option<String>§pending_tag_line: Option<usize>Same idea as pending_anchor_line but for tags. Used to detect
a freestanding tag in block-sequence context that should be
flushed as the previous item’s empty value rather than carried
onto the next item (yaml-test-suite FH7J).
last_token_type: Option<TokenType>§scanning_error: Option<Error>§yaml_version: Option<(u8, u8)>§tag_directives: Vec<(String, String)>§tag_resolver: TagResolver§defined_anchors: HashSet<String>Anchor names that have been defined so far in the stream. Used to
validate that aliases (*name) reference a known anchor (YAML 1.2
§6.9.2). Forward references are forbidden, and we never reset this
set — once defined, an anchor remains referenceable for the rest of
the parse, matching common loader semantics.
last_value_token_line: Option<usize>Line of the most recent : Value token. Used by the
BlockMappingValue heuristic to tell apart “same-line value
scalar” (6M2F) from “next-line sibling key” (6KGN).
explicit_key_pending: boolTrue while we’re holding an explicit ? key that has not yet
received its :. Used at end-of-stream to distinguish a
spec-legal ? key with implicit empty value from a missing-:
bare scalar (yaml-test-suite 7MNF).
implicit_flow_pair_depth: usizeCounts implicit single-pair flow mappings still open. A , or
] while this is > 0 closes the innermost implicit mapping
before continuing the outer flow sequence (§7.5).
Implementations§
Source§impl BasicParser
impl BasicParser
Sourcepub fn with_limits(input: String, limits: Limits) -> Self
pub fn with_limits(input: String, limits: Limits) -> Self
Create a new streaming parser with custom limits
Sourcepub fn new_eager(input: String) -> Self
pub fn new_eager(input: String) -> Self
Create a new parser with eager parsing (for compatibility)
Sourcepub fn new_eager_with_limits(input: String, limits: Limits) -> Self
pub fn new_eager_with_limits(input: String, limits: Limits) -> Self
Create a new parser with eager parsing and custom limits
Sourcepub fn from_scanner(scanner: BasicScanner) -> Self
pub fn from_scanner(scanner: BasicScanner) -> Self
Create parser from existing scanner
Sourcefn check_directive_context(&self, pos: Position, name: &str) -> Result<()>
fn check_directive_context(&self, pos: Position, name: &str) -> Result<()>
YAML 1.2 §6.8: directives may appear only before the first
document (StreamStart / ImplicitDocumentStart) or after an
explicit ... (DocumentEnd). Anywhere else they’re invalid.
Sourcefn create_implicit_document_start(&mut self, position: Position) -> Event
fn create_implicit_document_start(&mut self, position: Position) -> Event
Create implicit document start event with directives
Sourcefn validate_final_state(&self) -> Result<()>
fn validate_final_state(&self) -> Result<()>
Validate that the parser is in a valid final state
Sourcefn generate_next_event(&mut self) -> Result<()>
fn generate_next_event(&mut self) -> Result<()>
Generate the next event by processing the next token
Sourcefn process_token(&mut self, token: Token) -> Result<()>
fn process_token(&mut self, token: Token) -> Result<()>
Process a single token and generate appropriate events
Sourcefn handle_node_completion(&mut self)
fn handle_node_completion(&mut self)
Handle completion of a node (scalar or collection) and manage mapping state transitions
Source§impl BasicParser
impl BasicParser
Sourcepub fn take_scanning_error(&mut self) -> Option<Error>
pub fn take_scanning_error(&mut self) -> Option<Error>
Check if there was a scanning error