Exemplo n.º 1
0
        public Void Visit(DeclarationSequence declarationSequence, SortedSet <string> free)
        {
            declarationSequence.head.Accept(this, free);
            declarationSequence.tail.Accept(this, free);

            return(null);
        }
Exemplo n.º 2
0
        // ---

        /// /////////////////////////////////////////////////////////////////////////////////////////////////



        public IValue Visit(DeclarationSequence declarationSequence)
        {
            //Console.WriteLine("DECLARATION SEQUENCE STATEMENT");
            var declaration = declarationSequence;

            while (declaration != null)
            {
                var typeName = declaration.tail.GetType().Name;

                if (typeName == "VoidDeclaration")
                {
                    Environment.DeclareFunction((VoidDeclaration)declaration.tail);
                }
                else
                {
                    Environment.DeclareFunction((TypeDeclaration)declaration.tail);
                }
                declaration = (DeclarationSequence)declaration.head;
            }
            if (Environment.FunctionDict.ContainsKey("main"))
            {
                //Console.WriteLine("Main exists");

                var main     = Environment.FunctionDict["main"].Item1;
                var typeName = main.GetType().Name;
                if (typeName == "VoidDeclaration")
                {
                    main = (VoidDeclaration)Environment.FunctionDict["main"].Item1;
                }
                else
                {
                    main = (TypeDeclaration)Environment.FunctionDict["main"].Item1;
                }

                Environment.InitEnvironment();
                main.Accept(this);
                Environment.PopFunction();
                return(null);
            }
            else
            {
                //BACI GRESKU
                return(null);
            }
        }
Exemplo n.º 3
0
        public Statement Visit(DeclarationSequence declarationSequence)
        {
            var declaration = declarationSequence;

            while (declaration != null)
            {
                var typeName = declaration.tail.GetType().Name;
                State.ClearState();
                if (typeName == "VoidDeclaration")
                {
                    ((VoidDeclaration)declaration.tail).Accept(this);
                }
                else
                {
                    ((TypeDeclaration)declaration.tail).Accept(this);
                }
                declaration = (DeclarationSequence)declaration.head;
            }

            return(null);
        }
Exemplo n.º 4
0
        public Type Visit(DeclarationSequence declarationSequence, FunctionGeneratorEnvironment arg)
        {
            var declaration = declarationSequence;

            while (declaration != null)
            {
                var typeName = declaration.tail.GetType().Name;
                if (typeName == "TypeDeclaration")
                {
                    ((TypeDeclaration)declaration.tail).Accept(this, arg);
                }
                else
                {
                    ((TypeDeclaration)declaration.tail).Accept(this, arg);
                }

                declaration = (DeclarationSequence)declaration.head;
            }

            return(null);
        }
Exemplo n.º 5
0
        public Type Visit(DeclarationSequence declarationSequence)
        {
            var declaration = declarationSequence;

            while (declaration != null)
            {
                var typeName = declaration.tail.GetType().Name;

                if (typeName == "VoidDeclaration")
                {
                    Environment.FuncDeclaration.Add(((VoidDeclaration)declaration.tail).id, ((VoidDeclaration)declaration.tail));
                }
                else
                {
                    Environment.FuncDeclaration.Add(((TypeDeclaration)declaration.tail).id, ((TypeDeclaration)declaration.tail));
                }
                declaration = (DeclarationSequence)declaration.head;
            }

            declaration = declarationSequence;

            while (declaration != null)
            {
                var typeName = declaration.tail.GetType().Name;
                if (typeName == "VoidDeclaration")
                {
                    ((VoidDeclaration)declaration.tail).Accept(this);
                }
                else
                {
                    ((TypeDeclaration)declaration.tail).Accept(this);
                }

                Environment.VariableType.Clear();
                declaration = (DeclarationSequence)declaration.head;
            }

            return(null);
        }