pest::grammar!
[−]
[src]
macro_rules! grammar { (@conv $slf:ident ( ( $( $head:tt )* ) $( $tail:tt )* ) ( $( $optail:tt )* ) ( $( $output:tt )* )) => { ... }; (@conv $slf:ident ( @rp $( $tail:tt )* ) ( @lp $( $optail:tt )* ) ( $( $output:tt )* )) => { ... }; (@conv $slf:ident ( @rp $( $tail:tt )* ) ( $op:tt $( $optail:tt )* ) ( $( $output:tt )* )) => { ... }; (@conv $slf:ident ( ~ $( $tail:tt )* ) ( ~ $( $optail:tt )* ) ( $( $output:tt )* )) => { ... }; (@conv $slf:ident ( ~ $( $tail:tt )* ) ( $( $optail:tt )* ) $output:tt) => { ... }; (@conv $slf:ident ( | $( $tail:tt )* ) ( ~ $( $optail:tt )* ) ( $( $output:tt )* )) => { ... }; (@conv $slf:ident ( | $( $tail:tt )* ) ( | $( $optail:tt )* ) ( $( $output:tt )* )) => { ... }; (@conv $slf:ident ( | $( $tail:tt )* ) ( $( $optail:tt )* ) $output:tt) => { ... }; (@conv $slf:ident ( $head:tt $( $tail:tt )* ) $ops:tt ( $( $output:tt )* )) => { ... }; (@conv $slf:ident () () ( $( $output:tt )* )) => { ... }; (@conv $slf:ident () ( $op:tt $( $optail:tt )* ) ( $( $output:tt )* )) => { ... }; (@mtc $slf:ident (( $exp:expr ))) => { ... }; (@mtc $slf:ident [ $str:expr ]) => { ... }; (@mtc $slf:ident $rule:ident) => { ... }; (@process $_slf:ident (( $result:expr )) ()) => { ... }; (@process $slf:ident ( $b:tt $a:tt $( $tail:tt )* ) ( ~ $( $optail:tt )* )) => { ... }; (@process $slf:ident ( $b:tt $a:tt $( $tail:tt )* ) ( | $( $optail:tt )* )) => { ... }; (@process $slf:ident () ( $single:tt )) => { ... }; (@process $slf:ident ( $( $optail:tt )* ) ( $head:tt $( $tail:tt )* )) => { ... }; ( $( $name:ident = { $( $ts:tt )* } )* ) => { ... }; }
A macro
that defines each rule as a method on a Parser
.
Examples
impl_rdp!(MyRdp); impl MyRdp { grammar! { exp = { paren ~ exp | [""] } paren = { ["("] ~ exp ~ [")"] } } } let mut parser = MyRdp::new(Box::new(StringInput::new("(())((())())()"))); assert!(parser.exp()); assert!(parser.end());