R4d aims to be a modern m4 alternative, which means

No trivial quotes for macro definition

R4d (Rad)

  • Explicit rule for macro definition and usage so that de facto underscore rule is not necessary
  • Easier binding with other programming languages
  • Enable combination of file stream and stdout
  • As expressive as current m4 macro processor


No library

I tried pest, however I didn't like the limitation of the syntax. Plus, other parser generator libraries recommend using custom parser for programming languages.

The reason stock library doesn't fit well comes from the expressiveness and complexity of m4 macro processor. Technical difficulties are followed,

  • M4 syntax allows string literal in its file which is not allowed in many programming languages
  • M4 allows macro definition in any location of given input, even among string literal
  • M4 allows shell execution in any location of given input.

Thus there are too much caveats to with exsiting library that can differentiate string literal and macro definitio and macro usages at the same time.

Syntax (This is a plan, not the real specification)

Macro definition

Definition is also a macro.

Definition should start from the first of the line

// Define with json form
$define({name: "", args: [""], contents: [""]})
// Define with simple form

Macro inovokation

Prefix(default is $, dollar sign) can be changed by end user.

$macro_name(arg1, arg2)

Macro can be invoked anywhere

My name is $macro_name(Simon, Creek).

In-built macros

  • Include
  • Foreach, for loop

Find the latest versions by id

3.0.0-rc.0 - Jun 16, 2022


Refer docs for detailed changes.

2.1.2 - May 21, 2022

I was busy doing personal jobs and seldom updated releases.


  1. Enabled Include with optional argument for raw include.
  2. New macros
  • exec
  • ieval
  1. Relocated macros
  • from
  1. Changed for loop behaviour. This is backward compatible with feature, disable default features for compatibility. Previous implementation will be removed from 3.0
  2. Disabled read macro because there are very little gain over include. Though it is still included, but can be removed any time soon.
  3. Many bug fixes

2.0.0 - Mar 11, 2022

2.0 updates

1.8.0-rc.1 - Feb 20, 2022

GLIBC version 2.33

1.7 - Feb 02, 2022

New basic macros

  • min
  • max
  • ceil
  • floor
  • prec
  • cap
  • low
  • num
  • rev
  • evalk
  • tarray
  • hms
  • dropcsv
  • relay
  • halt
  • enl


Redir is getting deprecated in favor of relay and halt macro

Bug fix

Fixed where tail, head, and strip was not respeting utf-8 formatted text.

1.6 - Jan 22, 2022

New basic macros

- head
- headl
- tail
- taill
- strip
- stripl
- Grep  
- Index 
- Sort 
- Sortl 
- Fold 
- Foldl 
- Count
- Countw
- Countl

1.5.0 - Jan 18, 2022

New macros

  • pipeto
  • sep
  • dnl
  • update(storage)
  • extract(storage)
  • regcsv(cindex)
  • query(cindex)

Bug fixes

  • Wrong clap arguments were fixed

1.4.1 - Dec 28, 2021

  • New basic macros

    • Panic
    • Escape and exit
    • Triml
    • wrap
  • Added new signature flag into crates.io

1.3.0 - Dec 13, 2021


  • Signature map method (Not yet in lib, but can be compiled from source)
  • Migrated from mut reference builder to "move" builder pattern. Thus no need for method anymore
  • Better behaviour of debugger console
  • Changed default debugger prompt
  • Fixed a bug where sand-boxing was not working.
  • Fixed a collision among local arguments name
  • Fixed a macro attribute bug( rather unintended behaviour)

1.2.1 - Nov 23, 2021

1.2.1 changes

  • Missing re-exports of DiffOption and HookType which is an oopsie...
  • Fixed a strange bug where compiler was not respecting optional feature bound variables

1.2.0 changes

  • Deprecating global in favor of keyword macro

  • Deprecating bind in favor of keyword macro

  • New basic macros : Declare macros

  • Custom special character

  • Comment type addition

  • Hook macro for macro and character

  • Static custom rules

  • Added diff only changed option

  • Bug fix: Default comment behaviour is start

  • Bug fix: Non sufficient macro invocation doesn't return whole string

  • Bug fix: Assert result was not printed when there was no error at all.

1.1.1 - Nov 04, 2021

Glibc version

2.33 version was built in arch linux while 2.31 version was built with ubuntu 20.04

1.1.1 quick fix

  • Chomp was completely broken in windows version, it was fixed.

1.1.0 Changes

  • Added comment support as opt in
  • New basic macros
    • ifenvel
    • ifdefel
    • abs
    • arr
    • envset
  • Newline consistency in chomp macro
  • Fixed a bug where unterminated macros inside arguments were discard without proper handling.

1.0.0 - Oct 19, 2021

There are few things left for further improvements and I'm getting less time to put into open source projects thus I'm setting the version number to 1.0.

