pub struct Parser<'eng, 'tokens> {
pub tokens: Vec<Token<'tokens>>,
pub meta: Arc<SourceMeta>,
pub pos: usize,
pub refs: RefMap,
pub diag_engine: &'eng mut DiagnosticEngine<Code>,
pub options: ParseOptions,
pub source: Option<&'tokens str>,
pub link_label_depth: u16,
}Expand description
Token-stream cursor + diagnostic engine. 'tokens ties borrowed lexemes to
the source; 'eng ties the engine borrow to the caller.
Fields§
§tokens: Vec<Token<'tokens>>§meta: Arc<SourceMeta>§pos: usize§refs: RefMap§diag_engine: &'eng mut DiagnosticEngine<Code>§options: ParseOptions§source: Option<&'tokens str>Original source string, if the caller supplied it (via
with_source). Enables a safe, provenance-correct byte-offset
reslice in raw_source_for_token_range instead of pointer
arithmetic across token slices.
link_label_depth: u16Current [...] link-label nesting depth. Recursive label parsing
(and the unresolved-shortcut replay) is super-linear in the number
of nested brackets; once this exceeds [MAX_LINK_LABEL_DEPTH] a
[ is treated as literal text instead of opening yet another
recursive parse. No real document nests link labels that deeply
(CM forbids links inside link text), so this only bounds adversarial
[[[[[... input.
Implementations§
Source§impl<'eng, 'tokens> Parser<'eng, 'tokens>
impl<'eng, 'tokens> Parser<'eng, 'tokens>
Sourcepub fn new(
tokens: Vec<Token<'tokens>>,
meta: Arc<SourceMeta>,
diag_engine: &'eng mut DiagnosticEngine<Code>,
) -> Self
pub fn new( tokens: Vec<Token<'tokens>>, meta: Arc<SourceMeta>, diag_engine: &'eng mut DiagnosticEngine<Code>, ) -> Self
Build a parser positioned at the first token.
Sourcepub fn new_with_options(
tokens: Vec<Token<'tokens>>,
meta: Arc<SourceMeta>,
diag_engine: &'eng mut DiagnosticEngine<Code>,
options: ParseOptions,
) -> Self
pub fn new_with_options( tokens: Vec<Token<'tokens>>, meta: Arc<SourceMeta>, diag_engine: &'eng mut DiagnosticEngine<Code>, options: ParseOptions, ) -> Self
Build a parser with explicit ParseOptions.
Sourcepub fn with_source(self, source: &'tokens str) -> Self
pub fn with_source(self, source: &'tokens str) -> Self
Attach the original source string so verbatim-slice reconstruction (raw HTML blocks, malformed-link bodies) can reslice it directly instead of reconstructing a pointer range across token lexemes.