R4d (Rad)
R4d is a text oriented macro prosessor made with rust.
NOTE
R4d is in very early stage, so there might be lots of undetected bugs. Fast implementaiton was my priorites, thus optimization has had a least consideration for the time.
When it gets 1.0?
R4d's will reach 1.0 only when followings are resolved.
- Consistent parenthesis rules
- Absence of critical bugs
- No possiblity of basic macro changes
Usage
As a binary
# Usage : rad [OPTIONS] [FILE]...
# Read from file and save to file
# Read from file and print to stdout
# Read from standard input and print to file
|
# Read from stdin and print to stdout
|
# Use following options to decide error behaviours
# default is stderr
# Use following options to decide deubbing behaviours
# default is not to debug
# Other flags
# Freeze(zip to binary) rules to a single file
# Melt a file and use in processing
Type -h or --help to see full options.
As a library
Cargo.toml
[]
= { = "0.5", = ["full"] }
# Other available features are
# "evalexpr", "chrono", "lipsum", "csv", "debug"
# evalexpr - "eval" macro
# chrono - "date", "time" macro
# lipsum - "lipsum" macro
# csv - "from", "table" macro
# debug - Enable debug method
rust file
use RadError;
use Processor;
use MacroType;
// Every option is not mendatory
let processor = new
.purge
.greedy
.silent
.strict
.custom_rules // Read from frozen rule files
.write_to_file? // default is stdout
.error_to_file? // default is stderr
.unix_new_line // use unix new line for formatting
// Debugging options
.debug // Turn on debug mode
.log // Use logging to terminal
.interactive // Use interactive mode
// Create unreferenced instance
.build;
// Use Processor::empty() instead of Processor::new()
// if you don't want any default macros
// Add basic rules(= register functions)
processor.add_basic_rules;
// Add custom rules(in order of "name, args, body")
processor.add_custom_rules;
processor.from_string;
processor.from_stdin;
processor.from_file;
processor.freeze_to_file; // Create frozen file
processor.print_result; // Print out warning and errors count
Syntax
How to debug
Goal
R4d aims to be a modern alternative to m4 processor, which means
- No trivial m4 quotes for macro definition
- Explicit rule for macro definition and usage so that de facto underscore rule is not necessary
- Easier binding with other programming languages(Rust's c binding)
- Enable combination of file stream and stdout
- As expressive as current m4 macro processor