Skip to main content

Parser

Struct Parser 

Source
pub(crate) struct Parser<'a> {
    pub(crate) src: &'a str,
    pub(crate) file: PathBuf,
    pub(crate) pos: usize,
    pub(crate) items: Vec<Item>,
    pub(crate) diagnostics: Vec<Diagnostic>,
}

Fields§

§src: &'a str§file: PathBuf§pos: usize§items: Vec<Item>§diagnostics: Vec<Diagnostic>

Implementations§

Source§

impl Parser<'_>

Source

pub(crate) fn parse_heading(&mut self)

Source

fn flag_misplaced_heading_label(&mut self, start: usize, content_end: usize)

Emit MOS0048 when a heading carries a <label> token that is not the trailing element, so strip_trailing_label left it unrecognised and it would otherwise be swallowed into the heading text. The attached suggestion moves the label to the end of the line, where it registers as a real declaration.

Source

pub(crate) fn parse_paragraph(&mut self)

Source

fn heading_level_of_current_line(&self) -> Option<u8>

Returns Some(level) if the current line is a well-formed heading of =+ followed by ASCII whitespace.

Source§

impl Parser<'_>

Source

pub(crate) fn parse_directive_block(&mut self, kw: &'static str)

Source

fn parse_raw_block(&mut self, kw: &'static str)

Source

fn parse_set_block(&mut self)

Source

fn parse_call_block(&mut self, kw: &'static str)

Source

fn finish_directive_block( &mut self, line_start: usize, paren_pos: usize, kind: DirectiveKind, name: String, display_kw: &str, allow_positional: bool, )

Source

fn scan_balanced_parens(&self, start: usize) -> Option<usize>

Source

fn scan_long_raw_open(&self, start: usize) -> Option<(usize, usize)>

Source

fn scan_long_raw_close( &self, start: usize, eq_count: usize, ) -> Option<(usize, usize)>

Source

fn parse_set_body( &mut self, start: usize, end: usize, allow_positional: bool, ) -> Vec<SetArg>

Source

fn consume_arg_separator(&mut self, bytes: &[u8], i: usize, end: usize) -> usize

Source

fn parse_set_value(&mut self, i: &mut usize, end: usize) -> Option<SetValue>

Source

fn parse_string_value(&mut self, i: &mut usize, end: usize) -> Option<SetValue>

Source

fn parse_number_value(&mut self, i: &mut usize, end: usize) -> Option<SetValue>

Source§

impl Parser<'_>

Source

pub(crate) fn parse_inlines(&mut self, slice: &str, base: usize) -> Vec<Inline>

Tokenize slice (whose first byte sits at base in self.src) into inline runs. Backtick code and @label references are atomic; emphasis delimiters can nest into bold+italic text runs.

Source

fn parse_inline_segment( &mut self, slice: &str, base: usize, from: usize, style: InlineStyle, close: Option<Delimiter>, ) -> ParsedSegment

Source

fn flush_styled_text_with_pending( &self, out: &mut Vec<Inline>, slice: &str, base: usize, from: usize, to: usize, style: InlineStyle, pending: &mut String, pending_source_start: &mut Option<usize>, )

Flush slice[from..to] (possibly prefixed by buffered pending text from earlier escape expansions like \- → U+00AD) into a single styled-text inline. The span covers the full source range from the earliest byte that fed pending (or from when pending is empty) through to, so emitted inlines whose text includes expanded escapes still carry a span covering the original source bytes: including the consumed \- markers.

Source

fn flush_styled_text( &self, out: &mut Vec<Inline>, slice: &str, base: usize, from: usize, to: usize, style: InlineStyle, )

Source

fn warn_unterminated_delimiter( &mut self, slice: &str, base: usize, i: usize, delimiter: Delimiter, )

Source

fn closing_delimiter_suggestion( &self, slice: &str, base: usize, i: usize, delimiter: Delimiter, ) -> Option<Suggestion>

Source

fn code_closing_insertion( slice: &str, i: usize, close: Option<Delimiter>, ) -> Option<usize>

Source§

impl Parser<'_>

Source

pub(crate) fn parse_list(&mut self)

Consume a contiguous run of list-marker lines starting at the current position and push one or more Item::List entries onto self.items.

Source

fn collect_list_lines(&mut self) -> Vec<RawListLine>

Source

fn build_list_at(&mut self, raw: &[RawListLine], start: usize) -> (Item, usize)

Build one list from the run starting at raw[start].

Source§

impl<'a> Parser<'a>

Source

pub(crate) fn new(src: &'a str, file: &Path) -> Self

Source

pub(crate) fn run(self) -> ParseResult

Source

pub(crate) fn at_list_marker(&self) -> bool

Source

pub(crate) fn span(&self, start: usize, end: usize) -> SourceSpan

Source

pub(crate) fn starts_with(&self, prefix: &str) -> bool

Source

pub(crate) fn at_directive_keyword(&self) -> Option<&'static str>

Source

pub(crate) fn at_blank_line(&self) -> bool

Source

pub(crate) fn skip_line(&mut self)

Source

pub(crate) fn current_line_bounds(&self) -> (usize, usize, usize)

Source

pub(crate) fn line_bounds_from(&self, start: usize) -> (usize, usize, usize)

Source

pub(crate) fn warn( &self, def: &'static DiagnosticDef, message: &str, start: usize, end: usize, ) -> Diagnostic

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnsafeUnpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.