/// Function used to expand an expression
/// returns the transformed expression and a bool if all tokens are terminal
Function used to expand an expression
returns the transformed expression and a bool if all tokens are terminal
Function used to expand an expression returns the transformed expression and a bool if all tokens are terminal
pub fn expand(rules: &[Rule], expr: String) -> (String, bool) {
    let mut is_all_terminal = true;
    let mut aux = String::from("");
    let tokens = expr.split(' ');
    for token in tokens {
        let val = match is_terminal(&rules, &token) {
            Some(val) => {
                is_all_terminal = false;
                //checking if have another branch
                if val.contains("|") {
                    choose_token(val)
                } else {
                    String::from(val)
                }
            }
            None => String::from(token),
        };
        aux.push_str(&val);
        aux.push_str(" ");
    }
    return (aux, is_all_terminal);
}
pub fn expand ( rules : & [ Rule ] , expr : String ) -> ( String , bool ) { let mut is_all_terminal = true ; let mut aux = String :: from ( " " ) ; let tokens = expr . split ( ' ' ) ; for token in tokens { let val = match is_terminal ( & rules , & token ) { Some ( val ) => { is_all_terminal = false ; //checking if have another branch if val . contains ( " " ) { choose_token ( val ) } else { String :: from ( val ) } } None => String :: from ( token ) , } ; aux . push_str ( & val ) ; aux . push_str ( " " ) ; } return ( aux , is_all_terminal ) ; }
Function used to expand an expression
returns the transformed expression and a bool if all tokens are terminal
Function used to expand an expression returns the transformed expression and a bool if all tokens are terminal
rules
&[Rule]
expr
String