Expand description
nom
-based parser-combinators for parsing the token stream in Rust
Attribute
s.
Usually used in a closure handed to
MetaItemMatch::match_extract
.
The benefit of using a combinator library such as nom
is not just that
it gives us boundaries for parsers that lets us (re)combine them, but also
that we get features that are annoying to implement (such as backtracking)
for free.
Re-exportsยง
pub extern crate nom;
Structsยง
- Just a newtype-wrapper for
CursorRef
so we can implement traits on it (specificallynom::InputLength
).
Functionsยง
- ann_
match_ ๐fn Parser for a [LabelAnnotation
] - Expect the next token to be an identifier with the value
s
- Expect the next token to have the token kind
k
. - Parse a
TokenTree::Delimited
with the delimiter characterdelim
, applying the subparserp
to the tokens in between the delimiters and return the result of the subparser. - Parse something dictionnary-like.
- Parse an identifier. Identifiers in annotations are similar to identifiers in rust in general, e.g. strings or word character, numbers and underscores.
- Parse an integer literal and return the integer.
- Parse bracket-delimited, comma-separated integers, e.g.
[1,2,3]
. - Parse a
TokenKind::Literal
if it has a specificLitKind
and return the payload of the literal. - match_
exception ๐Parser for anExceptionAnnotation
- one ๐Parse any one token, returning the token.
- Parse a single token that is not a subtree and return the token.
- otype_
ann_ ๐match Parser for the payload of the#[paralegal_flow::output_type(...)]
annotation. - refinements_
parser ๐A parser for annotation refinements.