expression_list construct_expression_list_for_slice_expr(slice_expr sl)
        {
            // situation = 0 - ничего не пропущено
            // situation = 1 - пропущен from
            // situation = 2 - пропущен to
            // situation = 3 - пропущены from и to
            // Пропущенность кодируется тем, что в соответствующем поле - int.MaxValue
            // step может просто отсутствовать - это параметр по умолчанию в SystemSlice

            int situation = 0;

            if ((sl.from is int32_const) && (sl.from as int32_const).val == int.MaxValue)
            {
                situation += 1;
            }
            if ((sl.to is int32_const) && (sl.to as int32_const).val == int.MaxValue)
            {
                situation += 2;
            }

            var el = new expression_list();

            el.Add(new int32_const(situation));
            el.Add(sl.from); // Это плохо - считается 2 раза. Надо делать semantic_expr_node !!!? Нет!!!
                             // Если там будет лямбда, то не будет работать - известно, что semantic_expr_node не работает с лямбдами
                             // т.к. они несколько раз обходят код.
            el.Add(sl.to);
            if (sl.step != null)
            {
                el.Add(sl.step);
            }

            return(el);
        }
Example #2
0
 public override void visit(expression_list _expression_list)
 {
     foreach (expression ex in _expression_list.expressions)
     {
         ex.visit(this);
     }
 }
        public override void visit(slice_expr sl)
        {
            expression_list el = null;

            if (sl.slices == null)
            {
                el = construct_expression_list_for_slice_expr(sl);
            }
            else
            {
                el = construct_expression_list_for_slice_expr_multi(sl);  // то это многомерный массив
            }
            // надо как-то запретить многомерные слайсы в левой части присваивания
            if (sl.Parent is assign parent_assign && parent_assign.to == sl)
            {
                // если это многомерный слайс - кинуть ошибку
                if (sl.slices != null)
                {
                    // запретим пока или вовсе
                    throw new SyntaxVisitorError("MULTIDIMENSIONAL_SLICES_FORBIDDEN_IN_LEFT_SIDE_OF_ASSIGNMENT", sl.source_context);
                }
                el.Insert(0, parent_assign.from);
                var mc = method_call.NewP(
                    dot_node.NewP(
                        sl.v,
                        new ident("SystemSliceAssignment", sl.v.source_context),
                        sl.v.source_context),
                    el, sl.source_context);
                var systemSliceAssignmentCall   = new procedure_call(mc, sl.source_context);
                var typeCompatibilityCheck      = GetAssignmentTypeCompatibilityCheck(sl, parent_assign.from, mc);
                var checkAndDesugaredSliceBlock = new statement_list(typeCompatibilityCheck, systemSliceAssignmentCall);
                checkAndDesugaredSliceBlock.source_context = sl.source_context;
                ReplaceUsingParent(parent_assign, checkAndDesugaredSliceBlock);
                visit(systemSliceAssignmentCall); // обойти заменённое на предмет наличия такого же синтаксического сахара
            }
        expression_list construct_expression_list_for_slice_expr_multi(slice_expr sl)
        {
            if (sl.slices == null)
            {
                return(null);               // упадёт - это ошибка компилятора
            }
            var el = new expression_list(); // будем наполнять кортежами - самое простое
            var sc = sl.source_context;

            foreach (var slice in sl.slices)
            {
                var tup = new dot_node(new dot_node(new ident("?System", sc), new ident("Tuple", sc), sc), new ident("Create", sc), sc);
                var eel = new expression_list();
                // пытаемся разобраться с ^1

                var sl1 = slice.Item1;
                eel.Add(sl1);
                IndexVisitor.New.ProcessNode(sl1); // индексный визитор сам не вызывается поскольку в многомерных срезах хранится List кортежей троек expression, который сам не обходится
                var sl2 = slice.Item2;
                eel.Add(sl2);
                IndexVisitor.New.ProcessNode(sl2);
                var sl3 = slice.Item3; // и step тоже надо обходить!!!
                eel.Add(sl3);
                IndexVisitor.New.ProcessNode(sl3);

                var mc = new method_call(tup, eel, sc); // sc - не очень хорошо - ошибка будет в общем месте
                el.Add(mc);
                // по идее все параметры готовы. Надо только проверить, что они целые
            }
            return(el);
        }
Example #5
0
        private expression DesugarDeconstructorPatternParameters(deconstructor_pattern pattern)
        {
            expression paramCheckExpr = null;

            for (int i = 0; i < pattern.parameters.Count; ++i)
            {
                if (pattern.parameters[i] is const_pattern_parameter constPattern)
                {
                    var constParamIdent = new ident(NewDeconstructParamId(), pattern.parameters[i].source_context);

                    var eqParams = new expression_list(
                        new List <expression>()
                    {
                        constPattern.const_param,
                        constParamIdent
                    }
                        );

                    var constParamCheck = new method_call(
                        new dot_node(new ident("object"), new ident("Equals")),
                        eqParams,
                        pattern.source_context
                        );

                    pattern.parameters[i] = new var_deconstructor_parameter(
                        constParamIdent,
                        GetTypeDefinitionForConstParam(constPattern.const_param),
                        false,
                        pattern.parameters[i].source_context);

                    paramCheckExpr = paramCheckExpr == null ? (expression)constParamCheck : bin_expr.LogicalAnd(paramCheckExpr, constParamCheck);
                }

                if (pattern.parameters[i] is wild_card_deconstructor_parameter)
                {
                    var wildCardGeneratedParamIdent = new ident(NewDeconstructParamId(), pattern.parameters[i].source_context);
                    pattern.parameters[i] = new var_deconstructor_parameter(
                        wildCardGeneratedParamIdent,
                        null,
                        false,
                        pattern.parameters[i].source_context);
                }

                if (pattern.parameters[i] is recursive_deconstructor_parameter deconstructor_param)
                {
                    if (deconstructor_param.pattern is deconstructor_pattern deconstructor_pattern)
                    {
                        var recursiveChecks = DesugarDeconstructorPatternParameters(deconstructor_pattern);
                        paramCheckExpr = paramCheckExpr == null ?
                                         recursiveChecks :
                                         bin_expr.LogicalAnd(paramCheckExpr, recursiveChecks);
                    }
                }
            }
            return(paramCheckExpr);
        }
        public function_lambda_call NewFactor(ident func_decl_lambda, expression_list expr_list, LexLocation loc)
        {
            var fld = parsertools.find_pascalABC_lambda_name(func_decl_lambda.name);
            var _expression_list   = expr_list;
            var _lambda_definition = fld;
            var _lambda_call       = new function_lambda_call(_lambda_definition, _expression_list, loc);

            _lambda_call.source_context = func_decl_lambda.source_context;
            return(_lambda_call);
        }
Example #7
0
        private expression GetCollectionItemsEqualCheckAfterGap(addressed_value matchingExpression,
                                                                List <pattern_parameter> toCompare,
                                                                CollectionDesugaringResult desugaringResult)
        {
            var        elemFromTail = 1;
            expression equalChecks  = null;

            foreach (var param in toCompare)
            {
                var indexerCall = new indexer(
                    matchingExpression,
                    new expression_list(
                        new bin_expr(
                            new method_call(
                                new dot_node(
                                    matchingExpression,
                                    new ident("Count", matchingExpression.source_context)),
                                new expression_list()),
                            new int32_const(elemFromTail, matchingExpression.source_context),
                            Operators.Minus),
                        matchingExpression.source_context),
                    matchingExpression.source_context);

                if (param is const_pattern_parameter constParam)
                {
                    var eqParams = new expression_list(
                        new List <expression>()
                    {
                        indexerCall,
                        constParam.const_param
                    }
                        );

                    var equalCall = new method_call(
                        new dot_node(
                            new ident("object"),
                            new ident("Equals")),
                        eqParams,
                        matchingExpression.source_context
                        );

                    equalChecks = equalChecks == null ? (expression)equalCall : bin_expr.LogicalAnd(equalChecks, equalCall);
                    desugaringResult.ElemTypeChecks.Add(GetTypeCompatibilityCheck(indexerCall, constParam.const_param));
                }

                if (param is collection_pattern_var_parameter varParam)
                {
                    desugaringResult.VarParametersDeclarations.Add(
                        new var_statement(varParam.identifier, indexerCall));
                }

                ++elemFromTail;
            }
            return(equalChecks);
        }
Example #8
0
        private TupleDesugaringResult DesugarTuplePattern(tuple_pattern pattern, expression matchingExpression)
        {
            Debug.Assert(!pattern.IsRecursive, "All recursive patterns should be desugared into simple patterns at this point");
            var desugaringResult = new TupleDesugaringResult();
            var tupleItems       = pattern.parameters;

            for (int i = 0; i < tupleItems.Count; ++i)
            {
                var tupleItemCall = new dot_node(
                    matchingExpression as addressed_value,
                    new ident("Item" + (i + 1).ToString()),
                    matchingExpression.source_context);
                if (tupleItems[i] is tuple_pattern_var_parameter varParam)
                {
                    desugaringResult.VarParametersDeclarations.Add(
                        new var_statement(
                            varParam.identifier,
                            tupleItemCall,
                            matchingExpression.source_context
                            )
                        );
                }

                if (tupleItems[i] is const_pattern_parameter constParam)
                {
                    var eqParams = new expression_list(
                        new List <expression>()
                    {
                        tupleItemCall,
                        constParam.const_param
                    }
                        );
                    var equalCall = new method_call(
                        new dot_node(new ident("object"), new ident("Equals")),
                        eqParams,
                        pattern.source_context
                        );

                    desugaringResult.SuccessMatchingCheck = desugaringResult.SuccessMatchingCheck == null ?
                                                            (expression)equalCall :
                                                            bin_expr.LogicalAnd(desugaringResult.SuccessMatchingCheck, equalCall);
                    desugaringResult.ElemTypeChecks.Add(GetTypeCompatibilityCheck(tupleItemCall, constParam.const_param));
                }
            }

            desugaringResult.TupleLengthCheck = GetTypeCompatibilityCheck(matchingExpression, new int32_const(tupleItems.Count));

            if (desugaringResult.SuccessMatchingCheck == null)
            {
                desugaringResult.SuccessMatchingCheck = new bool_const(true);
            }
            return(desugaringResult);
        }
 private static void AddAttribute(declaration typeclassInterfaceDecl, string newAttribute, expression_list expressionList = null)
 {
     if (expressionList == null)
     {
         expressionList = new expression_list();
     }
     if (typeclassInterfaceDecl.attributes == null)
     {
         typeclassInterfaceDecl.attributes = new attribute_list();
     }
     typeclassInterfaceDecl.attributes.Add(new simple_attribute_list(new attribute(null, new named_type_reference(newAttribute), expressionList)));
 }
 public override void visit(bin_expr ex)
 {
     if (ex.operation_type == Operators.In && ex.right is diapason_expr_new diap && ex.left is addressed_value exl)
     {
         var el = new expression_list();
         el.Add(exl, exl.source_context);
         el.Add(diap.left, diap.left.source_context);
         el.Add(diap.right, diap.right.source_context);
         var mc  = method_call.NewP(new ident("InRangeInternal", exl.source_context), el, exl.source_context);
         var sug = sugared_addressed_value.NewP(ex, mc, ex.source_context);
         ReplaceUsingParent(ex, sug);
         visit(mc); // обойти заменённое на предмет наличия такого же синтаксического сахара
     }
Example #11
0
        //private SyntaxTree.uses_list CreateStandartUsesList()
        //{
        //    uses_list res = new uses_list();
        //    unit_or_namespace pabcsystem = new unit_or_namespace();
        //    pabcsystem.name = new ident_list("PABCSystem");
        //    res.units.Add(pabcsystem);
        //    return res;
        //}

        public procedure_call CreateProcedureCall(string procName, params expression[] exprList)
        {
            SyntaxTree.procedure_call pc = new SyntaxTree.procedure_call();
            SyntaxTree.method_call    mc = new SyntaxTree.method_call();
            mc.dereferencing_value = new ident(procName);
            pc.func_name           = mc;
            SyntaxTree.expression_list exl = new expression_list();
            foreach (expression x in exprList)
            {
                exl.Add(x);
            }
            mc.parameters = exl;
            return(pc);
        }
Example #12
0
        private expression GetCollectionItemsEqualCheckBeforeGap(addressed_value matchingExpression,
                                                                 List <pattern_parameter> toCompare,
                                                                 CollectionDesugaringResult desugaringResult)
        {
            var        fromIndex   = 0;
            expression equalChecks = null;

            foreach (var param in toCompare)
            {
                if (param is const_pattern_parameter constParam)
                {
                    var indexerCall = new indexer(
                        matchingExpression,
                        new expression_list(
                            new int32_const(fromIndex, matchingExpression.source_context),
                            matchingExpression.source_context),
                        matchingExpression.source_context);

                    var eqParams = new expression_list(
                        new List <expression>()
                    {
                        indexerCall,
                        constParam.const_param
                    }
                        );

                    var equalCall = new method_call(
                        new dot_node(
                            new ident("object"),
                            new ident("Equals")),
                        eqParams,
                        matchingExpression.source_context
                        );

                    equalChecks = equalChecks == null ? (expression)equalCall : bin_expr.LogicalAnd(equalChecks, equalCall);
                    desugaringResult.ElemTypeChecks.Add(GetTypeCompatibilityCheck(indexerCall, constParam.const_param));
                }

                if (param is collection_pattern_var_parameter varParam)
                {
                    desugaringResult.VarParametersDeclarations.Add(
                        new var_statement(varParam.identifier,
                                          GetIndexerCallForCollectionPattern(matchingExpression as addressed_value, fromIndex)));
                }
                ++fromIndex;
            }
            return(equalChecks);
        }
        public override void visit(index ind)
        {
            var indexCreation =
                new method_call(
                    new dot_node(
                        new ident("SystemIndex", ind.source_context),
                        new ident("Create", ind.source_context),
                        ind.source_context),
                    new expression_list(
                        new List<expression>()
                        {
                            ind.index_expr,
                            new bool_const(ind.inverted, ind.source_context)
                        },
                        ind.source_context),
                    ind.source_context);
            syntax_tree_node mc = null;
            var possibleIndexer = ind.Parent?.Parent;
            if (possibleIndexer != null && possibleIndexer is indexer indexer)
            {
                // Надо подняться до узла indexer и запомнить индекс, под которым данный index входит
                // Идём по Parent - и смотрим, когда Parent = indexer
                // Находим у него expressions и ищем, под каким индексом в нем содержится текущий.
                // Запоминаем это целое число и передаем его последним параметром в Reverse если expressions.Count > 1
                expression_list reverseIndexMethodParams = null;
                if (indexer.indexes.expressions.Count == 1)
                    reverseIndexMethodParams = new expression_list(indexer.dereferencing_value, ind.source_context);
                else
                {
                    var i = indexer.indexes.expressions.FindIndex(x => x == ind);
                    if (i >= 0)
                        reverseIndexMethodParams = new expression_list(new List<expression> { indexer.dereferencing_value, new int32_const(i) }, ind.source_context);
                }

                mc = new method_call(
                        new dot_node(indexCreation, new ident("Reverse", ind.source_context)),
                        reverseIndexMethodParams,
                        ind.source_context);
            }
            else // Это непонятная ветка. Она наступает в частности если индексер не находится на 2 уровня выше, что бывает в случае индекса вида a[1..^1]
            {
                mc = indexCreation;
            }
            //var sug = new sugared_expression(ind, mc, ind.source_context);
            ReplaceUsingParent(ind, mc);
            visit(mc);
        }
Example #14
0
        private expression CreateConditionFromCaseVariant(expression param, expression_list list)
        {
            var res = list.expressions.Aggregate(new bool_const(false) as expression, (acc, expr) =>
            {
                bin_expr currentExpr = null;
                diapason_expr diap   = expr as diapason_expr;
                if (diap != null)
                {
                    currentExpr = new bin_expr(new bin_expr(param, diap.left, Operators.GreaterEqual),
                                               new bin_expr(param, diap.right, Operators.LessEqual),
                                               Operators.LogicalAND);
                }
                else
                {
                    currentExpr = new bin_expr(param, expr, Operators.Equal);
                }

                return(new bin_expr(acc, currentExpr, Operators.LogicalOR));
            });

            return(res);
        }
Example #15
0
        public override void visit(index ind)
        {
            var indexCreation =
                new method_call(
                    new dot_node(
                        new ident("SystemIndex", ind.source_context),
                        new ident("Create", ind.source_context),
                        ind.source_context),
                    new expression_list(
                        new List <expression>()
            {
                ind.index_expr,
                new bool_const(ind.inverted, ind.source_context)
            },
                        ind.source_context),
                    ind.source_context);
            syntax_tree_node mc = null;
            var possibleIndexer = ind.Parent?.Parent;

            if (possibleIndexer != null && possibleIndexer is indexer indexer)
            {
                var reverseIndexMethodParams = new expression_list(indexer.dereferencing_value, ind.source_context);
                mc =
                    new method_call(
                        new dot_node(indexCreation, new ident("Reverse", ind.source_context)),
                        reverseIndexMethodParams,
                        ind.source_context);
            }
            else
            {
                mc = indexCreation;
            }
            //var sug = new sugared_expression(ind, mc, ind.source_context);
            Replace(ind, mc);
            visit(mc);
        }
        public override void visit(diapason_expr_new diap)
        {
            if (diap.Parent.Parent is pascal_set_constant)
            {
                // вернуть назад к diapason_expr
                var d = new diapason_expr(diap.left, diap.right, diap.source_context);
                ReplaceUsingParent(diap, d);
                visit(d);
                return;
            }

            var el = new expression_list();

            el.Add(diap.left, diap.left.source_context);
            el.Add(diap.right, diap.right.source_context);

            // Проблема в том, что тут тоже надо перепрошивать Parent!
            var mc = method_call.NewP(dot_node.NewP(new ident("PABCSystem", diap.source_context), new ident("InternalRange", diap.source_context), diap.source_context), el, diap.source_context);

            var sug = sugared_addressed_value.NewP(diap, mc, diap.source_context);

            ReplaceUsingParent(diap, sug);
            visit(mc); // обойти заменённое на предмет наличия такого же синтаксического сахара
        }
Example #17
0
		public virtual void post_do_visit(expression_list _expression_list)
		{
		}
Example #18
0
		public override void visit(expression_list _expression_list)
		{
			DefaultVisit(_expression_list);
			pre_do_visit(_expression_list);
			for (int i = 0; i < expressions.Count; i++)
				visit(expression_list.expressions[i]);
			post_do_visit(_expression_list);
		}
Example #19
0
 public virtual void visit(expression_list _expression_list)
 {
 }
Example #20
0
        protected override void DoAction(int action)
        {
            switch (action)
            {
            case 2: // module -> MODULE, ident, SEMICOLUMN, Declarations, BEGIN, StatementSequence,
                    //           END, ident, COMMA
            {
                if (ValueStack[ValueStack.Depth - 8].id.name != ValueStack[ValueStack.Depth - 2].id.name)
                {
                    PT.AddError("Имя " + ValueStack[ValueStack.Depth - 2].id.name + " должно совпадать с именем модуля " + ValueStack[ValueStack.Depth - 8].id.name, LocationStack[LocationStack.Depth - 2]);
                }

                // Подключение стандартной библиотеки
                ident_list il = new ident_list();
                il.Add(new ident("Oberon00System"));
                unit_or_namespace un = new unit_or_namespace(il);
                uses_list         ul = new uses_list();
                ul.units.Insert(0, un);

                // Формирование главного модуля
                var b = new block(ValueStack[ValueStack.Depth - 6].decl, ValueStack[ValueStack.Depth - 4].sl, LocationStack[LocationStack.Depth - 6].Merge(LocationStack[LocationStack.Depth - 2]));
                var r = new program_module(null, ul, b, null, CurrentLocationSpan);
                r.Language = LanguageId.Oberon00;
                root       = r;
            }
            break;

            case 3: // module -> INVISIBLE, expr
            {       // Для Intellisense
                root = ValueStack[ValueStack.Depth - 1].ex;
            }
            break;

            case 4: // ident -> ID
            {
                CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth - 1].sVal, CurrentLocationSpan);
            }
            break;

            case 5: // expr -> ident
            {
                CurrentSemanticValue.ex = ValueStack[ValueStack.Depth - 1].id;
            }
            break;

            case 6: // expr -> INTNUM
            {
                CurrentSemanticValue.ex = new int32_const(ValueStack[ValueStack.Depth - 1].iVal, CurrentLocationSpan);
            }
            break;

            case 7: // expr -> TRUE
            {
                CurrentSemanticValue.ex = new bool_const(true, CurrentLocationSpan);
            }
            break;

            case 8: // expr -> FALSE
            {
                CurrentSemanticValue.ex = new bool_const(false, CurrentLocationSpan);
            }
            break;

            case 9: // expr -> MINUS, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.Minus, CurrentLocationSpan);
            }
            break;

            case 10: // expr -> LPAREN, expr, RPAREN
            { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth - 2].ex; }
            break;

            case 11: // expr -> NOT, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalNOT, CurrentLocationSpan);
            }
            break;

            case 12: // expr -> expr, PLUS, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Plus, CurrentLocationSpan);
            }
            break;

            case 13: // expr -> expr, MINUS, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Minus, CurrentLocationSpan);
            }
            break;

            case 14: // expr -> expr, MULT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Multiplication, CurrentLocationSpan);
            }
            break;

            case 15: // expr -> expr, DIVIDE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.IntegerDivision, CurrentLocationSpan);
            }
            break;

            case 16: // expr -> expr, AND, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalAND, CurrentLocationSpan);
            }
            break;

            case 17: // expr -> expr, OR, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalOR, CurrentLocationSpan);
            }
            break;

            case 18: // expr -> expr, EQ, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Equal, CurrentLocationSpan);
            }
            break;

            case 19: // expr -> expr, NE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.NotEqual, CurrentLocationSpan);
            }
            break;

            case 20: // expr -> expr, LT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Less, CurrentLocationSpan);
            }
            break;

            case 21: // expr -> expr, LE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LessEqual, CurrentLocationSpan);
            }
            break;

            case 22: // expr -> expr, GT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Greater, CurrentLocationSpan);
            }
            break;

            case 23: // expr -> expr, GE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.GreaterEqual, CurrentLocationSpan);
            }
            break;

            case 24: // Assignment -> ident, ASSIGN, expr
            {
                CurrentSemanticValue.st = new assign(ValueStack[ValueStack.Depth - 3].id, ValueStack[ValueStack.Depth - 1].ex, Operators.Assignment, CurrentLocationSpan);
            }
            break;

            case 25: // IfStatement -> IF, expr, THEN, StatementSequence, END
            {
                CurrentSemanticValue.st = new if_node(ValueStack[ValueStack.Depth - 4].ex, ValueStack[ValueStack.Depth - 2].sl, null, CurrentLocationSpan);
            }
            break;

            case 26: // IfStatement -> IF, expr, THEN, StatementSequence, ELSE, StatementSequence, END
            {
                CurrentSemanticValue.st = new if_node(ValueStack[ValueStack.Depth - 6].ex, ValueStack[ValueStack.Depth - 4].sl, ValueStack[ValueStack.Depth - 2].sl, CurrentLocationSpan);
            }
            break;

            case 27: // WhileStatement -> WHILE, expr, DO, StatementSequence, END
            {
                CurrentSemanticValue.st = new while_node(ValueStack[ValueStack.Depth - 4].ex, ValueStack[ValueStack.Depth - 2].sl, WhileCycleType.While, CurrentLocationSpan);
            }
            break;

            case 28: // WriteStatement -> EXCLAMATION, expr
            {
                expression_list el = new expression_list(ValueStack[ValueStack.Depth - 1].ex);
                method_call     mc = new method_call(el);
                mc.dereferencing_value  = new ident("print");
                CurrentSemanticValue.st = mc;
            }
            break;

            case 29: // factparams -> expr
            {
                CurrentSemanticValue.el = new expression_list(ValueStack[ValueStack.Depth - 1].ex, CurrentLocationSpan);
            }
            break;

            case 30: // factparams -> factparams, COLUMN, expr
            {
                ValueStack[ValueStack.Depth - 3].el.Add(ValueStack[ValueStack.Depth - 1].ex, CurrentLocationSpan);
                CurrentSemanticValue.el = ValueStack[ValueStack.Depth - 3].el;
            }
            break;

            case 31: // ProcCallStatement -> ident, LPAREN, factparams, RPAREN
            {
                CurrentSemanticValue.st = new method_call(ValueStack[ValueStack.Depth - 4].id, ValueStack[ValueStack.Depth - 2].el, CurrentLocationSpan);
            }
            break;

            case 32: // EmptyStatement -> /* empty */
            {
                CurrentSemanticValue.st = new empty_statement();
            }
            break;

            case 39: // StatementSequence -> Statement
            {
                CurrentSemanticValue.sl = new statement_list(ValueStack[ValueStack.Depth - 1].st, CurrentLocationSpan);
            }
            break;

            case 40: // StatementSequence -> StatementSequence, SEMICOLUMN, Statement
            {
                ValueStack[ValueStack.Depth - 3].sl.Add(ValueStack[ValueStack.Depth - 1].st, CurrentLocationSpan);
                CurrentSemanticValue.sl = ValueStack[ValueStack.Depth - 3].sl;
            }
            break;

            case 41: // type -> BOOLEAN
            {
                CurrentSemanticValue.ntr = new named_type_reference("boolean", CurrentLocationSpan);
            }
            break;

            case 42: // type -> INTEGER
            {
                CurrentSemanticValue.ntr = new named_type_reference("integer", CurrentLocationSpan);
            }
            break;

            case 43: // IDList -> ident
            {
                CurrentSemanticValue.il = new ident_list(ValueStack[ValueStack.Depth - 1].id, CurrentLocationSpan);
            }
            break;

            case 44: // IDList -> IDList, COLUMN, ident
            {
                ValueStack[ValueStack.Depth - 3].il.Add(ValueStack[ValueStack.Depth - 1].id, CurrentLocationSpan);
                CurrentSemanticValue.il = ValueStack[ValueStack.Depth - 3].il;
            }
            break;

            case 45: // VarDecl -> IDList, COLON, type, SEMICOLUMN
            {
                CurrentSemanticValue.vds = new var_def_statement(ValueStack[ValueStack.Depth - 4].il, ValueStack[ValueStack.Depth - 2].ntr, null, definition_attribute.None, false, CurrentLocationSpan);
            }
            break;

            case 46: // VarDeclarations -> VarDecl
            {
                CurrentSemanticValue.vdss = new variable_definitions(ValueStack[ValueStack.Depth - 1].vds, CurrentLocationSpan);
            }
            break;

            case 47: // VarDeclarations -> VarDeclarations, VarDecl
            {
                ValueStack[ValueStack.Depth - 2].vdss.Add(ValueStack[ValueStack.Depth - 1].vds, CurrentLocationSpan);
                CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth - 2].vdss;
            }
            break;

            case 48: // ConstDecl -> ident, EQ, ConstExpr, SEMICOLUMN
            {
                CurrentSemanticValue.scd = new simple_const_definition(ValueStack[ValueStack.Depth - 4].id, ValueStack[ValueStack.Depth - 2].ex, CurrentLocationSpan);
            }
            break;

            case 50: // ConstDeclarations -> ConstDecl
            {
                CurrentSemanticValue.cdl = new consts_definitions_list(ValueStack[ValueStack.Depth - 1].scd, CurrentLocationSpan);
            }
            break;

            case 51: // ConstDeclarations -> ConstDeclarations, ConstDecl
            {
                ValueStack[ValueStack.Depth - 2].cdl.Add(ValueStack[ValueStack.Depth - 1].scd, CurrentLocationSpan);
                CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth - 2].cdl;
            }
            break;

            case 52: // ConstDeclarationsSect -> CONST, ConstDeclarations
            {
                CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth - 1].cdl;
                CurrentSemanticValue.cdl.source_context = CurrentLocationSpan;
            }
            break;

            case 53: // VarDeclarationsSect -> VAR, VarDeclarations
            {
                CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth - 1].vdss;
                CurrentSemanticValue.vdss.source_context = CurrentLocationSpan;
            }
            break;

            case 54: // Declarations -> VarDeclarationsSect
            {
                CurrentSemanticValue.decl = new declarations(ValueStack[ValueStack.Depth - 1].vdss, CurrentLocationSpan);
            }
            break;

            case 55: // Declarations -> ConstDeclarationsSect, VarDeclarationsSect
            {
                CurrentSemanticValue.decl = new declarations(ValueStack[ValueStack.Depth - 1].vdss, CurrentLocationSpan);
                CurrentSemanticValue.decl.Add(ValueStack[ValueStack.Depth - 1].vdss);
//		$$.source_context = @$;
            }
            break;
            }
        }
