Skip to main content

Crate grift_macros

Crate grift_macros 

Source
Expand description

Procedural macros for grift_parser standard library

This crate provides the include_stdlib! macro which parses a .scm file containing function definitions and transforms them into the format expected by the define_stdlib! macro.

§Example

Given a file stdlib.scm:

;;; (map f lst) - Apply f to each element of lst
(define (map f lst) (if (null? lst) '() (cons (f (car lst)) (map f (cdr lst)))))

The macro:

include_stdlib!("stdlib.scm");

Expands to:

define_stdlib! {
    /// (map f lst) - Apply f to each element of lst
    Map("map", ["f", "lst"], "(if (null? lst) '() (cons (f (car lst)) (map f (cdr lst))))"),
}

Macros§

include_stdlib
Include a .scm file and transform it into define_stdlib! format.