From 1.0 there will be no functional improvements or features, but only bug fixes and maybe some code refactoring.

Terms between every release will be that of "normal" programs. Every chagnes will be updated to dev branch first and will be updated to master branch periodically.

0.11.4 - Oct 15, 2021

  • Yield diff printed as error
  • Debug logging as error
  • Segregated debugger module
  • Fixed a panicking bug when debugging from macro

0.11.3 - Oct 14, 2021

  • Fixed a bug that keyword macros were not properly respecting orders
  • Logging also prints macro attributes
  • Made code clearer

0.11.1 - Oct 12, 2021

  • Fixed include macro was not respecting define order
  • Added a new macro that writes to buffer without saving.

0.11.0 - Oct 11, 2021

  • Fixed empty name's strange behaviour
  • Made get-pipe doesn't clear pipe
  • Basic macro syntax changes
    • From syntax similar to table macro
    • ifdef works similar to if and ifelse
    • Changed path syntax
  • New basic(keyword) macros
    • ifenv
    • global
    • repl
  • Made strict mode behaviours
    • Now strict mode is default and should be disabled with lenient option
    • Strict mode prohibits definition overriding
  • Cli option changes according to previous changes

0.10.1 - Oct 05, 2021

  • Include respects currently set file
  • Fixed set file bug where file was not properly set
  • Made env error ergnomic
  • Added some env variables (RAD_FILE, RAD_FILE_DIR)
  • New basic macros
    • Name
    • Parent
    • Paths
  • Remove unnecessary hashamp clone
  • Added keyword macros
  • Refactor sandbox environment

0.9.0 - Sep 26, 2021

  • Made basic macro error forgivable by user flag or builder function
  • Added color support for pager
  • Added closure based basic macro addition
  • Made binary print permission by default
  • Made permission error panicking
  • Added color support for panicking errors
  • Fixed error option was not actually working, wow...

0.8.1 - Sep 19, 2021

  • Added permission logics
  • Some bug fixes
  • Made colored optional
  • Detailed usage in docs.rs
  • Made escape rule consistent

0.7.2 - Sep 19, 2021

  • Exposed addition of basic macros and custom macros
  • Added lots of documentation codes for future "me"

0.7.1 - Sep 18, 2021

  • Complete debugger feature (There are probably some bugs)
  • Fixed incomplete error logging information (This part was especially tricky because I made no AST interpreter...)

0.7.0 - Sep 16, 2021

  • Oops, I skipped 0.6.0 by mistake.
  • Applied same logic as for loop into if macros
  • New debug flag logics (lines, log)

0.5.0 - Sep 03, 2021

  • there are helluva changes included
  • Strict option
  • Lib support

0.4.6 - Aug 31, 2021

  • Temp refactor
  • Result print

0.4.5 - Aug 30, 2021

  • Added bind macro
  • Fixed include local refresh bug
  • Made Error messages more helpful
  • Added trim attirbutes

0.4.4 - Aug 29, 2021

  • Some bug fixes
  • Some feature changes I don't remember.

0.4.0 - Aug 26, 2021

  • Changed literal rule + added literal attribute
  • Added new macros
    • env macro
    • path macro

0.3.3 - Aug 26, 2021

  • Added greed option to enable always greedy macro invocation
  • Removed unnecessary print lines

0.3.2 - Aug 24, 2021

  • Added purge mode
  • Fixed a bug

0.3.0 - Aug 23, 2021

  • Freeze file support with and flag
  • Unbalanced parenthesis warning message
  • Added greedy rule

Information - Updated Jun 22, 2022

Stars: 4
Forks: 0
Issues: 0

Repositories & Extras

macroquad is a simple and easy to use game library for Rust programming language, heavily...

macroquad is a simple and easy to use game library for Rust programming language, heavily inspired by docs

macroquad is a simple and easy to use game library for Rust programming language, heavily...


This library contains a procedural macro that reads a GraphQL schema file, and generates the


A Micro Transport Protocol

library implemented in Rust

A Micro Transport Protocol


Rouille, a Rust web micro-framework

Rouille is a micro-web-framework library

Rouille, a Rust web micro-framework

A library that can fetch all sorts of system information, super-duper fast!

Linux • macOS • Windows • NetBSD • Android • OpenWrt

A library that can fetch all sorts of system information, super-duper fast!

Rust library to manipulate file system access control lists (ACL) on macOS, Linux, and FreeBSD

This module provides two high level functions, getfacl and setfacl

Rust library to manipulate file system access control lists (ACL) on macOS, Linux, and FreeBSD

btleplug is an async Rust BLE library, supporting Windows 10, macOS, Linux, and possibly iOS...

btleplug is an async Rust BLE library, supporting Windows 10, macOS, Linux, and possibly iOS and

btleplug is an async Rust BLE library, supporting Windows 10, macOS, Linux, and possibly iOS...
Facebook Instagram Twitter GitHub Dribbble