Attributes
The #[derive(Logos)]
procedural macro recognizes three different attribute
names.
#[logos]
is the main attribute which can be attached to theenum
of your token definition. It allows you to define theExtras
associated type in order to put custom state into theLexer
, or declare concrete types for generic type parameters, if yourenum
uses such. It is strictly optional. It also allows to define parts that must be skipped by the lexer, the error type, or regex subpatterns.- And most importantly the
#[token]
and#[regex]
attributes. Those allow you to define patterns to match against the input, either plain text strings with#[token]
, or using regular expression syntax with#[regex]
. Aside from that difference, they are equivalent, and any extra arguments you can pass to one, you can pass to the other.