pub fn parse_query(pair: Pair<'_, Rule>, mut query: &mut Query) -> Result<(), Error> {
    for inner in pair.into_inner() {
        match inner.as_rule() {
            Rule::count => {
                if query.is_aggregation_exist() {
                    return Err(format_err!(
                        "{}",
                        "Only one aggregation is supported. At least for now"
                    ));
                }
                parse_count(inner, &mut query);
            }
            Rule::structured => {
                if query.selection.is_some() {
                    return Err(format_err!("{}", "Only one selection statement exist"));
                }
                parse_structured(inner, &mut query)
            }
            Rule::query => parse_query(inner, &mut query)?,
            Rule::query_block => parse_query(inner, &mut query)?,
            Rule::distinct | Rule::distinct_count => {
                if query.is_aggregation_exist() {
                    return Err(format_err!(
                        "{}",
                        "Only one aggregation is supported. At least for now"
                    ));
                }
                parse_distinct(inner, &mut query);
            }
            Rule::average => {
                if query.is_aggregation_exist() {
                    return Err(format_err!(
                        "{}",
                        "Only one aggregation is supported. At least for now"
                    ));
                }
                parse_average(inner, &mut query);
            }
            Rule::unstructured => {
                if query.selection.is_some() {
                    return Err(format_err!("{}", "Only one selection statement exist"));
                }
                parse_unstructured(inner, &mut query);
            }
            Rule::limit => {
                if query.limit != 0 {
                    return Err(format_err!("You can only use one limit operator"));
                }
                parse_limit(inner, &mut query);
            }
            Rule::source => {
                if query.soruces.len() != 0 {
                    return Err(format_err!("You can mention source only once"));
                }
                parse_source(inner, &mut query);
            }
            Rule::distance => {
                if query.distance != 0 {
                    return Err(format_err!("Only one distance limit is allowed"));
                }
                parse_distance(inner, &mut query);
            }
            _ => {}
        }
    }
    Ok(())
}
/// parse_query is used to parse the Pathivu query into internal
/// query structure.
parse_query is used to parse the Pathivu query into internal
query structure.
parse_query is used to parse the Pathivu query into internal query structure .
pub fn parse_query(pair: Pair<'_, Rule>, mut query: &mut Query) -> Result<(), Error> {
    for inner in pair.into_inner() {
        match inner.as_rule() {
            Rule::count => {
                if query.is_aggregation_exist() {
                    return Err(format_err!(
                        "{}",
                        "Only one aggregation is supported. At least for now"
                    ));
                }
                parse_count(inner, &mut query);
            }
            Rule::structured => {
                if query.selection.is_some() {
                    return Err(format_err!("{}", "Only one selection statement exist"));
                }
                parse_structured(inner, &mut query)
            }
            Rule::query => parse_query(inner, &mut query)?,
            Rule::query_block => parse_query(inner, &mut query)?,
            Rule::distinct | Rule::distinct_count => {
                if query.is_aggregation_exist() {
                    return Err(format_err!(
                        "{}",
                        "Only one aggregation is supported. At least for now"
                    ));
                }
                parse_distinct(inner, &mut query);
            }
            Rule::average => {
                if query.is_aggregation_exist() {
                    return Err(format_err!(
                        "{}",
                        "Only one aggregation is supported. At least for now"
                    ));
                }
                parse_average(inner, &mut query);
            }
            Rule::unstructured => {
                if query.selection.is_some() {
                    return Err(format_err!("{}", "Only one selection statement exist"));
                }
                parse_unstructured(inner, &mut query);
            }
            Rule::limit => {
                if query.limit != 0 {
                    return Err(format_err!("You can only use one limit operator"));
                }
                parse_limit(inner, &mut query);
            }
            Rule::source => {
                if query.soruces.len() != 0 {
                    return Err(format_err!("You can mention source only once"));
                }
                parse_source(inner, &mut query);
            }
            Rule::distance => {
                if query.distance != 0 {
                    return Err(format_err!("Only one distance limit is allowed"));
                }
                parse_distance(inner, &mut query);
            }
            _ => {}
        }
    }
    Ok(())
}
pub fn parse_query ( pair : Pair < ' _ , Rule > , mut query : & mut Query ) -> Result < ( ) , Error > { for inner in pair . into_inner ( ) { match inner . as_rule ( ) { Rule :: count => { if query . is_aggregation_exist ( ) { return Err ( format_err ! ( " " " " ) ) ; } parse_count ( inner , & mut query ) ; } Rule :: structured => { if query . selection . is_some ( ) { return Err ( format_err ! ( " " " " ) ) ; } parse_structured ( inner , & mut query ) } Rule :: query => parse_query ( inner , & mut query ) ? , Rule :: query_block => parse_query ( inner , & mut query ) ? , Rule :: distinct | Rule :: distinct_count => { if query . is_aggregation_exist ( ) { return Err ( format_err ! ( " " " " ) ) ; } parse_distinct ( inner , & mut query ) ; } Rule :: average => { if query . is_aggregation_exist ( ) { return Err ( format_err ! ( " " " " ) ) ; } parse_average ( inner , & mut query ) ; } Rule :: unstructured => { if query . selection . is_some ( ) { return Err ( format_err ! ( " " " " ) ) ; } parse_unstructured ( inner , & mut query ) ; } Rule :: limit => { if query . limit != 0 { return Err ( format_err ! ( " " ) ) ; } parse_limit ( inner , & mut query ) ; } Rule :: source => { if query . soruces . len ( ) != 0 { return Err ( format_err ! ( " " ) ) ; } parse_source ( inner , & mut query ) ; } Rule :: distance => { if query . distance != 0 { return Err ( format_err ! ( " " ) ) ; } parse_distance ( inner , & mut query ) ; } _ => { } } } Ok ( ( ) ) }
parse_query is used to parse the Pathivu query into internal
query structure.
parse_query is used to parse the Pathivu query into internal query structure .
pair
Pair<'_, Rule>
query
&mut Query