rustine 0.1.1

High-performance Gel syntax parser transforming to JSON/XML (Rust + PyO3)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use rustine::parser::{OutputFormat, Parser};

#[test]
fn test_intra_pattern_backreference() {
    let gel = r#"
grammar main:
match /A([a-z]{2})(\d+)/ $1 $2:
  act($1,$2)
"#;
    // Note: We approximate inline sequence: first regex capturing groups, then $1 then $2 backreferences.
    // Runtime input: "Aab42ab42" should match first part Aab42 then immediately attempt backref $1 ("ab") and $2 ("42").
    // Provide concatenated input accordingly.
    let parser = Parser::new(OutputFormat::Json);
    let out = parser.parse_and_run(gel, "main", "Aab42ab42").expect("exec failed");
    assert!(out.contains("act"), "{}", out);
    assert!(out.contains("\"ab\""), "{}", out);
    assert!(out.contains("\"42\""), "{}", out);
}