Skip to main content

Module ast

Module ast 

Source
Expand description

Typed, read-only wrappers over the BibTeX CST.

Accessors expose syntax without assigning meaning to fields or entries.

Free functions provide the same operations for untyped SyntaxNode callers.

Re-exports§

pub use nodes::Entry;
pub use nodes::EntryType;
pub use nodes::Field;
pub use nodes::FieldName;
pub use nodes::Key;
pub use nodes::StringEntry;
pub use nodes::Value;

Modules§

nodes
Typed AstNode wrappers over the BibTeX CST, with syntactic accessors. The bib analog of crate::ast::nodes. Purely syntactic: they know nothing about what a field or entry means (AGENTS.md decisions #2, #10).

Traits§

AstNode
A typed wrapper over BibTeX CST nodes of a particular SyntaxKind.

Functions§

child
The first child node castable to N.
children
All child nodes castable to N, in source order.
cite_key
The cite key of a regular ENTRY and the byte range of its KEY node. None when the entry has no key (a recovery case) or the key is empty.
entry_type
The entry type of an ENTRY / STRING_ENTRY / … node — the word following @ (e.g. "article", "string"). None for a malformed entry with no ENTRY_TYPE child. Case is preserved; callers normalize.
field_name
The name of a FIELD (the text of its FIELD_NAME), or None if absent.
field_value
The VALUE node of a FIELD (the right-hand side of =), or None if absent.
fields
The FIELD children of an entry, in source order.
string_def_name
The macro name defined by a STRING_ENTRY (@string{ name = value }) and the byte range of its FIELD_NAME node. None for a malformed @string with no name = … field.
value_macro_uses
The bare-macro uses inside a VALUE: each LITERAL piece whose single token is a WORD (an unquoted, unbraced name) is an @string reference. A LITERAL wrapping a NUMBER is a literal number, not a macro use, and is skipped. Yields (name, range) with the range of the LITERAL piece.
value_text_cleaned
A field VALUE as plain display text: the node text, trimmed, with one layer of surrounding {…}/"…" removed and interior whitespace collapsed. Shared by the LSP hover/completion cards and the semantic model’s cached title/author facts.