Esempio n. 1
0
        public MiniMLObservableParser()
        {
            anyId = from _ in InsignificantWhiteSpace
                    from first in Character(char.IsLetter)
                    from remainder in Character(char.IsLetterOrDigit).NoneOrMore().Join()
                    select first + remainder;

            letId    = anyId.Where(id => id == "let");
            inId     = anyId.Where(id => id == "in");
            keyword  = letId.Or(inId);
            identity = anyId.Not(keyword);

            term1 = (from id in identity
                     select(Term) new VarTerm(id))
                    .Or(
                from _ in WsChr('(')
                from t in term
                from __ in WsChr(')')
                select t);

            term = (from _ in WsChr('\\')
                    from id in identity
                    from __ in WsChr('.')
                    from t in term
                    select(Term) new LambdaTerm(id, t))
                   .Or(
                from _ in letId
                from id in identity
                from __ in WsChr('=')
                from rhs in term
                from ___ in inId
                from body in term
                select(Term) new LetTerm(id, rhs, body))
                   .Or(
                from t in term1
                from remainder in term1.NoneOrMore()
                from list in remainder.ToList()
                select(Term) new AppTerm(t, list));
        }