pub struct BasicScanner {Show 24 fields
input: String,
position: Position,
current_char: Option<char>,
tokens: Vec<Token>,
token_index: usize,
done: bool,
indent_stack: Vec<usize>,
current_indent: usize,
allow_simple_key: bool,
simple_key_allowed: bool,
flow_level: usize,
preserve_comments: bool,
detected_indent_style: Option<IndentStyle>,
indent_samples: Vec<(usize, bool)>,
previous_indent_level: usize,
buffer: String,
char_cache: Vec<char>,
char_indices: Vec<(usize, char)>,
current_char_index: usize,
profiler: Option<YamlProfiler>,
scanning_error: Option<Error>,
limits: Limits,
resource_tracker: ResourceTracker,
inline_sequence_depth: usize,
}Expand description
A basic scanner implementation for YAML tokenization
Fields§
§input: String§position: Position§current_char: Option<char>§tokens: Vec<Token>§token_index: usize§done: bool§indent_stack: Vec<usize>§current_indent: usize§allow_simple_key: bool§simple_key_allowed: bool§flow_level: usize§preserve_comments: bool§detected_indent_style: Option<IndentStyle>§indent_samples: Vec<(usize, bool)>§previous_indent_level: usize§buffer: String§char_cache: Vec<char>§char_indices: Vec<(usize, char)>§current_char_index: usize§profiler: Option<YamlProfiler>§scanning_error: Option<Error>§limits: Limits§resource_tracker: ResourceTracker§inline_sequence_depth: usizeImplementations§
Source§impl BasicScanner
impl BasicScanner
Sourcepub fn with_limits(input: String, limits: Limits) -> Self
pub fn with_limits(input: String, limits: Limits) -> Self
Create a new scanner with custom resource limits
Sourcepub fn new_eager(input: String) -> Self
pub fn new_eager(input: String) -> Self
Create a new scanner with eager token scanning (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 scanner with eager token scanning and custom limits
Sourcepub fn new_with_comments(input: String) -> Self
pub fn new_with_comments(input: String) -> Self
Create a new scanner with comment preservation enabled
Sourcepub fn new_with_comments_and_limits(input: String, limits: Limits) -> Self
pub fn new_with_comments_and_limits(input: String, limits: Limits) -> Self
Create a new scanner with comments and custom limits
Sourcepub fn new_eager_with_comments(input: String) -> Self
pub fn new_eager_with_comments(input: String) -> Self
Create a new scanner with eager scanning and comment preservation
Sourcepub const fn detected_indent_style(&self) -> Option<&IndentStyle>
pub const fn detected_indent_style(&self) -> Option<&IndentStyle>
Get the detected indentation style from the document
Sourcepub const fn has_scanning_error(&self) -> bool
pub const fn has_scanning_error(&self) -> bool
Check if there was a scanning error
Sourcepub fn take_scanning_error(&mut self) -> Option<Error>
pub fn take_scanning_error(&mut self) -> Option<Error>
Get the scanning error if any
Sourcefn skip_whitespace(&mut self)
fn skip_whitespace(&mut self)
Skip whitespace characters (excluding newlines)
Sourcefn handle_indentation(&mut self) -> Result<()>
fn handle_indentation(&mut self) -> Result<()>
Handle indentation and produce block tokens if necessary
Sourcefn analyze_indentation_pattern(
&mut self,
current_indent: usize,
has_tabs: bool,
has_spaces: bool,
) -> Result<()>
fn analyze_indentation_pattern( &mut self, current_indent: usize, has_tabs: bool, has_spaces: bool, ) -> Result<()>
Analyze indentation pattern to detect the document’s indentation style
Sourcefn detect_space_indentation_width(&mut self)
fn detect_space_indentation_width(&mut self)
Detect the consistent space indentation width from samples
Sourcefn is_valid_indentation_level(&self, indent: usize) -> bool
fn is_valid_indentation_level(&self, indent: usize) -> bool
Check if the given indentation level is valid based on current context
Sourcefn validate_indentation_consistency(&self, current_indent: usize) -> Result<()>
fn validate_indentation_consistency(&self, current_indent: usize) -> Result<()>
Validate that current indentation is consistent with detected style
Sourcefn is_plain_scalar_start(&self) -> bool
fn is_plain_scalar_start(&self) -> bool
Check if current position starts a plain scalar
Sourcefn is_yaml_bool(value: &str) -> bool
fn is_yaml_bool(value: &str) -> bool
Check if the value is a YAML boolean
Sourcefn is_yaml_null(value: &str) -> bool
fn is_yaml_null(value: &str) -> bool
Check if the value is a YAML null
Sourcefn normalize_scalar(value: String) -> String
fn normalize_scalar(value: String) -> String
Normalize a scalar value based on YAML rules
Sourcefn scan_number(&mut self) -> Result<Token>
fn scan_number(&mut self) -> Result<Token>
Scan a number token
Sourcefn scan_plain_scalar(&mut self) -> Result<Token>
fn scan_plain_scalar(&mut self) -> Result<Token>
Scan a plain scalar (unquoted string)
Sourcefn scan_quoted_string(&mut self, quote_char: char) -> Result<Token>
fn scan_quoted_string(&mut self, quote_char: char) -> Result<Token>
Scan a quoted string
Sourcefn scan_document_start(&mut self) -> Result<Option<Token>>
fn scan_document_start(&mut self) -> Result<Option<Token>>
Scan document start marker (—)
Sourcefn scan_yaml_directive(&mut self) -> Result<Option<Token>>
fn scan_yaml_directive(&mut self) -> Result<Option<Token>>
Scan YAML version directive (%YAML)
Sourcefn scan_tag_directive(&mut self) -> Result<Option<Token>>
fn scan_tag_directive(&mut self) -> Result<Option<Token>>
Scan TAG directive (%TAG)
Sourcefn scan_tag_handle(&mut self) -> Result<String>
fn scan_tag_handle(&mut self) -> Result<String>
Scan a tag handle for TAG directive
Sourcefn scan_tag_prefix(&mut self) -> Result<String>
fn scan_tag_prefix(&mut self) -> Result<String>
Scan a tag prefix (URI) for TAG directive
Sourcefn is_directive(&self) -> bool
fn is_directive(&self) -> bool
Check if current position might be a directive
Sourcefn scan_document_end(&mut self) -> Result<Option<Token>>
fn scan_document_end(&mut self) -> Result<Option<Token>>
Scan document end marker (…)
Sourcefn scan_comment(&mut self) -> Result<Token>
fn scan_comment(&mut self) -> Result<Token>
Scan a comment token
Sourcefn process_line(&mut self) -> Result<()>
fn process_line(&mut self) -> Result<()>
Process a line and generate appropriate tokens
Sourcefn scan_next_token(&mut self) -> Result<()>
fn scan_next_token(&mut self) -> Result<()>
Scan the next token lazily
Sourcefn scan_all_tokens(&mut self) -> Result<()>
fn scan_all_tokens(&mut self) -> Result<()>
Pre-scan all tokens (simplified approach for basic implementation)
Sourcefn peek_char(&self, offset: isize) -> Option<char>
fn peek_char(&self, offset: isize) -> Option<char>
Peek at a character at the given offset (can be negative)
Sourcefn scan_anchor(&mut self) -> Result<Token>
fn scan_anchor(&mut self) -> Result<Token>
Scan an anchor token (&name)
Sourcefn scan_alias(&mut self) -> Result<Token>
fn scan_alias(&mut self) -> Result<Token>
Scan an alias token (*name)
Sourcefn scan_identifier(&mut self) -> Result<String>
fn scan_identifier(&mut self) -> Result<String>
Scan an identifier (used for anchor and alias names)
Sourcefn scan_literal_block_scalar(&mut self) -> Result<Token>
fn scan_literal_block_scalar(&mut self) -> Result<Token>
Scan a literal block scalar (|)
Sourcefn scan_folded_block_scalar(&mut self) -> Result<Token>
fn scan_folded_block_scalar(&mut self) -> Result<Token>
Scan a folded block scalar (>)
Sourcefn scan_block_scalar_header(&mut self) -> Result<(bool, Option<usize>)>
fn scan_block_scalar_header(&mut self) -> Result<(bool, Option<usize>)>
Parse block scalar header indicators (+, -, and explicit indent)
Sourcefn skip_to_next_line(&mut self) -> Result<()>
fn skip_to_next_line(&mut self) -> Result<()>
Skip whitespace and comments to the next content line
Sourcefn find_block_scalar_indent(&mut self, base_indent: usize) -> Result<usize>
fn find_block_scalar_indent(&mut self, base_indent: usize) -> Result<usize>
Find the content indentation for a block scalar
Sourcefn count_line_indent(&mut self) -> usize
fn count_line_indent(&mut self) -> usize
Count indentation at start of current line
Sourcefn collect_literal_block_content(
&mut self,
content_indent: usize,
_keep_trailing: bool,
) -> Result<String>
fn collect_literal_block_content( &mut self, content_indent: usize, _keep_trailing: bool, ) -> Result<String>
Collect content for a literal block scalar
Sourcefn collect_folded_block_content(
&mut self,
content_indent: usize,
_keep_trailing: bool,
) -> Result<String>
fn collect_folded_block_content( &mut self, content_indent: usize, _keep_trailing: bool, ) -> Result<String>
Collect content for a folded block scalar
Sourcefn check_for_mapping_ahead(&self) -> bool
fn check_for_mapping_ahead(&self) -> bool
Check if the current position is the start of a mapping key by looking ahead for ‘:’
Sourcefn check_active_mapping_at_level(&self, _target_indent: usize) -> bool
fn check_active_mapping_at_level(&self, _target_indent: usize) -> bool
Check if there’s an active mapping at the specified indentation level This method properly handles BlockEnd tokens by tracking mapping start/end pairs
Trait Implementations§
Source§impl Debug for BasicScanner
impl Debug for BasicScanner
Source§impl ScalarScanner for BasicScanner
Implementation of ScalarScanner for BasicScanner
impl ScalarScanner for BasicScanner
Implementation of ScalarScanner for BasicScanner