romulus/
lib.rs

1//! Romulus is a text processing language similar to sed
2//!
3//! Here is an example program which process the output of ifconfig
4//! ```text
5//! /^(?P<inter>[a-zA-Z0-9]+): /,/^[a-zA-Z0-9]+:/ {
6//!   /inet (?P<ip>[0-9]{1,3}(\.[0-9]{1,3}){3})/ {
7//!     print("${inter}: ${ip}")
8//!   }
9//!
10//!   /inet6 (?P<ip>[a-fA-F0-9]{0,4}(:[a-fA-F0-9]{0,4}){0,8})/ {
11//!     print("${inter}: ${ip}")
12//!   }
13//! }
14//! ```
15//!
16
17#![deny(missing_docs)]
18
19/// A macro that expands to the proper line ending character sequence
20/// for operating system
21#[macro_export]
22macro_rules! nl {
23    () => {
24        if cfg!(not(target_os = "windows")) {
25            "\n"
26        } else {
27            "\r\n"
28        }
29    };
30}
31
32/// A macro that expands to a colored output if romulus is compiled
33/// with color support
34#[macro_export]
35macro_rules! color {
36    ($color: expr, $msg: expr) => {
37        if cfg!(feature = "color") {
38            $color.paint($msg.to_string()).to_string()
39        } else {
40            $msg.to_string()
41        }
42    };
43}
44
45#[macro_use]
46extern crate lazy_static;
47
48mod interpreter;
49
50mod ast;
51mod features;
52mod lex;
53mod lint;
54mod runtime;
55
56pub use features::*;
57pub use interpreter::{Builder, Interpreter};