Пример #1
0
        public object Visit(StartupStucture obj)
        {
            obj.Declarations?.Accept(this);
            obj.Declarations2?.Accept(this);
            obj.Declarations3?.Accept(this);
            _preVisit = false;

            obj.Declarations?.Accept(this);

            obj.DeclaringParameters.Accept(this);
            _symbolTable.Methods.Add(new SymbolTable.Method("Startup", "Void", _parameters));
            _parameters.Clear();
            obj.Commands?.Accept(this);

            _symbolTable.CloseScope();

            obj.Declarations2?.Accept(this);

            obj.DeclaringParameters2.Accept(this);
            _symbolTable.Methods.Add(new SymbolTable.Method("GameLoop", "Void", _parameters));
            _parameters.Clear();
            obj.Commands2?.Accept(this);

            _symbolTable.CloseScope();

            obj.Declarations3?.Accept(this);
            return(null);
        }
Пример #2
0
 public object Visit(StartupStucture obj)
 {
     obj.Commands?.Accept(this);
     return(null);
 }
Пример #3
0
        public object Visit(StartupStucture obj)
        {
            string codeString = "";

            //<S> ::= <Declarations> startup '(' <DeclaringParameters> ')' <Commands> end startup <Declarations> GameLoop '(' <DeclaringParameters> ')' <Commands> end GameLoop <Declarations>

            //////////////////////////////////////////////////////////////////////////////////////
            if (obj.Declarations != null)
            {
                codeString += (string)obj.Declarations.Accept(this);
            }
            if (obj.Declarations2 != null)
            {
                codeString += (string)obj.Declarations2.Accept(this);
            }
            if (obj.Declarations3 != null)
            {
                codeString += (string)obj.Declarations3.Accept(this);
            }
            _preVisit = false;

            codeString += "void Awake() {";

            foreach (string type in _instantiateList)
            {
                codeString += type;
            }

            codeString += "}";
            //////////////////////////////////////////////////////////////////////////GLOBAL SCOPE



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

            codeString += "void Start(";
            if (obj.DeclaringParameters != null)
            {
                codeString += (string)obj.DeclaringParameters.Accept(this);
            }

            codeString += ") {";

            if (obj.Commands != null)
            {
                codeString += (string)obj.Commands.Accept(this);
            }
            _symbolTable.CloseScope(); /////////////////////////////////////////////////////////////////////////////TESTFIX
            codeString += "}";
            /////////////////////////////////////////////////////////////////////////////////Start()



            ////////////////////////////////////////////////////////////////////////////////////////
            codeString += "void Update(";
            if (obj.DeclaringParameters2 != null)
            {
                codeString += (string)obj.DeclaringParameters2.Accept(this);
            }

            codeString += ") {";

            if (obj.Commands2 != null)
            {
                codeString += (string)obj.Commands2.Accept(this);
            }
            _symbolTable.CloseScope(); /////////////////////////////////////////////////////////////////////////////TESTFIX
            codeString += "}";
            ////////////////////////////////////////////////////////////////////////////////Update()


            if (obj.Declarations != null)
            {
                codeString += (string)obj.Declarations.Accept(this);
            }
            if (obj.Declarations2 != null)
            {
                codeString += (string)obj.Declarations2.Accept(this);
            }
            if (obj.Declarations3 != null)
            {
                codeString += (string)obj.Declarations3.Accept(this);
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // TODO: Add Better method to fix spaceing in cs file.
            codeString = codeString.Replace(";", ";" + System.Environment.NewLine);
            codeString = codeString.Replace("{", System.Environment.NewLine + "{" + System.Environment.NewLine);
            codeString = codeString.Replace("}", "}" + System.Environment.NewLine);
            Form1.formtest.testString = codeString;
            //////////////////////////////////////////////////////////////////////////// This block is only for test.

            return(codeString);
        }