R4d is a text oriented macro prosessor made with rust.
R4d is in very early stage, so there might be lots of undetected bugs and changes will occur fast.
Currently only binary exists.
```bash
rad inputfile.txt -o outfile.txt
rad input_file.txt
printf '...text...' | rad -o out_file.txt
printf '...text...' | rad
rad -e FileToWriteError.txt # Log error to file rad -s # Suppress error ```
Type -h
or --help
to see full options.
Definition syntax is similar to macro invocation but requires a specific form to sucessfully register the macro.
$define(name,arg1 arg2,$arg1() $arg2())
You can simply bind the value to macro with =
.
$define(v_name=Simon creek)
which is technically same with
$define(v_name,,Simon creek)
Prefix is a dollar sign($)
$define(macro_name,a1 a2,$a1() $a2())
$macro_name(arg1, arg2)
Macro can be invoked anywhere after the definition.
My name is $macro_name(Simon, Creek).
converts to
My name is Simon Creek.
Special argument $:
is used for iterated value.
$foreach("John,Simon,Jane",Name : $:
)
$forloop("5,10",$:th
)
converts to
```
Name : John
Name : Simon
Name : Jane
5th 6th 7th 8th 9th 10th
```
NOTE
An unbalanced right parenthesis ends macro invocation and a non-double-quoted
comma will change the number or content of arguments. If desirable content
includes unbalanced right parentheses or commas, enclose the body with double
quotes. Use escaped form of double quote, \"
to use literal comma inside
double quotes.
$define(order=first,second,third)
$order()
The result is
first
To include commas you need to enclose with double quotes
$define(order="first,second,third")
$order()
converts to
first,second,third
=> This behaviour might change in the future.
Literal input
``` $define(test,a,$a())
"This text prints as it is", but it should be only called on main level ))) ```
Piping
``` $define(test,a,$a()) $test|(I'm going to be used by a pipe macro) $trim($repeat(2,$-()
I'm going to be used by a pipe macro I'm going to be used by a pipe macro ```
R4d aims to be a modern alternative to m4 processor, which means
Macros
Features