Example #21
0
 public virtual void visit(expression_list _expression_list)
 {
     DefaultVisit(_expression_list);
 }
Example #22
0
		public override void visit(expression_list _expression_list)
		{
			executer.visit(_expression_list);
			if (_expression_list.expressions != null)
			foreach (dynamic x in _expression_list.expressions)
				if(x != null)
					this.visit(x);
			if (_expression_list.attributes != null)
				this.visit((dynamic)_expression_list.attributes);
		}
Example #23
0
        protected override void DoAction(int action)
        {
            switch (action)
            {
            case 2: // module -> MODULE, ident, SEMICOLUMN, mainblock, ident, COMMA
            {
                if (ValueStack[ValueStack.Depth - 5].id.name != ValueStack[ValueStack.Depth - 2].id.name)
                {
                    PT.AddError("Имя " + ValueStack[ValueStack.Depth - 2].id.name + " должно совпадать с именем модуля " + ValueStack[ValueStack.Depth - 5].id.name, LocationStack[LocationStack.Depth - 2]);
                }

                // Подключение стандартного модуля Oberon00System, написанного на PascalABC.NET
                var ul = new uses_list("Oberon00System");

                // Формирование модуля основной программы (используется фабричный метод вместо конструктора)
                root = program_module.create(ValueStack[ValueStack.Depth - 5].id, ul, ValueStack[ValueStack.Depth - 3].bl, CurrentLocationSpan);
            }
            break;

            case 3: // module -> INVISIBLE, expr
            {       // Для Intellisense
                root = ValueStack[ValueStack.Depth - 1].ex;
            }
            break;

            case 4: // ident -> ID
            {
                CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth - 1].sVal, CurrentLocationSpan);
            }
            break;

            case 5: // mainblock -> Declarations, BEGIN, StatementSequence, END
            {
                CurrentSemanticValue.bl = new block(ValueStack[ValueStack.Depth - 4].decl, ValueStack[ValueStack.Depth - 2].sl, CurrentLocationSpan);
            }
            break;

            case 6: // SetConstant -> LBRACE, SetElemList, RBRACE
            {
                CurrentSemanticValue.sc = ValueStack[ValueStack.Depth - 2].sc;
            }
            break;

            case 7: // SetElemList -> SetElem
            {
                CurrentSemanticValue.sc = new pascal_set_constant();
                CurrentSemanticValue.sc.Add(ValueStack[ValueStack.Depth - 1].ex);
            }
            break;

            case 8: // SetElemList -> SetElemList, COLUMN, SetElem
            {
                CurrentSemanticValue.sc = ValueStack[ValueStack.Depth - 3].sc;
                CurrentSemanticValue.sc.Add(ValueStack[ValueStack.Depth - 1].ex);
            }
            break;

            case 9: // SetElemList -> /* empty */
            {
                CurrentSemanticValue.sc = new pascal_set_constant();
            }
            break;

            case 11: // SetElem -> expr, DOUBLEPOINT, expr
            {
                CurrentSemanticValue.ex = new diapason_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex);
            }
            break;

            case 12: // expr -> ident
            {
                CurrentSemanticValue.ex = ValueStack[ValueStack.Depth - 1].id;
            }
            break;

            case 13: // expr -> INTNUM
            {
                CurrentSemanticValue.ex = new int32_const(ValueStack[ValueStack.Depth - 1].iVal, CurrentLocationSpan);
            }
            break;

            case 14: // expr -> LONGINTNUM
            {
                CurrentSemanticValue.ex = new int64_const(ValueStack[ValueStack.Depth - 1].lVal, CurrentLocationSpan);
            }
            break;

            case 15: // expr -> REALNUM
            {
                CurrentSemanticValue.ex = new double_const(ValueStack[ValueStack.Depth - 1].rVal, CurrentLocationSpan);
            }
            break;

            case 16: // expr -> TRUE
            {
                CurrentSemanticValue.ex = new bool_const(true, CurrentLocationSpan);
            }
            break;

            case 17: // expr -> FALSE
            {
                CurrentSemanticValue.ex = new bool_const(false, CurrentLocationSpan);
            }
            break;

            case 18: // expr -> CHAR_CONST
            {
                CurrentSemanticValue.ex = new char_const(ValueStack[ValueStack.Depth - 1].cVal, CurrentLocationSpan);
            }
            break;

            case 19: // expr -> STRING_CONST
            {
                CurrentSemanticValue.ex = new string_const(ValueStack[ValueStack.Depth - 1].sVal, CurrentLocationSpan);
            }
            break;

            case 20: // expr -> MINUS, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.Minus, CurrentLocationSpan);
            }
            break;

            case 21: // expr -> PLUS, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.Plus, CurrentLocationSpan);
            }
            break;

            case 22: // expr -> LPAREN, expr, RPAREN
            { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth - 2].ex; }
            break;

            case 23: // expr -> NOT, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalNOT, CurrentLocationSpan);
            }
            break;

            case 24: // expr -> expr, PLUS, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Plus, CurrentLocationSpan);
            }
            break;

            case 25: // expr -> expr, MINUS, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Minus, CurrentLocationSpan);
            }
            break;

            case 26: // expr -> expr, MULT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Multiplication, CurrentLocationSpan);
            }
            break;

            case 27: // expr -> expr, DIVIDE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Division, CurrentLocationSpan);
            }
            break;

            case 28: // expr -> expr, DIV, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.IntegerDivision, CurrentLocationSpan);
            }
            break;

            case 29: // expr -> expr, MOD, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.ModulusRemainder, CurrentLocationSpan);
            }
            break;

            case 30: // expr -> expr, AND, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalAND, CurrentLocationSpan);
            }
            break;

            case 31: // expr -> expr, OR, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalOR, CurrentLocationSpan);
            }
            break;

            case 32: // expr -> expr, EQ, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Equal, CurrentLocationSpan);
            }
            break;

            case 33: // expr -> expr, NE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.NotEqual, CurrentLocationSpan);
            }
            break;

            case 34: // expr -> expr, LT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Less, CurrentLocationSpan);
            }
            break;

            case 35: // expr -> expr, LE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LessEqual, CurrentLocationSpan);
            }
            break;

            case 36: // expr -> expr, GT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Greater, CurrentLocationSpan);
            }
            break;

            case 37: // expr -> expr, GE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.GreaterEqual, CurrentLocationSpan);
            }
            break;

            case 39: // Assignment -> ident, ASSIGN, expr
            {
                CurrentSemanticValue.st = new assign(ValueStack[ValueStack.Depth - 3].id, ValueStack[ValueStack.Depth - 1].ex, Operators.Assignment, CurrentLocationSpan);
            }
            break;

            case 40: // IfStatement -> IF, expr, THEN, StatementSequence, END
            {
                CurrentSemanticValue.st = new if_node(ValueStack[ValueStack.Depth - 4].ex, ValueStack[ValueStack.Depth - 2].sl, null, CurrentLocationSpan);
            }
            break;

            case 41: // IfStatement -> IF, expr, THEN, StatementSequence, ELSE, StatementSequence, END
            {
                CurrentSemanticValue.st = new if_node(ValueStack[ValueStack.Depth - 6].ex, ValueStack[ValueStack.Depth - 4].sl, ValueStack[ValueStack.Depth - 2].sl, CurrentLocationSpan);
            }
            break;

            case 42: // WhileStatement -> WHILE, expr, DO, StatementSequence, END
            {
                CurrentSemanticValue.st = new while_node(ValueStack[ValueStack.Depth - 4].ex, ValueStack[ValueStack.Depth - 2].sl, WhileCycleType.While, CurrentLocationSpan);
            }
            break;

            case 43: // WriteStatement -> EXCLAMATION, expr
            {
                expression_list el = new expression_list(ValueStack[ValueStack.Depth - 1].ex);
                method_call     mc = new method_call(el);
                mc.dereferencing_value  = new ident("print");
                CurrentSemanticValue.st = mc;
            }
            break;

            case 44: // factparams -> expr
            {
                CurrentSemanticValue.el = new expression_list(ValueStack[ValueStack.Depth - 1].ex, CurrentLocationSpan);
            }
            break;

            case 45: // factparams -> factparams, COLUMN, expr
            {
                ValueStack[ValueStack.Depth - 3].el.Add(ValueStack[ValueStack.Depth - 1].ex, CurrentLocationSpan);
                CurrentSemanticValue.el = ValueStack[ValueStack.Depth - 3].el;
            }
            break;

            case 46: // ProcCallStatement -> ident, LPAREN, factparams, RPAREN
            {
                CurrentSemanticValue.st = new method_call(ValueStack[ValueStack.Depth - 4].id, ValueStack[ValueStack.Depth - 2].el, CurrentLocationSpan);
            }
            break;

            case 47: // EmptyStatement -> /* empty */
            {
                CurrentSemanticValue.st = new empty_statement();
            }
            break;

            case 54: // StatementSequence -> Statement
            {
                CurrentSemanticValue.sl = new statement_list(ValueStack[ValueStack.Depth - 1].st, CurrentLocationSpan);
            }
            break;

            case 55: // StatementSequence -> StatementSequence, SEMICOLUMN, Statement
            {
                ValueStack[ValueStack.Depth - 3].sl.Add(ValueStack[ValueStack.Depth - 1].st, CurrentLocationSpan);
                CurrentSemanticValue.sl = ValueStack[ValueStack.Depth - 3].sl;
            }
            break;

            case 56: // type -> ID
            {
                CurrentSemanticValue.ntr = new named_type_reference(PT.InternalTypeName(ValueStack[ValueStack.Depth - 1].sVal), CurrentLocationSpan);
            }
            break;

            case 57: // IDList -> ident
            {
                CurrentSemanticValue.il = new ident_list(ValueStack[ValueStack.Depth - 1].id, CurrentLocationSpan);
            }
            break;

            case 58: // IDList -> IDList, COLUMN, ident
            {
                ValueStack[ValueStack.Depth - 3].il.Add(ValueStack[ValueStack.Depth - 1].id, CurrentLocationSpan);
                CurrentSemanticValue.il = ValueStack[ValueStack.Depth - 3].il;
            }
            break;

            case 59: // VarDecl -> IDList, COLON, type, SEMICOLUMN
            {
                CurrentSemanticValue.vds = new var_def_statement(ValueStack[ValueStack.Depth - 4].il, ValueStack[ValueStack.Depth - 2].ntr, null, definition_attribute.None, false, CurrentLocationSpan);
            }
            break;

            case 60: // VarDeclarations -> VarDecl
            {
                CurrentSemanticValue.vdss = new variable_definitions(ValueStack[ValueStack.Depth - 1].vds, CurrentLocationSpan);
            }
            break;

            case 61: // VarDeclarations -> VarDeclarations, VarDecl
            {
                ValueStack[ValueStack.Depth - 2].vdss.Add(ValueStack[ValueStack.Depth - 1].vds, CurrentLocationSpan);
                CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth - 2].vdss;
            }
            break;

            case 62: // ConstDecl -> ident, EQ, ConstExpr, SEMICOLUMN
            {
                CurrentSemanticValue.scd = new simple_const_definition(ValueStack[ValueStack.Depth - 4].id, ValueStack[ValueStack.Depth - 2].ex, CurrentLocationSpan);
            }
            break;

            case 64: // ConstDeclarations -> ConstDecl
            {
                CurrentSemanticValue.cdl = new consts_definitions_list(ValueStack[ValueStack.Depth - 1].scd, CurrentLocationSpan);
            }
            break;

            case 65: // ConstDeclarations -> ConstDeclarations, ConstDecl
            {
                ValueStack[ValueStack.Depth - 2].cdl.Add(ValueStack[ValueStack.Depth - 1].scd, CurrentLocationSpan);
                CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth - 2].cdl;
            }
            break;

            case 66: // ConstDeclarationsSect -> CONST, ConstDeclarations
            {
                CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth - 1].cdl;
                CurrentSemanticValue.cdl.source_context = CurrentLocationSpan;
            }
            break;

            case 67: // VarDeclarationsSect -> VAR, VarDeclarations
            {
                CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth - 1].vdss;
                CurrentSemanticValue.vdss.source_context = CurrentLocationSpan;
            }
            break;

            case 68: // DeclarationsSect -> VarDeclarationsSect
            {
                CurrentSemanticValue.decsec = ValueStack[ValueStack.Depth - 1].vdss;
            }
            break;

            case 69: // DeclarationsSect -> ConstDeclarationsSect
            {
                CurrentSemanticValue.decsec = ValueStack[ValueStack.Depth - 1].cdl;
            }
            break;

            case 70: // DeclarationsSect -> ProcedureDeclarationSect
            {
                CurrentSemanticValue.decsec = ValueStack[ValueStack.Depth - 1].pd;
            }
            break;

            case 71: // Declarations -> /* empty */
            {
                CurrentSemanticValue.decl = new declarations();
            }
            break;

            case 72: // Declarations -> Declarations, DeclarationsSect
            {
                if (ValueStack[ValueStack.Depth - 1].decsec != null)
                {
                    ValueStack[ValueStack.Depth - 2].decl.Add(ValueStack[ValueStack.Depth - 1].decsec);
                }
                CurrentSemanticValue.decl = ValueStack[ValueStack.Depth - 2].decl;
                CurrentSemanticValue.decl.source_context = CurrentLocationSpan;                 // Необходимо показать место в программе, т.к. невно это не сделано
                // (например, в конструкторе)
            }
            break;

            case 73: // ProcedureDeclarationSect -> PROCEDURE, ident, maybeformalparams, maybereturn,
                     //                             SEMICOLUMN, mainblock, ident, SEMICOLUMN
            {
            }
            break;

            case 74: // maybeformalparams -> /* empty */
            {
                //$$ = null;
            }
            break;

            case 75: // maybeformalparams -> LPAREN, FPList, RPAREN
            {
                //$$ = $2;
            }
            break;

            case 76: // maybereturn -> /* empty */
            {
            }
            break;

            case 77: // maybereturn -> COLUMN, type
            {
            }
            break;

            case 78: // FPList -> FPSect
            {
            }
            break;

            case 79: // FPList -> FPList, SEMICOLUMN, FPSect
            {
            }
            break;

            case 80: // FPSect -> maybevar, IDList, COLON, type
            {
            }
            break;

            case 81: // maybevar -> /* empty */
            {
                CurrentSemanticValue.bVal = false;
            }
            break;

            case 82: // maybevar -> VAR
            {
                CurrentSemanticValue.bVal = true;
            }
            break;
            }
        }
