pub fn find_form(se: &SynEnv, nt: &str, form_name: &str) -> Rc<Form> {
    fn find_form_rec(f: &FormPat, form_name: &str) -> Option<Rc<Form>> {
        match *f {
            Scope(ref f, _) => {
                if f.name.is(form_name) {
                    Some(f.clone())
                } else {
                    None
                }
            }
            Alt(ref vf) => {
                for f in vf {
                    let res = find_form_rec(f, form_name);
                    if res.is_some() {
                        return res;
                    }
                }
                None
            }
            Biased(ref lhs, ref rhs) => {
                let l_res = find_form_rec(lhs, form_name);
                if l_res.is_some() {
                    l_res
                } else {
                    find_form_rec(rhs, form_name)
                }
            }
            _ => None,
        }
    }
    let pat = se.find_or_panic(&n(nt));

    find_form_rec(pat, form_name)
        .unwrap_or_else(|| icp!("{:#?} not found in {:#?}", form_name, pat))
}
/// Mostly for testing purposes, this looks up forms by name.
/// In the "real world", programmers look up forms by syntax, using a parser.
Mostly for testing purposes, this looks up forms by name.
In the "real world", programmers look up forms by syntax, using a parser.
Mostly for testing purposes this looks up forms by name . In the " real world " programmers look up forms by syntax using a parser .
pub fn find_form(se: &SynEnv, nt: &str, form_name: &str) -> Rc<Form> {
    fn find_form_rec(f: &FormPat, form_name: &str) -> Option<Rc<Form>> {
        match *f {
            Scope(ref f, _) => {
                if f.name.is(form_name) {
                    Some(f.clone())
                } else {
                    None
                }
            }
            Alt(ref vf) => {
                for f in vf {
                    let res = find_form_rec(f, form_name);
                    if res.is_some() {
                        return res;
                    }
                }
                None
            }
            Biased(ref lhs, ref rhs) => {
                let l_res = find_form_rec(lhs, form_name);
                if l_res.is_some() {
                    l_res
                } else {
                    find_form_rec(rhs, form_name)
                }
            }
            _ => None,
        }
    }
    let pat = se.find_or_panic(&n(nt));
    find_form_rec(pat, form_name)
        .unwrap_or_else(|| icp!("{:#?} not found in {:#?}", form_name, pat))
}
pub fn find_form ( se : & SynEnv , nt : & str , form_name : & str ) -> Rc < Form > { fn find_form_rec ( f : & FormPat , form_name : & str ) -> Option < Rc < Form > > { match * f { Scope ( ref f , _ ) => { if f . name . is ( form_name ) { Some ( f . clone ( ) ) } else { None } } Alt ( ref vf ) => { for f in vf { let res = find_form_rec ( f , form_name ) ; if res . is_some ( ) { return res ; } } None } Biased ( ref lhs , ref rhs ) => { let l_res = find_form_rec ( lhs , form_name ) ; if l_res . is_some ( ) { l_res } else { find_form_rec ( rhs , form_name ) } } _ => None , } } let pat = se . find_or_panic ( & n ( nt ) ) ; find_form_rec ( pat , form_name ) . unwrap_or_else ( | | icp ! ( " " form_name pat ) ) }
Mostly for testing purposes, this looks up forms by name.
Mostly for testing purposes this looks up forms by name .
se
&SynEnv
nt
&str
form_name
&str
se
&SynEnv
nt
&str
form_name
&str