示例#1
0
        public override void Visit(ListConst n)   // may need implpamentation

        /*foreach (AST ast in n.declarings) {
         *  ast.accept(this);
         * }*/
        {
        }
示例#2
0
 public override void Visit(ListConst n)
 {
     foreach (AST ast in n.declarings)
     {
         ast.accept(this);
     }
 }
示例#3
0
 public override void Visit(ListConst n)
 {
     emit("{");
     if (n.declarings.Count > 0)
     {
         AST first = n.declarings[0];
         foreach (AST ast in n.declarings)
         {
             if (first != ast)
             {
                 emit(", ");
             }
             ast.accept(this);
         }
     }
     emit("}");
 }
示例#4
0
文件: TypeChecker.cs 项目: mkju19/P4
        public override void Visit(ListConst n)
        {
            string type        = AST.LIST.ToString();
            int    elementType = -1;

            foreach (AST ast in n.declarings)
            {
                ast.accept(this);
                if (elementType == -1)
                {
                    elementType = ast.type;
                }
                else if (ast.type != elementType)
                {
                    Error($"List in {scopeLevel} not of same type");
                }
            }
            if (elementType != -1)
            {
                type += elementType.ToString();
            }
            n.type = int.Parse(type);
        }