Skip to main content

Module ast

Module ast 

Source
Expand description

Typed, read-only wrappers over the CST.

Accessors are positional and do not assign meaning or arity to commands.

Free functions provide the same operations for untyped SyntaxNode callers.

Re-exports§

pub use nodes::Begin;
pub use nodes::Command;
pub use nodes::Conditional;
pub use nodes::ConditionalBranch;
pub use nodes::End;
pub use nodes::Environment;
pub use nodes::Group;
pub use nodes::NameGroup;
pub use nodes::Optional;
pub use tokens::ControlWord;

Modules§

nodes
Typed AstNode wrappers over the generic CST.
tokens
Typed AstToken wrappers over CST tokens. Only ControlWord exists today — the rest of the lexer’s tokens (L_BRACE, WORD, trivia, …) are matched raw by the formatter’s token loops, which is idiomatic and should stay that way. Add a wrapper here only when a token grows a named accessor consumer.

Traits§

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

Functions§

child
Returns the first child node castable to N.
child_token
The first child token castable to T.
children
All child nodes castable to N, in source order.
command_name
The control-word name of a COMMAND node (the leading \ stripped), or None for a control symbol.
control_word_range
The range of a COMMAND node’s leading CONTROL_WORD token, or None for a control symbol.
environment_name
The environment name of a BEGIN or END node — the text of its NAME_GROUP child, braces dropped.
environment_name_range
The byte range of the environment name inside a BEGIN or END node’s NAME_GROUP.
first_group_range
The byte range of command spanning its control word through the end of its first {…} group; the full command range when the first group is absent.
group_command_name
The control-word name of a single COMMAND wrapped in group. A braced l3doc v-type name argument (\begin{macro}{\foo}) captures its content as one opaque VERB token instead of a COMMAND (issue #60); a control-word- shaped VERB (\ + letters, nothing else) reads as the same name.
group_inner_source
The raw inner source of group with its outer braces dropped, nested braces kept.
nth_group
The n-th GROUP argument node of command, if present.
nth_group_inner
The byte range of the content inside the n-th GROUP argument together with that inner text.
nth_group_text
The literal text inside the n-th GROUP argument of command, braces dropped.