fn process_nonterminal(pair: Pair<Rule>) -> Result<(usize, usize, Edge, NonTerminal), Error> {
    // nonterminal rule is defined as:
    // ID ~ other ~ label ~ other ~ edge_label ~ ID ~ consume_line? ~ NEWLINE
    // thus safe to unwrap up to second ID as the rule would not match otherwise
    match pair.as_rule() {
        Rule::nonterminal => (),
        _ => return Err(format_err!("Expected terminal, got {:?}", pair)),
    }
    let mut parts = pair.into_inner();
    let self_id = parts.next().unwrap().as_str().parse::<usize>()?;
    //other
    parts.next();
    let mut label_parts = parts.next().unwrap().as_str().split('=');
    let label = label_parts.next().unwrap();
    let annotation = label_parts.next().map(ToOwned::to_owned);
    //other
    parts.next();
    let edge = parts.next().unwrap().as_str();
    let edge = if edge == "--" { None } else { Some(edge) };
    let parent_id = parts.next().unwrap().as_str().parse::<usize>()?;
    let mut nt = NonTerminal::new(label, 0);
    if annotation.is_some() {
        nt.set_features(Some(
            vec![(NODE_ANNOTATION_FEATURE_KEY, annotation)]
                .into_iter()
                .collect(),
        ));
    };
    Ok((parent_id, self_id, edge.into(), nt))
}
// returns a tuple of parent_id, own_id, parent_edge, ntbuilder
// NTBuilder is returned rather than NonTerminal because span depends on other nodes.
returns a tuple of parent_id, own_id, parent_edge, ntbuilder
NTBuilder is returned rather than NonTerminal because span depends on other nodes.
returns a tuple of parent_id own_id parent_edge ntbuilder NTBuilder is returned rather than NonTerminal because span depends on other nodes .
fn process_nonterminal(pair: Pair<Rule>) -> Result<(usize, usize, Edge, NonTerminal), Error> {
    // nonterminal rule is defined as:
    // ID ~ other ~ label ~ other ~ edge_label ~ ID ~ consume_line? ~ NEWLINE
    // thus safe to unwrap up to second ID as the rule would not match otherwise
    match pair.as_rule() {
        Rule::nonterminal => (),
        _ => return Err(format_err!("Expected terminal, got {:?}", pair)),
    }
    let mut parts = pair.into_inner();
    let self_id = parts.next().unwrap().as_str().parse::<usize>()?;
    //other
    parts.next();
    let mut label_parts = parts.next().unwrap().as_str().split('=');
    let label = label_parts.next().unwrap();
    let annotation = label_parts.next().map(ToOwned::to_owned);
    //other
    parts.next();
    let edge = parts.next().unwrap().as_str();
    let edge = if edge == "--" { None } else { Some(edge) };
    let parent_id = parts.next().unwrap().as_str().parse::<usize>()?;
    let mut nt = NonTerminal::new(label, 0);
    if annotation.is_some() {
        nt.set_features(Some(
            vec![(NODE_ANNOTATION_FEATURE_KEY, annotation)]
                .into_iter()
                .collect(),
        ));
    };
    Ok((parent_id, self_id, edge.into(), nt))
}
fn process_nonterminal ( pair : Pair < Rule > ) -> Result < ( usize , usize , Edge , NonTerminal ) , Error > { // nonterminal rule is defined as: // ID ~ other ~ label ~ other ~ edge_label ~ ID ~ consume_line? ~ NEWLINE // thus safe to unwrap up to second ID as the rule would not match otherwise match pair . as_rule ( ) { Rule :: nonterminal => ( ) , _ => return Err ( format_err ! ( " " pair ) ) , } let mut parts = pair . into_inner ( ) ; let self_id = parts . next ( ) . unwrap ( ) . as_str ( ) . parse :: < usize > ( ) ? ; //other parts . next ( ) ; let mut label_parts = parts . next ( ) . unwrap ( ) . as_str ( ) . split ( '=' ) ; let label = label_parts . next ( ) . unwrap ( ) ; let annotation = label_parts . next ( ) . map ( ToOwned :: to_owned ) ; //other parts . next ( ) ; let edge = parts . next ( ) . unwrap ( ) . as_str ( ) ; let edge = if edge == " " { None } else { Some ( edge ) } ; let parent_id = parts . next ( ) . unwrap ( ) . as_str ( ) . parse :: < usize > ( ) ? ; let mut nt = NonTerminal :: new ( label , 0 ) ; if annotation . is_some ( ) { nt . set_features ( Some ( vec ! [ ( NODE_ANNOTATION_FEATURE_KEY annotation ) ] . into_iter ( ) . collect ( ) , ) ) ; } ; Ok ( ( parent_id , self_id , edge . into ( ) , nt ) ) }
returns a tuple of parent_id, own_id, parent_edge, ntbuilder
NTBuilder is returned rather than NonTerminal because span depends on other nodes.
returns a tuple of parent_id own_id parent_edge ntbuilder NTBuilder is returned rather than NonTerminal because span depends on other nodes .
pair
Pair<Rule>
pair
Pair<Rule>