Пример #1
0
        Ast.ListNode ParseList(SeekableStringReader sr)
        {
            // list            = list_empty | list_nonempty .
            // list_empty      = '[]' .
            // list_nonempty   = '[' expr_list ']' .
            sr.Read();                  // [
            sr.SkipWhitespace();
            Ast.ListNode list = new Ast.ListNode();
            if (sr.Peek() == ']')
            {
                sr.Read();
                return(list);                           // empty list
            }

            list.Elements = ParseExprList(sr);
            if (!sr.HasMore())
            {
                throw new ParseException("missing ']'");
            }
            char closechar = sr.Read();

            if (closechar != ']')
            {
                throw new ParseException("expected ']'");
            }
            return(list);
        }
Пример #2
0
        public void Visit(Ast.ListNode list)
        {
            IList <object> obj = new List <object>(list.Elements.Count);

            foreach (Ast.INode node in list.Elements)
            {
                node.Accept(this);
                obj.Add(generated.Pop());
            }
            generated.Push(obj);
        }
Пример #3
0
 public void Visit(Ast.ListNode list)
 {
     result.AppendLine("(list");
     indent++;
     foreach (Ast.INode node in list.Elements)
     {
         Indent();
         node.Accept(this);
         result.AppendLine(",");
     }
     indent--;
     Indent();
     result.Append(")");
 }