JunSuzukiJapan/macro-lisp
Lisp-like DSL for Rust language
{ "createdAt": "2016-12-18T10:15:39Z", "defaultBranch": "master", "description": "Lisp-like DSL for Rust language", "fullName": "JunSuzukiJapan/macro-lisp", "homepage": null, "language": "Rust", "name": "macro-lisp", "pushedAt": "2023-06-24T02:06:52Z", "stargazersCount": 435, "topics": [], "updatedAt": "2025-11-22T15:38:41Z", "url": "https://github.com/JunSuzukiJapan/macro-lisp"}macro-lisp
Section titled “macro-lisp”Lisp-like DSL for Rust language.
[
]!(LICENSE)
Installation
Section titled “Installation”include the following in your Cargo.toml file:
[dependencies]macro_lisp="0.2.0"And then import the library using:
extern crate macro_lisp;
use macro_lisp::lisp;Examples
Section titled “Examples”factorial
Section titled “factorial”extern crate macro_lisp;
use macro_lisp::lisp;
lisp!(defun factorial ((n i32)) i32 (if (<= n 1) 1 (* n (factorial (- n 1)))));
lisp!(defun main () () (defconstant num (factorial 10)) (println "10! = {}" num));extern crate macro_lisp;
use macro_lisp::lisp;
lisp!(use std::env);lisp!(use std::process::exit);
lisp!(defun is_whitespace ((b u8)) bool (match b (0x20 | 0x09 | 0x85 | 0x0a | 0x0b | 0x0c | 0x0d => (true)) (_ => (false) )));
lisp!(defun main () () (defconstant (args Vec<String>) env::args().collect()) (if (< (len args) 2) (progn (println "usage: wc file") (exit 0)))
(defvar char_count 0) (defvar word_count 0) (defvar line_count 0) (defvar in_word false)
(defconstant path &args[1]) (with-input-from-file (file path) (doiter (byte file.bytes()) (incf char_count)
(defconstant b byte.unwrap()) (if (== b 0x0a) (incf line_count))
(if in_word (if (is_whitespace b) (setf in_word false)) (if (! (is_whitespace b)) (progn (setf in_word true) (incf word_count))))))
(println "{:>10} {:>10} {:>10} {}" line_count word_count char_count path));License
Section titled “License”[MIT]!(LICENSE)