expr

Macro expr 

Source
macro_rules! expr {
    (( $($inner:tt)* )) => { ... };
    (! $e:ident) => { ... };
    (! ( $($inner:tt)* )) => { ... };
    ($a:ident + $b:ident) => { ... };
    ($a:ident * $b:ident) => { ... };
    ($a:ident * $b:ident + $c:ident * $d:ident * $e:ident) => { ... };
    ($a:ident * $b:ident + $c:ident * $d:ident) => { ... };
    ($a:ident * $b:ident + ! $c:ident * $d:ident) => { ... };
    ($a:ident * $b:ident + $c:ident * ! $d:ident) => { ... };
    ($a:ident * $b:ident + ! $c:ident * ! $d:ident) => { ... };
    ($a:ident * ! $b:ident + ! $c:ident * $d:ident) => { ... };
    ($a:ident * ! $b:ident + $c:ident * ! $d:ident) => { ... };
    ($a:ident * ! $b:ident + ! $c:ident * ! $d:ident) => { ... };
    (! $a:ident * $b:ident + $c:ident * ! $d:ident) => { ... };
    (! $a:ident * $b:ident + ! $c:ident * $d:ident) => { ... };
    (! $a:ident * $b:ident + ! $c:ident * ! $d:ident) => { ... };
    (! $a:ident * ! $b:ident + $c:ident * $d:ident) => { ... };
    (! $a:ident * ! $b:ident + $c:ident * ! $d:ident) => { ... };
    (! $a:ident * ! $b:ident + ! $c:ident * $d:ident) => { ... };
    (! $a:ident * ! $b:ident + ! $c:ident * ! $d:ident) => { ... };
    ($a:ident * $b:ident * $c:ident) => { ... };
    (( $($a:tt)* ) * $b:ident) => { ... };
    ($a:ident * ( $($b:tt)* )) => { ... };
    (( $($a:tt)* ) * ( $($b:tt)* )) => { ... };
    (! ( $($a:tt)* ) * $b:ident) => { ... };
    ($a:ident * ! ( $($b:tt)* )) => { ... };
    (( $($a:tt)* ) * ! $b:ident) => { ... };
    (! $a:ident * ( $($b:tt)* )) => { ... };
    (( $($a:tt)* ) + $b:ident) => { ... };
    ($a:ident + ( $($b:tt)* )) => { ... };
    (( $($a:tt)* ) + ( $($b:tt)* )) => { ... };
    (! ( $($a:tt)* ) + $b:ident) => { ... };
    ($a:ident + ! ( $($b:tt)* )) => { ... };
    (( $($a:tt)* ) + ! $b:ident) => { ... };
    (! $a:ident + ( $($b:tt)* )) => { ... };
    ($e:ident) => { ... };
}
Expand description

Macro for building boolean expressions with clean syntax

Automatically inserts borrows so you can write expr!(a * b + !a * !b) instead of &a * &b + &(!&a) * &(!&b).

Supports:

  • * for AND
  • + for OR
  • ! for NOT
  • Parentheses for grouping

ยงExamples

use espresso_logic::{BoolExpr, expr};

let a = BoolExpr::variable("a");
let b = BoolExpr::variable("b");

let xnor = expr!(a * b + !a * !b);  // Clean syntax!