Example #24
0
 public override void visit(expression_list _expression_list)
 {
     prepare_collection(_expression_list.expressions, "expressions");
 }
Example #25
0
 public override void visit(expression_list _expression_list)
 {
     get_count(_expression_list.expressions);
 }
		public virtual void visit(expression_list _expression_list)
		{
			DefaultVisit(_expression_list);
		}
        public ident func_decl_lambda(object lr0, object lr2)
        {
            statement_list    _statement_list    = (statement_list)lr2;
            expression_list   _expression_list   = new expression_list();
            ident_list        _i_l               = new ident_list();
            formal_parameters _formal_parameters = new formal_parameters();

            if (lr0 != null)
            {
                List <object> ar = (List <object>)lr0;
                for (int i = 0; i < ar.Count; i++)
                {
                    if (ar[i] is ident)
                    {
                        _i_l.idents.Add((ident)ar[i]);
                    }
                    else
                    {
                        _i_l.idents.Add(((var_def_statement)ar[i]).vars.idents[0]);
                    }
                }

                for (int i = 0; i < _i_l.idents.Count; i++)
                {
                    _expression_list.expressions.Add(_i_l.idents[i]);
                }

                for (int i = 0; i < ar.Count; i++)
                {
                    ident_list _ident_list = new ident_list();
                    ident      id          = _i_l.idents[i];
                    _ident_list.idents.Add(id);
                    string           name_param        = id.name;
                    typed_parameters _typed_parameters = null;
                    int k = 0;
                    {
                        named_type_reference _named_type_reference = new named_type_reference();
                        type_definition      t_d = new type_definition();
                        if (ar[i] is ident)
                        {
                            ident idtype = new ident("object");
                            _named_type_reference.names.Add(idtype);
                            t_d = (type_definition)_named_type_reference;
                        }
                        else
                        {
                            t_d = ((var_def_statement)ar[i]).vars_type;
                        }
                        _typed_parameters = new typed_parameters(_ident_list, t_d, parametr_kind.none, null);
                        //parsertools.create_source_context(_typed_parameters, _ident_list, t_d);
                    }
                    _formal_parameters.params_list.Add(_typed_parameters);
                }
            }
            //////////////////////////
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("object");

            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            /////////////////////////////
            lambda_num++;
            function_lambda_definition _procedure_definition = new function_lambda_definition();

            _procedure_definition.formal_parameters = _formal_parameters;
            _procedure_definition.return_type       = (type_definition)_named_type_reference1;
            _procedure_definition.ident_list        = _i_l;
            _procedure_definition.proc_body         = null;
            _procedure_definition.parameters        = _expression_list;
            _procedure_definition.lambda_name       = "__lambda__" + lambda_num;
            //new function_lambda_definition(_formal_parameters, (type_definition)_named_type_reference1, _i_l, null, _expression_list, "lambda" + lambda_num);
            object rt = _i_l;

            _procedure_definition.proc_body = _statement_list;

            //////////////////////////////vnutrennie lambda
            if (_procedure_definition.defs == null)
            {
                _procedure_definition.defs = new List <declaration>();
            }
            while (pascalABC_lambda_definitions.Count > 0 && pascalABC_lambda_definitions[pascalABC_lambda_definitions.Count - 1] != null)
            {
                _procedure_definition.defs.Add(lambda((function_lambda_definition)pascalABC_lambda_definitions[pascalABC_lambda_definitions.Count - 1]));
                pascalABC_lambda_definitions.RemoveAt(pascalABC_lambda_definitions.Count - 1);
            }
            if (pascalABC_lambda_definitions.Count > 0 && pascalABC_lambda_definitions[pascalABC_lambda_definitions.Count - 1] == null)
            {
                pascalABC_lambda_definitions.RemoveAt(pascalABC_lambda_definitions.Count - 1);
            }
            pascalABC_lambda_definitions.Add(_procedure_definition);
            ///////////////////////////////////////////////
            //parsertools.create_source_context(_procedure_definition, _expression_list, rt);
            ident _name = new ident(_procedure_definition.lambda_name);

            if (lr0 != null)
            {
                _name.source_context = _i_l.idents[0].source_context;
            }
            return(_name);
        }
Example #28
0
		public virtual void visit(expression_list _expression_list)
		{
		}