Function flexi_parse::parse_string

source ·
pub fn parse_string<T: Parse>(source: String) -> Result<T>
Expand description

Scans and parses the given string into the syntax tree node T.

This function ignores all whitespace.

Examples found in repository?
examples/calc.rs (line 97)
96
97
98
99
fn main() {
    let expr: Expr = pretty_unwrap(parse_string(env::args().nth(1).expect("expect expression")));
    println!("{}", expr.eval());
}
More examples
Hide additional examples
examples/lox.rs (lines 627-639)
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
fn main() {
    let _ast: Ast = pretty_unwrap(parse_string(
        "
        var x = 5;
        var y = \"hello\";
        x = 6;
        y = 4.0;

        fun add(x, y) {
            return x + y;
        }
    "
        .to_string(),
    ));
}