Пример #1
0
        private static AstList ParseList(Queue <Token> tokens)
        {
            var ret = new AstList();

            tokens.Dequeue();
            while (tokens.Count > 0)
            {
                if (tokens.Peek().Text.Equals(")"))
                {
                    tokens.Dequeue();
                    return(ret);
                }

                ret.Add(Parse(tokens));
            }

            throw new Exception("Couldn't find end of list");
        }
Пример #2
0
        private static string PrintList(AstList al)
        {
            var ret = new StringBuilder();

            ret.Append('(');
            var list = new Queue <AstObject>(al.Objects);

            while (list.Count > 0)
            {
                ret.Append(Print(list.Dequeue()));
                if (list.Count != 0)
                {
                    ret.Append(' ');
                }
            }

            ret.Append(')');
            return(ret.ToString());
        }