Crate lead_lang_macros

Source
Expand description
A few rules:
  • The variables are only valid till the function execution.
  • Storage of LeadLang variable data (except the moved ones) requires cloning.
  • You shouldn’t store the mutable or immutable reference of a variable.

Got to define function

§Simple LeadLang Package

use interpreter::{generate, module, pkg_name};
use lead_lang_macros::{define, methods};
 
use interpreter::BufValue;
 
module! {
  Module1,
  pkg_name! { "Module" },
  methods! {
    foo
  }
}
 
generate! {
  Module1
}
 
#[define((
  desc: "Prints a variable",
  notes: Some("Optional Note"),
  params: [
   // "my-custom-regex, see example below",
   r"\$[a-z0-9_]*" // This is a regex of a lead variable
  ],
  returns: Some("%null"), // %null means that it returns nothing
  usage: [
   (
    desc: "Prints $hello",
    code: "print $hello"
   )
  ]
  root: Some("MyNewRT"), // This is a method on a RuntimeValue
))]
fn foo(var: &BufValue) {
  println!("{}", var.display());
}

Macros§

define_prototypes
Define the Package’s prototypes
methods
Define the Module Methods
runtime_value_methods
Define the Methods of the RuntimeValue

Attribute Macros§

define
Defines a callable lead function
gendoc
This is not recommended to be used