pub struct Grammar { /* fields omitted */ }
A compiled collection of rules ready for the building of a
pidgin::Matcher
or for use in the definition of a new rule.
You do not build new Grammar
s directly. Rather, the compile
or grammar
method of a Pidgin
produces them for you.
Compiles a Matcher
based on the Grammar
's rules.
If the Grammar
contains a "foreign rule" with a named capture, an
error may be returned.
Produces a quasi-BNF representation of the grammar.
This is how pidging::Grammar
implements std::fmt::Display
, so a
grammar's description is what you get if you feed it to the {}
pattern.
let mut p = Pidgin::new();
let g = p.grammar(&vec!["bar", "baz"]);
p.rule("foo", &g);
p = p.case_insensitive(true);
let g = p.grammar(&vec!["ping", "pang", "pong"]);
p = p.case_insensitive(false);
p.rule("xyzzy", &g);
let g = p.grammar(&vec!["xyzzy", "qux"]);
p.rule("plugh", &g);
let g = p.grammar(&vec!["foo", "plugh"]);
println!("{}", g.describe());
println!("{}", g);
Returns a quasi-regex representation of the grammar. This is intended
mostly for debugging. Rules will be identifiable by named groups, but
group names may repeat, in which case the stringification cannot be
compiled into a regular expression.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the minimum of two values. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more