Пример #1
0
 private IEnumerable <Object> GetSubexpressions(ConsCell args)
 {
     try
     {
         return(args.GetListItems());
     }
     catch (System.InvalidOperationException)
     {
         throw new SyntaxException("Syntax error: Invalid expression.");
     }
 }
Пример #2
0
        public IEnumerable <Object> GetListItems()
        {
            ConsCell current = this;

            while (true)
            {
                if (current == Nil)
                {
                    yield break;
                }
                yield return(current.Car);

                if (!(current.Cdr is ConsCell))
                {
                    throw new System.InvalidOperationException("This is not a list.");
                }
                current = (ConsCell)current.Cdr;
            }
        }