8 releases
0.1.7 | Jul 26, 2024 |
---|---|
0.1.6 | Jul 14, 2024 |
0.1.5 | Apr 29, 2023 |
0.1.4 | Mar 19, 2023 |
0.1.0 | Feb 23, 2019 |
#46 in Procedural macros
56 downloads per month
Used in 3 crates
(2 directly)
62KB
1.5K
SLoC
A browser add-on for Firefox, Chrome and Edge
A library to generate syntax ("railroad") diagrams for Rust's macro_rules!()
.
Diagrams are generated as Scalable Vector Graphics, with layout-details controlled by customizable CSS.
As an example, given the definition of nom's method
macro_rules! method {
($name:ident<$a:ty>( $i:ty ) -> $o:ty, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty,$i:ty,$o:ty,$e:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty,$i:ty,$o:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty,$o:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty>( $i:ty ) -> $o:ty, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty,$i:ty,$o:ty,$e:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty,$i:ty,$o:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty,$o:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty>, $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty>( $i:ty ) -> $o:ty, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty,$i:ty,$o:ty,$e:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty,$i:ty,$o:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty,$o:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
($name:ident<$a:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty>( $i:ty ) -> $o:ty, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty,$i:ty,$o:ty,$e:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty,$i:ty,$o:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty,$o:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
(pub $name:ident<$a:ty>, mut $self_:ident, $submac:ident!( $($args:tt)* )) => { ... };
}
... the library generates an SVG which renders (using default CSS) as
To generate the examples shown here, run
cargo run --example various
which will output some html-files to /examples
; Feel free to hack on the demos in /examples/various.rs
.
Examples
- Live demo (code)
- The macros from
nom-4.1.1
as diagrams - Some of the macros from the standard library as diagrams
- The macros from
syn-0.14
as diagrams - Some macros from various crates, including
bitflags
,quickcheck
andcfg-if
, as diagrams
Dependencies
~1.4–2.6MB
~49K SLoC