pub struct GrammarNode {
pub key: Vec<u8>,
pub val: Vec<u8>,
pub children: BTreeMap<Vec<u8>, Vec<GrammarNode>>,
}
Expand description
tree-based grammar data format
Fields§
§key: Vec<u8>
§val: Vec<u8>
§children: BTreeMap<Vec<u8>, Vec<GrammarNode>>
Implementations§
Source§impl GrammarNode
root node for grammar-based input constructions
impl GrammarNode
root node for grammar-based input constructions
Sourcepub fn from(s: &[u8]) -> GrammarNode
pub fn from(s: &[u8]) -> GrammarNode
Derive a grammar tree from a byte vector.
Grammar tree nodes are newline-separated.
Parent nodes must be defined before child nodes.
Each node line is defined as a key and value separated by ‘=’, e.g.
key1=val
.
Example: phone number grammar input
<phone-number>=<countrycode>(<area>) <exchange>-<line><ext>
# values may be left empty
<countrycode>=
<countrycode>=+1
<area>=<digit><digit><digit>
<exchange>=<digit><digit><digit>
<line>=<digit><digit><digit><digit>
# values may be repeated to increase the frequency of occurrence
<ext>=
<ext>=
<ext>=
<ext>=
<ext>=
<ext>=
<ext>=
<ext>=
<ext>=
<ext>=
<ext>=, ext. <digit><digit>
<digit>=0
<digit>=1
<digit>=2
<digit>=3
<digit>=4
<digit>=5
<digit>=6
<digit>=7
<digit>=8
<digit>=9
Sourcepub fn from_file(p: &PathBuf) -> GrammarNode
pub fn from_file(p: &PathBuf) -> GrammarNode
wrapper for GrammarNode::from() to load bytes from a grammar file
Trait Implementations§
Source§impl Clone for GrammarNode
impl Clone for GrammarNode
Source§fn clone(&self) -> GrammarNode
fn clone(&self) -> GrammarNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for GrammarNode
impl RefUnwindSafe for GrammarNode
impl Send for GrammarNode
impl Sync for GrammarNode
impl Unpin for GrammarNode
impl UnwindSafe for GrammarNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more