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: usizeImplementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
fn new(src: &'a str) -> Self
fn at_end(&self) -> bool
fn peek(&self) -> Option<u8>
fn bump(&mut self)
fn skip_whitespace(&mut self)
fn error_here(&self, kind: BibParseErrorKind) -> BibParseError
fn error_at(&self, offset: usize, kind: BibParseErrorKind) -> BibParseError
Sourcefn expect_byte(
&mut self,
byte: u8,
kind: BibParseErrorKind,
) -> Result<(), BibParseError>
fn expect_byte( &mut self, byte: u8, kind: BibParseErrorKind, ) -> Result<(), BibParseError>
Consume byte if it is next; otherwise fail with kind.
Sourcefn take_identifier(&mut self) -> Option<String>
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.
fn parse_entry(&mut self) -> Result<ParsedEntry, BibParseError>
Sourcefn parse_key(&mut self) -> Result<ParsedKey, BibParseError>
fn parse_key(&mut self) -> Result<ParsedKey, BibParseError>
A citation key runs verbatim until a structural delimiter or whitespace. It must be non-empty.
Sourcefn parse_fields(
&mut self,
fields: &mut BTreeMap<String, String>,
) -> Result<(), BibParseError>
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.
fn parse_value(&mut self) -> Result<String, BibParseError>
Sourcefn parse_braced(&mut self) -> Result<String, BibParseError>
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.
Sourcefn parse_quoted(&mut self) -> Result<String, BibParseError>
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.
Sourcefn take_bare_value(&mut self) -> String
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.