Skip to main content

Crate vermouth

Crate vermouth 

Source
Expand description

Fortification against sin. A new kind of parser for procedural macros.

License Crates.io Downloads Docs

This crate aims to be a (not-quite) drop-in replacement for David Tolnay’s proc-macro2 and quote crates, and an opinionated alternative to syn. Opposing syn, this crate is designed around the philosophy that malformed input should be handled gracefully by procedural macros.

See our quote macro and the TokenQueue type for stream-building operations. See the Parser type for structural documentation on parsing.

The design of this crate is still in flux. Expect frequent breaking changes and temporary (🤞) API inconsistencies.

§Stable Features

§Unstable Features

Tread lightly. These features may require a nightly compiler, and enabling any of them in a crate’s dependencies explicitly voids all semver guarantees your crate may promise.

§MSRV

Note that while we don’t have an official policy with regards to our MSRV, expect it to be tied high for some time.

Modules§

attributesattributes
Provides utilities for parsing attributes.

Macros§

for_all_punct_seqs
Expands a macro with every distinct (supported) sequence of punctuation.
punct_decompose
Decomposes a larger token into a sequence of chars.
punct_patparse
Transforms a sequence of punctuation (e.g. && or ..=) into a PunctPat.
quotequote
Lazy quasi-quoting for Rust source.
verbatimquote
Quotes a single token (either a literal, an identifier, or a lifetime) in exactly the format supplied.

Structs§

Checkpointparse
A location in the stream of a Parser.
Diagnosticparse
The universal type used for parsing diagnostics.
Drquote
The dollar doctor. Evaluates to $. Useful for escaping.
Eosparse
Matches the end of the stream.
Expectedparse
Builds a diagnostic which represents some syntax which was expected.
Parserparse
A simple parser for Rust source which traverses TokenTrees.
ParserPosparse
A reference to a position within the internal stream of a Parser.
PunctPatparse
A pattern representing a sequence of Puncts.
Spanned
A simple wrapper which provides span information for any value.
TokenQueue
General purpose buffer for token composition.
Transcriberquote
A lazily-evaluated sequence of quoted tokens (what quote evaluates to).
Verbatim
A verbatim token. See the verbatim macro.

Enums§

DiagnosticLevelparse
The severity level of a custom Diagnostic.
VerbatimKind
What sort of token this Verbatim represents.

Traits§

IntoTokens
Methods for converting by-value into TokenQueue.
Parseparse
A common interface for parsing values from a Parser.
Patternparse
Performs simple pattern-matched parsing through a Parser object.
PushToken
A marker trait indicating that this IntoTokens implementation executes in amortized constant time.
RefToTokens
Marks a type as cheaply-clonable and suitable for an automatic &T: IntoTokens implementation.
ToSpan
Enables conversion between different span formats.
TokenTreeExt
A trait extending the behaviour of TokenTrees.

Type Aliases§

Resultparse
An alias for the standard library Result.