fn fast_parse(tokens: Vec<Token>, grefs: &[LocalRef], name: Name) -> Option<MixfixTree> {
        match name {
            Name::Mixfix(s) => {
                let parts = Name::decode_parts(s);

                // Check that the tokens agree with the mixfix name.
                if parts.len() != tokens.len() {
                    return None;
                }

                // Placeholders should line up with expression tokens.
                // Names should line up with name tokens.
                for (part, token) in parts.iter().zip(tokens.iter()) {
                    match (part, token) {
                        (Part::Placeholder, Token::Exp(_)) => {},
                        (Part::Id(x), Token::Name(Part::Id(y), _)) => {
                            if x != y {
                                return None;
                            }
                        },
                        (Part::Op(x), Token::Name(Part::Op(y), _)) => {
                            if x != y {
                                return None;
                            }
                        },
                        _ => {
                            return None;
                        },
                    }
                }

                // All ok, now make the expression tree.
                let args: Trees = tokens.iter().filter_map(|t| match t {
                    Token::Exp(e) => Some(e.clone()),
                    _ => None,
                }).collect();

                Some(MixfixTree::make_call(MixfixTree::Name(name, grefs.to_vec()), &args))
            },
            _ => {
                None
            },
        }
    }
// Do fast mixfix parsing. Should be called only when all the decls have a single mixfix name.
// It just checks that the tokens match the mixfix name and builds the call tree.
Do fast mixfix parsing. Should be called only when all the decls have a single mixfix name.
It just checks that the tokens match the mixfix name and builds the call tree.
Do fast mixfix parsing . Should be called only when all the decls have a single mixfix name . It just checks that the tokens match the mixfix name and builds the call tree .
fn fast_parse(tokens: Vec<Token>, grefs: &[LocalRef], name: Name) -> Option<MixfixTree> {
        match name {
            Name::Mixfix(s) => {
                let parts = Name::decode_parts(s);
                // Check that the tokens agree with the mixfix name.
                if parts.len() != tokens.len() {
                    return None;
                }
                // Placeholders should line up with expression tokens.
                // Names should line up with name tokens.
                for (part, token) in parts.iter().zip(tokens.iter()) {
                    match (part, token) {
                        (Part::Placeholder, Token::Exp(_)) => {},
                        (Part::Id(x), Token::Name(Part::Id(y), _)) => {
                            if x != y {
                                return None;
                            }
                        },
                        (Part::Op(x), Token::Name(Part::Op(y), _)) => {
                            if x != y {
                                return None;
                            }
                        },
                        _ => {
                            return None;
                        },
                    }
                }
                // All ok, now make the expression tree.
                let args: Trees = tokens.iter().filter_map(|t| match t {
                    Token::Exp(e) => Some(e.clone()),
                    _ => None,
                }).collect();
                Some(MixfixTree::make_call(MixfixTree::Name(name, grefs.to_vec()), &args))
            },
            _ => {
                None
            },
        }
    }
fn fast_parse ( tokens : Vec < Token > , grefs : & [ LocalRef ] , name : Name ) -> Option < MixfixTree > { match name { Name :: Mixfix ( s ) => { let parts = Name :: decode_parts ( s ) ; // Check that the tokens agree with the mixfix name. if parts . len ( ) != tokens . len ( ) { return None ; } // Placeholders should line up with expression tokens. // Names should line up with name tokens. for ( part , token ) in parts . iter ( ) . zip ( tokens . iter ( ) ) { match ( part , token ) { ( Part :: Placeholder , Token :: Exp ( _ ) ) => { } , ( Part :: Id ( x ) , Token :: Name ( Part :: Id ( y ) , _ ) ) => { if x != y { return None ; } } , ( Part :: Op ( x ) , Token :: Name ( Part :: Op ( y ) , _ ) ) => { if x != y { return None ; } } , _ => { return None ; } , } } // All ok, now make the expression tree. let args : Trees = tokens . iter ( ) . filter_map ( | t | match t { Token :: Exp ( e ) => Some ( e . clone ( ) ) , _ => None , } ) . collect ( ) ; Some ( MixfixTree :: make_call ( MixfixTree :: Name ( name , grefs . to_vec ( ) ) , & args ) ) } , _ => { None } , } }
Do fast mixfix parsing.
Do fast mixfix parsing .
tokens
Vec<Token>
grefs
&[LocalRef]
name
Name
tokens
Vec<Token>
grefs
&[LocalRef]
name
Name