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 [ & $head:tt $( $tail:tt )* ] [ $( $optail:tt )* ] $output:tt ) => { ... }; ( @conv $slf:ident [ ! $head:tt $( $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 [ | $( $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 [ $left:tt .. $right:tt ]) => { ... }; ( @mtc $slf:ident [ $left:expr, $right: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 [ $a:tt $( $tail:tt )* ] [ * $( $optail:tt )* ] ) => { ... }; ( @process $slf:ident [ $a:tt $( $tail:tt )* ] [ + $( $optail:tt )* ] ) => { ... }; ( @process $slf:ident [ $a:tt $( $tail:tt )* ] [ ? $( $optail:tt )* ] ) => { ... }; ( @process $slf:ident [ $a:tt $( $tail:tt )* ] [ _pres $( $optail:tt )* ] ) => { ... }; ( @process $slf:ident [ $a:tt $( $tail:tt )* ] [ _abs $( $optail:tt )* ] ) => { ... }; ( @process $slf:ident [] [ $single:tt ] ) => { ... }; ( @process $slf:ident [ $( $optail:tt )* ] [ $head:tt $( $tail:tt )* ] ) => { ... }; ( @skip ws $_slf:ident ) => { ... }; ( @skip $_name:ident $slf:ident ) => { ... }; () => { ... }; ( $name:ident = { $( $ts:tt )* } $( $tail:tt )* ) => { ... }; ( $name:ident = _{ $( $ts:tt )* } $( $tail:tt )* ) => { ... }; }
A macro
that defines each rule as a method on a Parser
. Rules starting with an uderscore
will not be placed into the queue.
ws
is a special rules used exclusively for white-space.
Examples
impl_rdp! { grammar! { exp = _{ paren ~ exp | [""] } paren = { ["("] ~ exp ~ [")"] } } } let mut parser = Rdp::new(Box::new(StringInput::new("(())((())())()"))); assert!(parser.exp()); assert!(parser.end());