pub struct SetOfRules(_);
Expand description

The set of rules to be parsed Any rule has a name A rule can be registered just once The starting rule is main

Implementations§

Initialize a set of rules with a hashmap of <String, Expression> In general, is better to use the rules! macro

As this is a dynamic parser, it is necessary to add rules on runtime.

This method, will take the owner ship, and will return itself

In this way, you don’t need to declare mutable vars. You could need recursion in some cases

To add several rules at once, look for merge

#[macro_use]  extern crate dynparser;
use dynparser::parse;

fn main() {
    let rules = rules!{
       "main"   =>  and!{
                        rep!(lit!("a"), 1, 5),
                        ref_rule!("rule2")
                    }
    };

    let rules = rules.add("rule2", lit!("bcd"));

    assert!(parse("aabcd", &rules).is_ok())
}

As this is a dynamic parser, it is necessary to add rules on runtime.

This method, will take the owner ship, and will return itself

In this way, you don’t need to declare mutable vars. You could need recursion in some cases

It will add the rules from the parameter

#[macro_use]  extern crate dynparser;
use dynparser::parse;

fn main() {
    let rules = rules!{
       "main"   =>  and!{
                        rep!(lit!("a"), 1, 5),
                        ref_rule!("rule2")
                    }
    };

    let rules = rules.merge(rules!{"rule2" => lit!("bcd")});

    assert!(parse("aabcd", &rules).is_ok())
}

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.