Expand description
All magic happens here. A module that generates interpreters for SimpleX chat command syntax.
To add support for another language it’s sufficient to implement the
SyntaxInterpreter
trait and then use the following builder pattern:
ⓘ
use simploxide_bindgen::syntax::binding::BindExt;
//..
let interpret_method = syntax_str
.bind(YourInterpreter::new(api_type))
// Allows to define, e.g. a function method before the interpreter body
.prelude(|intrp, out| {
bufwriteln!(out, :> 4, "def interpret(self):");
intrp.offset = 8;
})
.generate()?;
Structs§
- Enum
Interpreter Err - Generator
- A helper type that consumes the interpreter and generates the whole code block with it. The
block itself is generated with
prelude
andpostlude
callbacks. E.g. for Python this snippet can be used to generate the interpret method: - Record
Context Data
Enums§
Traits§
- BindExt
- This trait exists to provide syntactic sugar to create the generator builder from str:
- Interpretable
- Represents a type with a syntax that can be interpreted as a SimpleX command. The impl should return Ok(None) when the syntax string is empty or return full implementation of the following trait:
- Syntax
Interpreter - Implement
interpret_
methods and use the providedSelf::interpret_syntax
to generate the whole interpreter body from the syntax.
Type Aliases§
- Deferred
Generation - It’s just a simple closure that provides (interpreter, out_buffer) in its arguments and allows borrowing the outside context.
- Syntax
Interpreter Result