Esempio n. 1
0
        public override bool SemanticAnalysis()
        {
            IsSemanticCorrect = true;
            try
            {
                IsSemanticCorrect &= Condition.SemanticAnalysis();
            }
            catch (SemanticException e)
            {
                Console.WriteLine(e.Message);
                IsSemanticCorrect = false;
            }

            try
            {
                IsSemanticCorrect &= IfBranch.SemanticAnalysis();
            }
            catch
            {
                IsSemanticCorrect = false;
            }

            if (ElseBranch != null)
            {
                try
                {
                    IsSemanticCorrect = ElseBranch.SemanticAnalysis();
                }
                catch (SemanticException e)
                {
                    Console.WriteLine(e.Message);
                    IsSemanticCorrect = false;
                }
            }

            IfBranch.CheckVariables();
            if (ElseBranch != null)
            {
                ElseBranch.CheckVariables();
            }
            return(IsSemanticCorrect);
        }