private AbstractExpression parseInitialization(List <Token> currentTokens)
        {
            InitializationExpression expression = new InitializationExpression();

            if (currentTokens[0].Type == TokenType.KeyWord)
            {
                expression.keyWord = currentTokens[0].Value;
            }
            else
            {
                throw new Exception($"Line {currentTokens[0].Line}: When initialize variables start with type of data");
            }

            if (currentTokens[1].Type == TokenType.Identifier)
            {
                expression.identifier = currentTokens[1].Value;
            }
            else
            {
                throw new Exception($"Line {currentTokens[1].Line}: Incorrect identifier");
            }

            expression.Line = currentTokens[0].Line;
            return(expression);
        }
        private static void showInitialization(AbstractExpression expression, string t = "")
        {
            InitializationExpression initializationExpression = (InitializationExpression)expression;

            Console.WriteLine(t + $"type: {initializationExpression.type}");
            Console.WriteLine(t + $"keyword: {initializationExpression.keyWord}");
            Console.WriteLine(t + $"identifier: {initializationExpression.identifier}");
        }
Example #3
0
 private void AnalyzeInitializationExpr(InitializationExpression expr)
 {
     if (IsIdInitialized(expr.identifier))
     {
         throw new Exception("You try to initialize identifier again");
     }
     AddNewID(expr.identifier, expr.keyWord);
 }
Example #4
0
        private DeclarationExpression createDeclExpr(InitializationExpression initExpr, AssignmentExpression assgnExpr)
        {
            DeclarationExpression declExpr = new DeclarationExpression();

            declExpr.initializationExpression = initExpr;
            declExpr.expression = assgnExpr.Right;

            return(declExpr);
        }
Example #5
0
 private int findAssignmentExprIndex(int startPointer, InitializationExpression initExpr)
 {
     for (int i = startPointer; i < exprList.Count; i++)
     {
         if (exprList[i] is AssignmentExpression &&
             initExpr.identifier == ((AssignmentExpression)exprList[i]).identifier)
         {
             return(i);
         }
     }
     return(-1);
 }
        /* private void setValueForId(string id, string value, string prop = null)
         * {
         *   Data.SetValueByPropId(id, prop, value);
         * }*/

        private void TranslateInitExpr(InitializationExpression expression)
        {
            if (Data.IsAlreadyExist(expression.identifier))
            {
                throw new Exception($"Line {expression.Line}: Identifier {expression.identifier} is already exist");
            }
            bool isPrimitive = true;

            switch (expression.keyWord)
            {
            case (DataTypes.PRIVATE_ENTERPRENUER_DT):
                createNewPrivateEnterprenuer(expression.identifier);
                isPrimitive = false;
                break;

            case (DataTypes.ONE_TAX_PAYER_REPORT_DT):
                createNewOneTaxPayerReport(expression.identifier);
                isPrimitive = false;
                break;

            case (DataTypes.DF_1_REPORT_DT):
                createNewForm1DF(expression.identifier);
                isPrimitive = false;
                break;

            case (DataTypes.SECTION_1_DF_1_DT):
                createNewForm1DFSection1(expression.identifier);
                isPrimitive = false;
                break;

            case (DataTypes.UNIFIED_SOCIAL_TAX_REPORT_DT):
                createNewUnifiedSocialTaxReport(expression.identifier);
                isPrimitive = false;
                break;

            case (DataTypes.TABLE_1_UNIFIED_SOCIL_TAX_DT):
                createNewUnifiedSocialTaxTable1(expression.identifier);
                isPrimitive = false;
                break;
            }

            if (isPrimitive)
            {
                Data.CreatePrimitive(expression.keyWord, expression.identifier);
            }
        }