Macro essence_expr

Source
essence_expr!() { /* proc-macro */ }
Expand description

Parses an Essence expression into its corresponding Conjure AST at compile time.

§Input

The input can be one of the following:

  • The raw Essence tokens (essence_expr!(2 + 2))
  • A string literal (essence_expr!("2 + 2"))

The macro may reference variables in the current scope (called “metavars”) using the syntax &<name>. For example:

use conjure_essence_macros::essence_expr;
let x = 42;
essence_expr!(2 + &x);

§Expansion

If the input is valid Essence, expands to a valid AST constructor

§Note

Some characters (e.g. \) are valid Essence tokens, but not Rust tokens. If you encounter an error similar to:

rustc: unknown start of token: \

The workaround is to wrap the Essence code in a string literal (e.g. r"a /\ b").