Crate rad[−][src]
Expand description
R4d(rad)
R4d is a text oriented macro processor that tries to solve inconveniences of well-known m4 macro processor.
R4d is provided as both binary and library. Binary includes all features of optional dependencies. Library doesn’t provide any features by default so you can set them manually.
Simple usage
Binary
rad input_file.txt -o out_file.txt
rad input_file.txt
printf '...text...' | rad -o out_file.txt
printf '...text...' | rad Library
use rad::RadError;
use rad::Processor;
use rad::MacroType;
// Every option is not mendatory
let processor = Processor::new()
.purge(true)
.greedy(true)
.silent(true)
.strict(true)
.custom_rules(Some(vec![pathbuf])) // Read from frozen rule files
.write_to_file(Some(pathbuf))? // default is stdout
.error_to_file(Some(pathbuf))? // default is stderr
.unix_new_line(true) // use unix new line for formatting
// Debugging options
.debug(true) // Turn on debug mode
.log(true) // Use logging to terminal
.interactive(true) // 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(vec![("test", test as MacroType)]);
// Add custom rules(in order of "name, args, body")
processor.add_custom_rules(vec![("test","a_src a_link","$a_src() -> $a_link()")]);
processor.from_string(r#"$define(test=Test)"#);
processor.from_stdin();
processor.from_file(&path);
processor.freeze_to_file(&path); // Create frozen file
processor.print_result(); // Print out warning and errors countDetailed r4d usage is illustrated in github page
Structs
Processor that parses(lexes) given input and print out to desginated output
Enums
R4d’s error type
Type Definitions
Type signature of basic macros