Skip to main content

Parser

Struct Parser 

Source
struct Parser<'a> {
    src: &'a str,
    bytes: &'a [u8],
    pos: usize,
}
Expand description

A byte cursor over the BibTeX source. All structural delimiters (@ { } " , =) and whitespace are ASCII, so scanning byte-by-byte never splits a multi-byte UTF-8 sequence and every recorded offset lands on a char boundary.

Fields§

§src: &'a str§bytes: &'a [u8]§pos: usize

Implementations§

Source§

impl<'a> Parser<'a>

Source

fn new(src: &'a str) -> Self

Source

fn at_end(&self) -> bool

Source

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

Source

fn bump(&mut self)

Source

fn skip_whitespace(&mut self)

Source

fn error_here(&self, kind: BibParseErrorKind) -> BibParseError

Source

fn error_at(&self, offset: usize, kind: BibParseErrorKind) -> BibParseError

Source

fn expect_byte( &mut self, byte: u8, kind: BibParseErrorKind, ) -> Result<(), BibParseError>

Consume byte if it is next; otherwise fail with kind.

Source

fn take_identifier(&mut self) -> Option<String>

Consume a run of identifier bytes, returning the lowercased text. Returns None (consuming nothing) when no identifier byte is next.

Source

fn parse_entry(&mut self) -> Result<ParsedEntry, BibParseError>

Source

fn parse_key(&mut self) -> Result<ParsedKey, BibParseError>

A citation key runs verbatim until a structural delimiter or whitespace. It must be non-empty.

Source

fn parse_fields( &mut self, fields: &mut BTreeMap<String, String>, ) -> Result<(), BibParseError>

Parse the comma-separated field list up to and including the closing }. At least one field is required after the key’s comma, so @type{key,} is rejected; a trailing comma after a field is accepted.

Source

fn parse_value(&mut self) -> Result<String, BibParseError>

Source

fn parse_braced(&mut self) -> Result<String, BibParseError>

Capture a {...} value, balancing nested braces by naive counting. The inner text is returned verbatim, braces and all.

Source

fn parse_quoted(&mut self) -> Result<String, BibParseError>

Capture a "..." value, reading to the next unescaped " outside braced TeX groups. This still stores raw text: the brace tracking only keeps common quoted TeX accents like {\"o} from ending the value.

Source

fn take_bare_value(&mut self) -> String

Capture an unquoted value (e.g. 1984) as a single token. The caller has already confirmed the first byte is a bare-value byte, so the result is non-empty. @string macros are not resolved.

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.