示例#1
0
 public static formal_parameters BuildFormalParameters(List<ident> names, List<type_definition> types)
 {
     var fp = new formal_parameters();
     for (int i = 0; i < names.Count; i++)
         fp.Add(new typed_parameters(names[i], types[i]));
     return fp;
 }
 public override void visit(formal_parameters fp)
 {
     foreach (var id in fp.params_list.SelectMany(tp => tp.idents.idents))
     {
         CheckVariableAlreadyDefined(id);
         UpperBlockNames.Add(id.name);
     }
 }
        public procedure_definition lambda(function_lambda_definition _function_lambda_definition)
        {
            procedure_definition _func_def     = new procedure_definition();
            method_name          _method_name1 = new method_name(null, null, new ident(_function_lambda_definition.lambda_name), null);
            //parsertools.create_source_context(_method_name1, _method_name1.meth_name, _method_name1.meth_name);
            function_header _function_header1 = new function_header();

            object rt1 = new object();

            _function_header1.name = _method_name1;
            if (_function_header1.name.meth_name is template_type_name)
            {
                _function_header1.template_args = (_function_header1.name.meth_name as template_type_name).template_args;
                ident id = new ident(_function_header1.name.meth_name.name);
                //parsertools.create_source_context(id, _function_header1.name.meth_name, _function_header1.name.meth_name);
                _function_header1.name.meth_name = id;
            }

            formal_parameters fps = new PascalABCCompiler.SyntaxTree.formal_parameters();

            _function_header1.parameters = _function_lambda_definition.formal_parameters;//fps;

            /*SyntaxTree.named_type_reference _named_type_reference = new SyntaxTree.named_type_reference();
             * SyntaxTree.ident idtype = new SyntaxTree.ident("object");
             * _named_type_reference.source_context = idtype.source_context;
             * _named_type_reference.names.Add(idtype);
             * rt1 = _named_type_reference;
             * _function_header1.return_type = (SyntaxTree.type_definition)_named_type_reference;*/
            _function_header1.return_type = _function_lambda_definition.return_type;

            _function_header1.of_object     = false;
            _function_header1.class_keyword = false;
            token_info _token_info = new token_info("function");
            //_token_info.source_context = parsertools.GetTokenSourceContext();
            //parsertools.create_source_context(_function_header1, _token_info, _token_info);

            block          _block1 = new block(null, null);
            statement_list sl1     = new statement_list();

            sl1.subnodes.Add(_function_lambda_definition.proc_body);
            _block1.program_code  = sl1;
            _func_def.proc_header = _function_header1;
            _func_def.proc_body   = (proc_block)_block1;
            if (_function_lambda_definition.defs != null)
            {
                if (((block)_func_def.proc_body).defs == null)
                {
                    ((block)_func_def.proc_body).defs = new declarations();
                }
                for (int l = 0; l < _function_lambda_definition.defs.Count; l++)
                {
                    ((block)_func_def.proc_body).defs.defs.Add(_function_lambda_definition.defs[l] as procedure_definition);
                }
            }
            _function_lambda_definition.proc_definition = _func_def;
            //parsertools.create_source_context(_func_def, _function_header1, _function_header1);
            return(_func_def);
        }
 public override void visit(formal_parameters fp)
 {
     if (!first_time_visit_function_header) // чтобы в лямбдах не заходить в формальные параметры. Во вложенных тоже не зайдёт
         return;
     // SSM переименование формальных параметров (нужно если мы их изменяем внутри)
     ++CurrentLevel;
     BlockNamesStack.Add(new Dictionary<string, string>());
     if (fp != null)
     {
         var fpids = fp.params_list.SelectMany(tp => tp.idents.idents);
         foreach (var v in fpids)
         {
             BlockNamesStack[CurrentLevel].Add(v.name, "$fp_"+v.name);
         }
     }
     // DO NOTHING
 }
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////
        //CreateNonTerminalObject
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////

        public Object CreateNonTerminalObject(int ReductionRuleIndex)
        {
            switch (ReductionRuleIndex)
            {
                case (int)RuleConstants.RULE_SEPARATOR_TK_SEMICOLON:
                    //<Separator> ::= 'tk_SemiColon'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_SEPARATOR_TK_NEWLINE:
                    //<Separator> ::= 'tk_NewLine'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_SEPARATORS:
                    //<Separators> ::= <Separators> <Separator>
                    return LRParser.GetReductionSyntaxNode(1);

                case (int)RuleConstants.RULE_SEPARATORS2:
                    //<Separators> ::= <Separator>
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_SEPARATORSOPT:
                    //<Separators Opt> ::= <Separator> <Separators Opt>
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_SEPARATORSOPT2:
                    //<Separators Opt> ::= 
                    return null;

                case (int)RuleConstants.RULE_PROGRAM_TK_ALG_TK_IDENTIFIER_TK_BEGIN_TK_END:
                    //<Program> ::= <Separators Opt> <Global_part> 'tk_alg' 'tk_Identifier' <Separators> 'tk_begin' <Statements> 'tk_end' <Sub_declarations>
                    {
                        program_module _program_module;
                        block _block;
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(6));
                        program_name _program_name = new program_name((ident)LRParser.GetReductionSyntaxNode(3));

                        if ((_units[this.unit_number - 1] as unit_data).initialization.subnodes.Count != 0)
                            _statement_list.subnodes.InsertRange(0, (_units[this.unit_number - 1] as unit_data).initialization.subnodes);

                        if ((_units[this.unit_number - 1] as unit_data).sub_progs.defs.Count != 0)
                            _block = new block((_units[this.unit_number - 1] as unit_data).sub_progs, _statement_list);
                        else
                            _block = new block(null, _statement_list);

                        (_units[this.unit_number - 1] as unit_data).used_units.idents.Add(new ident("MathForKumir"));

                        if ((_units[this.unit_number - 1] as unit_data).used_units.idents.Count != 0)
                        {
                            unit_or_namespace _unit_or_namespace;
                            uses_list _uses_list = new uses_list();

                            for (int i = 0; i < (_units[this.unit_number - 1] as unit_data).used_units.idents.Count; i++)
                            {
                                ident_list _ident_list = new ident_list();
                                _ident_list.idents.Add((_units[this.unit_number - 1] as unit_data).used_units.idents[i]);
                                _unit_or_namespace = new unit_or_namespace(_ident_list);
                                _uses_list.units.Add(_unit_or_namespace);
                            }
                            _program_module = new program_module(_program_name, _uses_list, _block, null);

                        }
                        else
                            _program_module = new program_module(_program_name, null, _block, null);
                        declarations _declarations = new declarations();
                        _program_module.Language = LanguageId.PascalABCNET;
                        parsertools.create_source_context(_program_module, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(3)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(8), LRParser.GetReductionSyntaxNode(7), LRParser.GetReductionSyntaxNode(6)));
                        parsertools.create_source_context(_block, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(2)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(8), LRParser.GetReductionSyntaxNode(7)));
                        parsertools.create_source_context(_program_name, LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(3));
                        return _program_module;
                    }

                case (int)RuleConstants.RULE_PROGRAM_TK_ISP_TK_IDENTIFIER_TK_END:
                    //<Program> ::= <Separators Opt> 'tk_isp' 'tk_Identifier' <Separators> <Global_part> <Sub_declarations> 'tk_end'
                    {
                        interface_node _interface_node;
                        (_units[this.unit_number - 1] as unit_data).used_units.idents.Add(new ident("MathForKumir"));
                        if ((_units[this.unit_number - 1] as unit_data).used_units.idents.Count > 0)
                        {
                            unit_or_namespace _unit_or_namespace;
                            uses_list _uses_list = new uses_list();
                            for (int i = 0; i < (_units[this.unit_number - 1] as unit_data).used_units.idents.Count; i++)
                            {
                                ident_list _ident_list = new ident_list();
                                _ident_list.idents.Add((_units[this.unit_number - 1] as unit_data).used_units.idents[i]);
                                _unit_or_namespace = new unit_or_namespace(_ident_list);
                                _uses_list.units.Add(_unit_or_namespace);
                            }
                            _interface_node = new interface_node((_units[this.unit_number - 1] as unit_data).sub_progs, _uses_list, null);
                        }
                        else
                            _interface_node = new interface_node((_units[this.unit_number - 1] as unit_data).sub_progs, null, null);
                        unit_module _unit_module = new unit_module(new unit_name((ident)LRParser.GetReductionSyntaxNode(2), 0), _interface_node, null, (_units[this.unit_number - 1] as unit_data).initialization, null);
                        _unit_module.Language = LanguageId.PascalABCNET;
                        unit_name _unit_name = new unit_name((ident)LRParser.GetReductionSyntaxNode(2), 0);
                        parsertools.create_source_context(_unit_module, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(3)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(6), LRParser.GetReductionSyntaxNode(5)));
                        parsertools.create_source_context(_unit_name, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));

                        return _unit_module;
                    }

                case (int)RuleConstants.RULE_PROCEDURE_TK_ALG_TK_IDENTIFIER_TK_ROUNDOPEN_TK_ROUNDCLOSE_TK_BEGIN_TK_END:
                    //<Procedure> ::= 'tk_alg' 'tk_Identifier' 'tk_RoundOpen' <Formal_list> 'tk_RoundClose' <Separators> 'tk_begin' <Statements> 'tk_end'
                    {
                        method_name _method_name = new method_name(null, (ident)LRParser.GetReductionSyntaxNode(1), null);
                        procedure_header _procedure_header = new procedure_header(GetFormals(LRParser.GetReductionSyntaxNode(3)), null, _method_name, false, false, null,null);
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(7));
                        block _block = new block(null, _statement_list);

                        procedure_definition _procedure_definition = new procedure_definition(_procedure_header, _block);
                        parsertools.create_source_context(_method_name, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_procedure_header, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(4));
                        parsertools.create_source_context(_procedure_definition, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(8));
                        parsertools.create_source_context(_block, LRParser.GetReductionSyntaxNode(6), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(8), LRParser.GetReductionSyntaxNode(7)));
                        (_units[this.unit_number - 1] as unit_data).sub_progs.defs.Add(_procedure_definition);

                        return _procedure_definition;
                    }

                case (int)RuleConstants.RULE_PROCEDURE_TK_ALG_TK_IDENTIFIER_TK_BEGIN_TK_END:
                    //<Procedure> ::= 'tk_alg' 'tk_Identifier' <Separators> 'tk_begin' <Statements> 'tk_end'
                    {
                        method_name _method_name = new method_name(null, (ident)LRParser.GetReductionSyntaxNode(1), null);
                        procedure_header _procedure_header = new procedure_header(null, null, _method_name, false, false, null,null);
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(4));
                        block _block = new block(null, _statement_list);

                        procedure_definition _procedure_definition = new procedure_definition(_procedure_header, _block);

                        parsertools.create_source_context(_method_name, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_procedure_header, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_procedure_definition, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(5));
                        parsertools.create_source_context(_block, LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(5));
                        (_units[this.unit_number - 1] as unit_data).sub_progs.defs.Add(_procedure_definition);
                        declarations _declarations = new declarations();
                        _declarations.defs.Add(_procedure_definition);
                        parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(5), LRParser.GetReductionSyntaxNode(4)));

                        return _procedure_definition;
                    }

                case (int)RuleConstants.RULE_FUNCTION_TK_ALG_TK_IDENTIFIER_TK_ROUNDOPEN_TK_ROUNDCLOSE_TK_BEGIN_TK_END:
                    //<Function> ::= 'tk_alg' <Type> 'tk_Identifier' 'tk_RoundOpen' <Formal_list> 'tk_RoundClose' <Separators> 'tk_begin' <Statements> 'tk_end'
                    {
                        method_name _method_name = new method_name(null, LRParser.GetReductionSyntaxNode(2) as ident, null);
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(1)).text.ToLower());

                        function_header _function_header = new function_header(_named_type_reference);
                        _function_header.of_object = false;
                        _function_header.name = _method_name;
                        _function_header.parameters = GetFormals(LRParser.GetReductionSyntaxNode(4));

                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(8));
                        block _block = new block(null, _statement_list);

                        procedure_definition _procedure_definition = new procedure_definition(_function_header, _block);
                        parsertools.create_source_context(_method_name, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_function_header, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(5));
                        parsertools.create_source_context(_procedure_definition, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(9));
                        parsertools.create_source_context(_block, LRParser.GetReductionSyntaxNode(7), LRParser.GetReductionSyntaxNode(9));
                        (_units[this.unit_number - 1] as unit_data).sub_progs.defs.Add(_procedure_definition);
                        declarations _declarations = new declarations();
                        _declarations.defs.Add(_procedure_definition);
                        parsertools.create_source_context(_declarations, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(9));
                        return _procedure_definition;
                    }

                case (int)RuleConstants.RULE_FUNCTION_TK_ALG_TK_IDENTIFIER_TK_BEGIN_TK_END:
                    //<Function> ::= 'tk_alg' <Type> 'tk_Identifier' <Separators> 'tk_begin' <Statements> 'tk_end'
                    {
                        method_name _method_name = new method_name(null, LRParser.GetReductionSyntaxNode(2) as ident, null);
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(1)).text.ToLower());

                        function_header _function_header = new function_header(_named_type_reference);
                        _function_header.of_object = false;
                        _function_header.name = _method_name;

                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(5));
                        block _block = new block(null, _statement_list);

                        procedure_definition _procedure_definition = new procedure_definition(_function_header, _block);
                        parsertools.create_source_context(_method_name, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_function_header, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_procedure_definition, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(6));
                        parsertools.create_source_context(_block, LRParser.GetReductionSyntaxNode(4), LRParser.GetReductionSyntaxNode(6));
                        (_units[this.unit_number - 1] as unit_data).sub_progs.defs.Add(_procedure_definition);
                        return _procedure_definition;
                    }

                case (int)RuleConstants.RULE_SUB_DECLARATIONS:
                    //<Sub_declarations> ::= 
                    return null;

                case (int)RuleConstants.RULE_SUB_DECLARATIONS2:
                    //<Sub_declarations> ::= <Sub_declarations> <Procedure>
                    {
                        declarations _declarations;
                        if (LRParser.GetReductionSyntaxNode(0) != null)
                        {
                            _declarations = (declarations)LRParser.GetReductionSyntaxNode(0);
                            _declarations.defs.Add((declaration)LRParser.GetReductionSyntaxNode(1));
                        }
                        else
                        {
                            _declarations = new declarations();
                            _declarations.defs.Add((declaration)LRParser.GetReductionSyntaxNode(1));
                        }
                        // 
                        parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1)), LRParser.GetReductionSyntaxNode(1));
                        return _declarations;
                    }

                case (int)RuleConstants.RULE_SUB_DECLARATIONS3:
                    //<Sub_declarations> ::= <Sub_declarations> <Function>
                    {
                        declarations _declarations;
                        if (LRParser.GetReductionSyntaxNode(0) != null)
                        {
                            _declarations = (declarations)LRParser.GetReductionSyntaxNode(0);
                            _declarations.defs.Add((declaration)LRParser.GetReductionSyntaxNode(1));
                        }
                        else
                        {
                            _declarations = new declarations();
                            _declarations.defs.Add((declaration)LRParser.GetReductionSyntaxNode(1));
                        }
                        parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1)), LRParser.GetReductionSyntaxNode(1));
                        return _declarations;
                    }

                case (int)RuleConstants.RULE_SUB_DECLARATIONS4:
                    //<Sub_declarations> ::= <Sub_declarations> <Separators>
                    {
                        declarations _declarations;
                        if (LRParser.GetReductionSyntaxNode(0) != null)
                        {
                            _declarations = (declarations)LRParser.GetReductionSyntaxNode(0);
                        }
                        else
                        {
                            _declarations = new declarations();

                        }
                        parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0)));
                        return _declarations;
                    }


                case (int)RuleConstants.RULE_TYPE_TK_INTEGER_TYPE:
                    //<Type> ::= 'tk_integer_type'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_TYPE_TK_REAL_TYPE:
                    //<Type> ::= 'tk_real_type'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_TYPE_TK_BOOLEAN_TYPE:
                    //<Type> ::= 'tk_boolean_type'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_TYPE_TK_CHAR_TYPE:
                    //<Type> ::= 'tk_char_type'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_TYPE_TK_STRING_TYPE:
                    //<Type> ::= 'tk_string_type'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_DIAP_TK_COLON:
                    //<Diap> ::= <Expression> 'tk_Colon' <Expression>
                    {
                        diapason _diapason = new diapason(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression);

                        parsertools.create_source_context(_diapason, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _diapason;
                    }

                case (int)RuleConstants.RULE_DIAP_LIST_TK_COMMA:
                    //<Diap_list> ::= <Diap_list> 'tk_Comma' <Diap>
                    {
                        indexers_types _indexers_types = GetIndexers(LRParser.GetReductionSyntaxNode(0));
                        _indexers_types.indexers.Add(LRParser.GetReductionSyntaxNode(2) as diapason);

                        parsertools.create_source_context(_indexers_types, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _indexers_types;
                    }

                case (int)RuleConstants.RULE_DIAP_LIST:
                    //<Diap_list> ::= <Diap>
                    {
                        indexers_types _indexers_types = new indexers_types();
                        _indexers_types.indexers.Add(LRParser.GetReductionSyntaxNode(0) as diapason);

                        parsertools.create_source_context(_indexers_types, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _indexers_types;
                    }

                case (int)RuleConstants.RULE_LIST_OF_EXPRESSIONS_TK_COMMA:
                    //<List_of_expressions> ::= <List_of_expressions> 'tk_Comma' <Expression>
                    {
                        expression_list _expression_list = GetExpressions(LRParser.GetReductionSyntaxNode(0));
                        _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(2) as expression);

                        parsertools.create_source_context(_expression_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _expression_list;
                    }

                case (int)RuleConstants.RULE_LIST_OF_EXPRESSIONS:
                    //<List_of_expressions> ::= <Expression>
                    {
                        expression_list _expression_list = new expression_list();
                        _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);

                        _expression_list.source_context = ((expression)LRParser.GetReductionSyntaxNode(0)).source_context;
                        return _expression_list;
                    }

                case (int)RuleConstants.RULE_ID_LIST1_TK_IDENTIFIER:
                    //<Id_list1> ::= 'tk_Identifier'
                    {
                        ident_list _ident_list = new ident_list();
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        _ident_list.source_context = ((ident)LRParser.GetReductionSyntaxNode(0)).source_context;
                        return _ident_list;
                    }

                case (int)RuleConstants.RULE_ID_LIST1_TK_IDENTIFIER_TK_COMMA:
                    //<Id_list1> ::= 'tk_Identifier' 'tk_Comma' <Id_list1>
                    {
                        ident_list _ident_list = GetIdents(LRParser.GetReductionSyntaxNode(2));
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        parsertools.create_source_context(_ident_list, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(0)));
                        return _ident_list;
                    }

                case (int)RuleConstants.RULE_ARRAY_LIST1_TK_IDENTIFIER_TK_SQUAREOPEN_TK_SQUARECLOSE:
                    //<Array_list1> ::= 'tk_Identifier' 'tk_SquareOpen' <Diap_list> 'tk_SquareClose'
                    {
                        ident_list _ident_list = new ident_list();
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        indexers_types _indexers_types = GetIndexers(LRParser.GetReductionSyntaxNode(2));
                        array_type _array_type = new array_type(_indexers_types, null);

                        var_def_statement _var_def_statement = new var_def_statement(_ident_list, _array_type, null, definition_attribute.None, false);
                        variable_definitions _variable_definitions = new variable_definitions();
                        _variable_definitions.var_definitions.Add(_var_def_statement);

                        //_ident_list.source_context = ((ident)LRParser.GetReductionSyntaxNode(0)).source_context;
                        parsertools.create_source_context(_array_type, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        //parsertools.create_source_context(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_ident_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        parsertools.create_source_context(_indexers_types, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_var_def_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _variable_definitions;
                    }

                case (int)RuleConstants.RULE_ARRAY_LIST1_TK_IDENTIFIER_TK_SQUAREOPEN_TK_SQUARECLOSE_TK_COMMA:
                    //<Array_list1> ::= 'tk_Identifier' 'tk_SquareOpen' <Diap_list> 'tk_SquareClose' 'tk_Comma' <Array_list1>
                    {
                        ident_list _ident_list = new ident_list();
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        indexers_types _indexers_types = GetIndexers(LRParser.GetReductionSyntaxNode(2));
                        array_type _array_type = new array_type(_indexers_types, null);

                        var_def_statement _var_def_statement = new var_def_statement(_ident_list, _array_type, null, definition_attribute.None, false);
                        variable_definitions _variable_definitions = (LRParser.GetReductionSyntaxNode(5) as variable_definitions);
                        _variable_definitions.var_definitions.Add(_var_def_statement);

                        //_ident_list.source_context = ((ident)LRParser.GetReductionSyntaxNode(0)).source_context;
                        parsertools.create_source_context(_array_type, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_ident_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        //parsertools.create_source_context(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_indexers_types, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(5));
                        parsertools.create_source_context(_var_def_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _variable_definitions;
                    }

                case (int)RuleConstants.RULE_ID_LIST2_TK_IDENTIFIER_TK_COMMA:
                    //<Id_list2> ::= 'tk_Identifier' 'tk_Comma'
                    {
                        ident_list _ident_list = new ident_list();
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        _ident_list.source_context = ((ident)LRParser.GetReductionSyntaxNode(0)).source_context;
                        return _ident_list;
                    }

                case (int)RuleConstants.RULE_ID_LIST2_TK_IDENTIFIER_TK_COMMA2:
                    //<Id_list2> ::= 'tk_Identifier' 'tk_Comma' <Id_list2>
                    {
                        ident_list _ident_list = GetIdents(LRParser.GetReductionSyntaxNode(2));
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        parsertools.create_source_context(_ident_list, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(0)));
                        return _ident_list;
                    }

                case (int)RuleConstants.RULE_ARRAY_LIST2_TK_IDENTIFIER_TK_SQUAREOPEN_TK_SQUARECLOSE_TK_COMMA:
                    //<Array_list2> ::= 'tk_Identifier' 'tk_SquareOpen' <Diap_list> 'tk_SquareClose' 'tk_Comma'
                    {
                        ident_list _ident_list = new ident_list();
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        indexers_types _indexers_types = GetIndexers(LRParser.GetReductionSyntaxNode(2));
                        array_type _array_type = new array_type(_indexers_types, null);

                        var_def_statement _var_def_statement = new var_def_statement(_ident_list, _array_type, null, definition_attribute.None, false);
                        variable_definitions _variable_definitions = new variable_definitions();
                        _variable_definitions.var_definitions.Add(_var_def_statement);

                        //_ident_list.source_context = ((ident)LRParser.GetReductionSyntaxNode(0)).source_context;
                        parsertools.create_source_context(_array_type, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_ident_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        //parsertools.create_source_context(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_indexers_types, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));

                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_var_def_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _variable_definitions;
                    }

                case (int)RuleConstants.RULE_ARRAY_LIST2_TK_IDENTIFIER_TK_SQUAREOPEN_TK_SQUARECLOSE_TK_COMMA2:
                    //<Array_list2> ::= 'tk_Identifier' 'tk_SquareOpen' <Diap_list> 'tk_SquareClose' 'tk_Comma' <Array_list2>
                    {
                        ident_list _ident_list = new ident_list();
                        _ident_list.idents.Add(LRParser.GetReductionSyntaxNode(0) as ident);

                        indexers_types _indexers_types = GetIndexers(LRParser.GetReductionSyntaxNode(2));
                        array_type _array_type = new array_type(_indexers_types, null);

                        var_def_statement _var_def_statement = new var_def_statement(_ident_list, _array_type, null, definition_attribute.None, false);
                        variable_definitions _variable_definitions = (LRParser.GetReductionSyntaxNode(5) as variable_definitions);
                        _variable_definitions.var_definitions.Add(_var_def_statement);

                        //_ident_list.source_context = ((ident)LRParser.GetReductionSyntaxNode(0)).source_context;
                        parsertools.create_source_context(_array_type, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_ident_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        //parsertools.create_source_context(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_indexers_types, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));

                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(5));
                        parsertools.create_source_context(_var_def_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _variable_definitions;
                    }

                case (int)RuleConstants.RULE_VAR_DECLARATIONS1:
                    //<Var_declarations1> ::= <Type> <Id_list1>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());

                        var_def_statement _var_def_statement = new var_def_statement(GetIdents(LRParser.GetReductionSyntaxNode(1)), _named_type_reference, null, definition_attribute.None, false);
                        var_statement _var_statement = new var_statement(_var_def_statement);

                        parsertools.create_source_context(_var_def_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_var_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_named_type_reference, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _var_statement;
                    }

                case (int)RuleConstants.RULE_VAR_DECLARATIONS1_TK_ARRAY:
                    //<Var_declarations1> ::= <Type> 'tk_array' <Array_list1>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());

                        statement_list var_statement_list = new statement_list();

                        variable_definitions _variable_definitions = LRParser.GetReductionSyntaxNode(2) as variable_definitions;
                        for (int i = 0; i < _variable_definitions.var_definitions.Count; i++)
                        {
                            ((_variable_definitions.var_definitions[i]).vars_type as array_type).elemets_types = _named_type_reference;
                            var_statement _var_statement = new var_statement((var_def_statement)_variable_definitions.var_definitions[i]);
                            var_statement_list.subnodes.Add(_var_statement);

                            parsertools.create_source_context(_var_statement, _variable_definitions.var_definitions[i], _variable_definitions.var_definitions[i]);

                        }
                        parsertools.create_source_context(_named_type_reference.names[0], LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(var_statement_list, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_named_type_reference, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return var_statement_list;
                    }

                case (int)RuleConstants.RULE_VAR_DECLARATIONS2:
                    //<Var_declarations2> ::= <Type> <Id_list2>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());
                        var_def_statement _var_def_statement = new var_def_statement(GetIdents(LRParser.GetReductionSyntaxNode(1)), _named_type_reference, null, definition_attribute.None, false);
                        var_statement _var_statement = new var_statement(_var_def_statement);

                        parsertools.create_source_context(_var_def_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_var_statement, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_named_type_reference, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _var_statement;
                    }

                case (int)RuleConstants.RULE_VAR_DECLARATIONS2_TK_ARRAY:
                    //<Var_declarations2> ::= <Type> 'tk_array' <Array_list2>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());

                        statement_list var_statement_list = new statement_list();

                        variable_definitions _variable_definitions = LRParser.GetReductionSyntaxNode(2) as variable_definitions;
                        for (int i = 0; i < _variable_definitions.var_definitions.Count; i++)
                        {
                            ((_variable_definitions.var_definitions[i]).vars_type as array_type).elemets_types = _named_type_reference;
                            var_statement _var_statement = new var_statement((var_def_statement)_variable_definitions.var_definitions[i]);
                            var_statement_list.subnodes.Add(_var_statement);

                            parsertools.create_source_context(_var_statement, _variable_definitions.var_definitions[i], _variable_definitions.var_definitions[i]);
                        }

                        parsertools.create_source_context(_named_type_reference.names[0], LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        parsertools.create_source_context(var_statement_list, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_named_type_reference, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));

                        return var_statement_list;
                    }

                case (int)RuleConstants.RULE_VAR_DECL_LIST1:
                    //<Var_decl_list1> ::= <Var_declarations1>
                    {
                        statement_list var_statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));

                        parsertools.create_source_context(var_statement_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return var_statement_list;
                    }

                case (int)RuleConstants.RULE_VAR_DECL_LIST12:
                    //<Var_decl_list1> ::= <Var_decl_list2> <Var_declarations1>
                    {
                        statement_list var_statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));
                        var_statement_list.subnodes.AddRange(GetStatements(LRParser.GetReductionSyntaxNode(1)).subnodes);

                        parsertools.create_source_context(var_statement_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return var_statement_list;
                    }

                case (int)RuleConstants.RULE_VAR_DECL_LIST2:
                    //<Var_decl_list2> ::= <Var_declarations2>
                    {
                        statement_list var_statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));

                        parsertools.create_source_context(var_statement_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return var_statement_list;
                    }

                case (int)RuleConstants.RULE_VAR_DECL_LIST22:
                    //<Var_decl_list2> ::= <Var_decl_list2> <Var_declarations2>
                    {
                        statement_list var_statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));
                        var_statement_list.subnodes.AddRange(GetStatements(LRParser.GetReductionSyntaxNode(1)).subnodes);

                        parsertools.create_source_context(var_statement_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return var_statement_list;
                    }


                case (int)RuleConstants.RULE_DECLARATIONS:
                    //<Declarations> ::= <Var_decl_list1>
                    return LRParser.GetReductionSyntaxNode(0);

                //------------------------- Globals

                case (int)RuleConstants.RULE_USES_UNITS_TK_USES:
                    //<Uses_units> ::= 'tk_uses' <Id_list1>
                    {
                        if (_units[unit_number - 1] != null)
                            (_units[unit_number - 1] as unit_data).used_units.idents.AddRange(((ident_list)LRParser.GetReductionSyntaxNode(1)).idents);
                        parsertools.create_source_context(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return LRParser.GetReductionSyntaxNode(1);

                        //return null;
                    }

                case (int)RuleConstants.RULE_GLOBAL_DECL_LIST:
                    //<Global_decl_list> ::= <Global_decl_list> <Separators> <Declarations>
                    {
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));
                        _statement_list.subnodes.AddRange(GetStatements(LRParser.GetReductionSyntaxNode(2)).subnodes);
                        parsertools.create_source_context(_statement_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _statement_list;
                    }

                case (int)RuleConstants.RULE_GLOBAL_DECL_LIST2:
                    //<Global_decl_list> ::= <Declarations>
                    {   // etot kod pohoje inogda ne vipolniaetsia hotia pravilo srabativaet        
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));
                        for (int i = 0; i < _statement_list.subnodes.Count; i++)
                            (_units[this.unit_number - 1] as unit_data).sub_progs.defs.Add(_statement_list.subnodes[i] as declaration);
                        parsertools.create_source_context(_statement_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _statement_list;
                    }

                case (int)RuleConstants.RULE_INITIALIZATION_TK_ASSIGN:
                    //<Initialization> ::= <Initialization> <Separators> <Value> 'tk_Assign' <Expression>
                    {
                        assign _assign = new assign((addressed_value)LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(4) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(3)).type);
                        (_units[this.unit_number - 1] as unit_data).initialization.subnodes.Add(_assign);

                        parsertools.create_source_context(_assign, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(4));
                        return null;
                    }

                case (int)RuleConstants.RULE_INITIALIZATION_TK_ASSIGN2:
                    //<Initialization> ::= <Value> 'tk_Assign' <Expression>
                    {
                        assign _assign = new assign((addressed_value)LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        (_units[this.unit_number - 1] as unit_data).initialization.subnodes.Add(_assign);

                        parsertools.create_source_context(_assign, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return null;
                    }

                case (int)RuleConstants.RULE_GLOBAL_VARS:
                    //<Global_vars> ::= <Global_decl_list> <Separators> <Initialization> <Separators>
                    {
                        declarations _declarations = new declarations();
                        //_declarations.defs.Add((declaration)LRParser.GetReductionSyntaxNode(2));
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));
                        for (int i = 0; i < _statement_list.subnodes.Count; i++)
                        {
                            (_units[this.unit_number - 1] as unit_data).sub_progs.defs.Add(_statement_list.subnodes[i] as declaration);
                            _declarations.defs.Add(_statement_list.subnodes[i] as declaration);
                        }
                        parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(3)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0)));
                        return _declarations;
                    }

                case (int)RuleConstants.RULE_GLOBAL_VARS2:
                    //<Global_vars> ::= <Global_decl_list> <Separators>
                    {
                        //declarations _declarations = (declarations)LRParser.GetReductionSyntaxNode(0);
                        declarations _declarations = new declarations();
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));
                        for (int i = 0; i < _statement_list.subnodes.Count; i++)
                        {
                            (_units[this.unit_number - 1] as unit_data).sub_progs.defs.Add(_statement_list.subnodes[i] as declaration);
                            _declarations.defs.Add(_statement_list.subnodes[i] as declaration);
                        }
                        parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0)));
                        return _declarations;
                    }

                case (int)RuleConstants.RULE_GLOBAL_PART:
                    //<Global_part> ::= 
                    return null;

                case (int)RuleConstants.RULE_GLOBAL_PART2:
                    //<Global_part> ::= <Uses_units> <Separators>
                    {
                        //declarations _declarations = (declarations)LRParser.GetReductionSyntaxNode(0);
                        //parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0)));
                        return null;
                    }

                case (int)RuleConstants.RULE_GLOBAL_PART3:
                    //<Global_part> ::= <Uses_units> <Separators> <Global_vars>
                    {
                        //declarations _declarations = (declarations)LRParser.GetReductionSyntaxNode(0);
                        //_declarations.defs.AddRange(((declarations)LRParser.GetReductionSyntaxNode(2)).defs);
                        //parsertools.create_source_context(_declarations, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(2)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0)));
                        return null;
                    }
                case (int)RuleConstants.RULE_GLOBAL_PART4:
                    //<Global_part> ::= <Global_vars>
                    {
                        //declarations _declarations = (declarations)LRParser.GetReductionSyntaxNode(0);
                        //parsertools.create_source_context(_declarations, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return null;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER1:
                    //<Formal_parameter1> ::= <Type> <Id_list1>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());
                        ident_list _ident_list = GetIdents(LRParser.GetReductionSyntaxNode(1));
                        _ident_list.idents.Reverse();

                        typed_parameters _typed_parametres = new typed_parameters(_ident_list, _named_type_reference, parametr_kind.none, null);
                        formal_parameters _formal_parametres = new formal_parameters();
                        _formal_parametres.params_list.Add(_typed_parametres);

                        parsertools.create_source_context(_typed_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER1_TK_VAR:
                    //<Formal_parameter1> ::= 'tk_var' <Type> <Id_list1>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(1)).text.ToLower());
                        ident_list _ident_list = GetIdents(LRParser.GetReductionSyntaxNode(2));
                        _ident_list.idents.Reverse();

                        typed_parameters _typed_parametres = new typed_parameters(_ident_list, _named_type_reference, parametr_kind.var_parametr, null);
                        formal_parameters _formal_parametres = new formal_parameters();
                        _formal_parametres.params_list.Add(_typed_parametres);

                        parsertools.create_source_context(_typed_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER1_TK_ARRAY:
                    //<Formal_parameter1> ::= <Type> 'tk_array' <Array_list1>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());
                        variable_definitions _variable_definitions = LRParser.GetReductionSyntaxNode(2) as variable_definitions;
                        formal_parameters _formal_parametres = new formal_parameters();
                        _variable_definitions.var_definitions.Reverse();

                        for (int i = 0; i < _variable_definitions.var_definitions.Count; i++)
                        {
                            ((_variable_definitions.var_definitions[i]).vars_type as array_type).elemets_types = _named_type_reference;
                            _formal_parametres.params_list.Add(new typed_parameters((_variable_definitions.var_definitions[i]).vars, (_variable_definitions.var_definitions[i]).vars_type, parametr_kind.none, null));
                        }
                        _variable_definitions.var_definitions.Clear();

                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_named_type_reference, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER1_TK_VAR_TK_ARRAY:
                    //<Formal_parameter1> ::= 'tk_var' <Type> 'tk_array' <Array_list1>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(1)).text.ToLower());
                        variable_definitions _variable_definitions = LRParser.GetReductionSyntaxNode(3) as variable_definitions;
                        formal_parameters _formal_parametres = new formal_parameters();
                        _variable_definitions.var_definitions.Reverse();

                        for (int i = 0; i < _variable_definitions.var_definitions.Count; i++)
                        {
                            ((_variable_definitions.var_definitions[i]).vars_type as array_type).elemets_types = _named_type_reference;
                            _formal_parametres.params_list.Add(new typed_parameters((_variable_definitions.var_definitions[i]).vars, (_variable_definitions.var_definitions[i]).vars_type, parametr_kind.var_parametr, null));
                        }
                        _variable_definitions.var_definitions.Clear();

                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_named_type_reference, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER2:
                    //<Formal_Parameter2> ::= <Type> <Id_list2>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());
                        ident_list _ident_list = GetIdents(LRParser.GetReductionSyntaxNode(1));
                        _ident_list.idents.Reverse();

                        typed_parameters _typed_parametres = new typed_parameters(_ident_list, _named_type_reference, parametr_kind.none, null);
                        formal_parameters _formal_parametres = new formal_parameters();
                        _formal_parametres.params_list.Add(_typed_parametres);

                        parsertools.create_source_context(_typed_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER2_TK_VAR:
                    //<Formal_Parameter2> ::= 'tk_var' <Type> <Id_list2>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(1)).text.ToLower());
                        ident_list _ident_list = GetIdents(LRParser.GetReductionSyntaxNode(2));
                        _ident_list.idents.Reverse();

                        typed_parameters _typed_parametres = new typed_parameters(_ident_list, _named_type_reference, parametr_kind.var_parametr, null);
                        formal_parameters _formal_parametres = new formal_parameters();
                        _formal_parametres.params_list.Add(_typed_parametres);

                        parsertools.create_source_context(_typed_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER2_TK_ARRAY:
                    //<Formal_Parameter2> ::= <Type> 'tk_array' <Array_list2>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(0)).text.ToLower());
                        variable_definitions _variable_definitions = LRParser.GetReductionSyntaxNode(2) as variable_definitions;
                        formal_parameters _formal_parametres = new formal_parameters();
                        _variable_definitions.var_definitions.Reverse();

                        for (int i = 0; i < _variable_definitions.var_definitions.Count; i++)
                        {
                            ((_variable_definitions.var_definitions[i]).vars_type as array_type).elemets_types = _named_type_reference;
                            _formal_parametres.params_list.Add(new typed_parameters((_variable_definitions.var_definitions[i]).vars, (_variable_definitions.var_definitions[i]).vars_type, parametr_kind.none, null));
                        }
                        _variable_definitions.var_definitions.Clear();

                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_PARAMETER2_TK_VAR_TK_ARRAY:
                    //<Formal_Parameter2> ::= 'tk_var' <Type> 'tk_array' <Array_list2>
                    {
                        named_type_reference _named_type_reference = GetType(((token_info)LRParser.GetReductionSyntaxNode(1)).text.ToLower());
                        variable_definitions _variable_definitions = LRParser.GetReductionSyntaxNode(3) as variable_definitions;
                        formal_parameters _formal_parametres = new formal_parameters();
                        _variable_definitions.var_definitions.Reverse();

                        for (int i = 0; i < _variable_definitions.var_definitions.Count; i++)
                        {
                            ((_variable_definitions.var_definitions[i]).vars_type as array_type).elemets_types = _named_type_reference;
                            _formal_parametres.params_list.Add(new typed_parameters((_variable_definitions.var_definitions[i]).vars, (_variable_definitions.var_definitions[i]).vars_type, parametr_kind.var_parametr, null));
                        }
                        _variable_definitions.var_definitions.Clear();

                        parsertools.create_source_context(_variable_definitions, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_TYPE_LIST1:
                    //<Formal_type_list1> ::= <Formal_parameter1>
                    {
                        formal_parameters _formal_parametres = GetFormals(LRParser.GetReductionSyntaxNode(0));

                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_TYPE_LIST12:
                    //<Formal_type_list1> ::= <Formal_type_list2> <Formal_parameter1>
                    {
                        formal_parameters _formal_parametres = GetFormals(LRParser.GetReductionSyntaxNode(0));
                        _formal_parametres.params_list.AddRange(GetFormals(LRParser.GetReductionSyntaxNode(1)).params_list);

                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_TYPE_LIST2:
                    //<Formal_type_list2> ::= <Formal_Parameter2>
                    {
                        formal_parameters _formal_parametres = GetFormals(LRParser.GetReductionSyntaxNode(0));

                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_TYPE_LIST22:
                    //<Formal_type_list2> ::= <Formal_type_list2> <Formal_Parameter2>
                    {
                        formal_parameters _formal_parametres = GetFormals(LRParser.GetReductionSyntaxNode(0));
                        _formal_parametres.params_list.AddRange(GetFormals(LRParser.GetReductionSyntaxNode(1)).params_list);

                        parsertools.create_source_context(_formal_parametres, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _formal_parametres;
                    }

                case (int)RuleConstants.RULE_FORMAL_LIST:
                    //<Formal_list> ::= 
                    return null;

                case (int)RuleConstants.RULE_FORMAL_LIST2:
                    //<Formal_list> ::= <Formal_type_list1>
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_FACT_LIST:
                    //<Fact_list> ::= 
                    return null;

                case (int)RuleConstants.RULE_FACT_LIST2:
                    //<Fact_list> ::= <List_of_expressions>
                    return LRParser.GetReductionSyntaxNode(0);

                //-------------------------- Operators

                case (int)RuleConstants.RULE_FREE_OPERATOR:
                    //<Free_operator> ::= 
                    return null;

                case (int)RuleConstants.RULE_CASE_VARIANT_LIST:
                    //<Case_variant_list> ::= <Case_variant> <Case_variant_list>
                    {
                        if_node _if_node1;
                        if (LRParser.GetReductionSyntaxNode(1) is case_variant)
                        {
                            case_variant _case_variant1 = (case_variant)LRParser.GetReductionSyntaxNode(1);
                            _if_node1 = new if_node((expression)_case_variant1.conditions.expressions[0], GetStatements(_case_variant1.exec_if_true), null);
                            parsertools.create_source_context(_if_node1, LRParser.GetReductionSyntaxNode(1),LRParser.GetReductionSyntaxNode(1)); //make
                        
                        }
                        else
                            _if_node1 = LRParser.GetReductionSyntaxNode(1) as if_node;

                        case_variant _case_variant = (case_variant)LRParser.GetReductionSyntaxNode(0);
                        if_node _if_node = new if_node((expression)_case_variant.conditions.expressions[0], _case_variant.exec_if_true, _if_node1);

                        parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0))); //make
                        return _if_node;
                    }

                case (int)RuleConstants.RULE_CASE_VARIANT_LIST2:
                    //<Case_variant_list> ::= <Case_variant>
                    {   //unreacheable rule.. ?
                        case_variant _case_variant = (case_variant)LRParser.GetReductionSyntaxNode(0);
                        if_node _if_node = new if_node(GetExpressions(_case_variant.conditions), (statement)_case_variant.exec_if_true, null);

                        parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0)); //make
                        return _if_node;
                    }

                case (int)RuleConstants.RULE_CASE_VARIANT_TK_CASE_V_TK_COLON:
                    //<Case_variant> ::= 'tk_case_v' <Expression> 'tk_Colon' <Statements>
                    {
                        expression_list _expression_list = GetExpressions(LRParser.GetReductionSyntaxNode(1));
                        case_variant _case_variant = new case_variant(_expression_list, GetStatements(LRParser.GetReductionSyntaxNode(3)));

                        //_case_variant.source_context = (GetExpressions(LRParser.GetReductionSyntaxNode(1))).source_context;
                        parsertools.create_source_context(_case_variant, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(2)));
                        return _case_variant;
                    }

                case (int)RuleConstants.RULE_STATEMENTS:
                    //<Statements> ::= <Statements> <Separators> <Statement>
                    {
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));
                        _statement_list.subnodes.AddRange(GetStatements(LRParser.GetReductionSyntaxNode(2)).subnodes);

                        parsertools.create_source_context(_statement_list, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2)), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(0)));
                        //parsertools.create_source_context(_statement_list, _statement_list, _statement_list);   //make
                        return _statement_list;
                    }

                case (int)RuleConstants.RULE_STATEMENTS2:
                    //<Statements> ::= <Statement>
                    {
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(0));

                        parsertools.create_source_context(_statement_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _statement_list;
                    }

                case (int)RuleConstants.RULE_STATEMENT:
                    //<Statement> ::= <Free_operator>
                    {
                        empty_statement _empty_statement = new empty_statement();

                        return _empty_statement;
                    }

                case (int)RuleConstants.RULE_STATEMENT2:
                    //<Statement> ::= <Declarations>
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_STATEMENT_TK_ASSIGN:
                    //<Statement> ::= <Value> 'tk_Assign' <Expression>
                    {
                        assign _assign = new assign((addressed_value)LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);

                        parsertools.create_source_context(_assign, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _assign;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_IF_TK_THEN_TK_END_ALL:
                    //<Statement> ::= 'tk_if' <Expression> 'tk_then' <Statements> 'tk_end_all'
                    {
                        if_node _if_node = new if_node((expression)LRParser.GetReductionSyntaxNode(1), GetStatements(LRParser.GetReductionSyntaxNode(3)), null);

                        parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(4), LRParser.GetReductionSyntaxNode(2)));
                        return _if_node;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_IF_TK_THEN_TK_ELSE_TK_END_ALL:
                    //<Statement> ::= 'tk_if' <Expression> 'tk_then' <Statements> 'tk_else' <Statements> 'tk_end_all'
                    {
                        if_node _if_node = new if_node((expression)LRParser.GetReductionSyntaxNode(1), GetStatements(LRParser.GetReductionSyntaxNode(3)), GetStatements(LRParser.GetReductionSyntaxNode(5)));

                        parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(6), LRParser.GetReductionSyntaxNode(2)));
                        return _if_node;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_BEGIN_CYCLE_TK_RAZ_TK_END_CYCLE:
                    //<Statement> ::= 'tk_begin_cycle' <Expression> 'tk_raz' <Statements> 'tk_end_cycle'
                    {   // remake without "_system_loop_var_" !
                        int32_const _int32_const = new int32_const(1);
                        ident loop_var = new ident("&_system_loop_var");
                        statement_list _statement_list = GetStatements(LRParser.GetReductionSyntaxNode(3));

                        for_node _for_node = new for_node(loop_var, _int32_const, (expression)LRParser.GetReductionSyntaxNode(1), _statement_list, for_cycle_type.to, null, null, true);

                        parsertools.create_source_context(_for_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(4), LRParser.GetReductionSyntaxNode(1)));
                        if ((_statement_list as statement).source_context != null)
                            parsertools.create_source_context(_statement_list, LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_for_node, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(4));
                        return _for_node;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_BEGIN_CYCLE_TK_FOR_TK_IDENTIFIER_TK_FROM_TK_TO_TK_END_CYCLE:
                    //<Statement> ::= 'tk_begin_cycle' 'tk_for' 'tk_Identifier' 'tk_from' <Expression> 'tk_to' <Expression> <Statements> 'tk_end_cycle'
                    {
                        for_node _for_node = new for_node((ident)LRParser.GetReductionSyntaxNode(2), (expression)LRParser.GetReductionSyntaxNode(4), (expression)LRParser.GetReductionSyntaxNode(6), GetStatements(LRParser.GetReductionSyntaxNode(7)), for_cycle_type.to, null, null, false);

                        parsertools.create_source_context(_for_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(8), LRParser.GetReductionSyntaxNode(1)));
                        parsertools.create_source_context(GetStatements(LRParser.GetReductionSyntaxNode(7)), LRParser.GetReductionSyntaxNode(7), LRParser.GetReductionSyntaxNode(7));
                        return _for_node;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_BEGIN_CYCLE_TK_WHILE_TK_END_CYCLE:
                    //<Statement> ::= 'tk_begin_cycle' 'tk_while' <Expression> <Statements> 'tk_end_cycle'
                    {
                        while_node _while_node = new while_node((expression)LRParser.GetReductionSyntaxNode(2), GetStatements(LRParser.GetReductionSyntaxNode(3)), WhileCycleType.While);

                        parsertools.create_source_context(_while_node, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(4));
                        return _while_node;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_CASE_TK_END_ALL:
                    //<Statement> ::= 'tk_case' <Separators Opt> <Case_variant_list> 'tk_end_all'
                    {
                        if_node _if_node;
                        if (LRParser.GetReductionSyntaxNode(2) is case_variant)
                        {
                            case_variant _case_variant = (case_variant)LRParser.GetReductionSyntaxNode(2);
                            _if_node = new if_node((expression)_case_variant.conditions.expressions[0], (statement)_case_variant.exec_if_true, null);

                            parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1)));   //make                       
                            return _if_node;
                        }
                        else{
                            if_node _if_node1;
                            _if_node = (if_node)LRParser.GetReductionSyntaxNode(2);
                            _if_node1 = _if_node;
                            while (_if_node1.else_body is if_node)
                                _if_node1 = _if_node1.else_body as if_node;

                            _if_node1.else_body = null;
                            parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1)));
                            return _if_node;

                        }
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_CASE_TK_ELSE_TK_END_ALL:
                    //<Statement> ::= 'tk_case' <Separators Opt> <Case_variant_list> 'tk_else' <Statements> 'tk_end_all'
                    {
                        if_node _if_node;
                        if (LRParser.GetReductionSyntaxNode(2) is case_variant)
                        {
                            case_variant _case_variant = (case_variant)LRParser.GetReductionSyntaxNode(2);
                            _if_node = new if_node((expression)_case_variant.conditions.expressions[0], (statement)_case_variant.exec_if_true, GetStatements(LRParser.GetReductionSyntaxNode(4)));

                            parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(5), LRParser.GetReductionSyntaxNode(4), LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1)));   //make                       
                            return _if_node;
                        }
                        else
                        {
                            if_node _if_node1;
                            _if_node = (if_node)LRParser.GetReductionSyntaxNode(2);
                            _if_node1 = _if_node;
                            while (_if_node1.else_body is if_node)
                               _if_node1 = _if_node1.else_body as if_node;
                                
                            
                            _if_node1.else_body = GetStatements(LRParser.GetReductionSyntaxNode(4));
                           // _if_node1.else_body.source_context.end_position
                            //parsertools.create_source_context(_if_node1, LRParser.GetReductionSyntaxNode(2), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(5), LRParser.GetReductionSyntaxNode(4), LRParser.GetReductionSyntaxNode(3)));   //make                       
                            parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(5), LRParser.GetReductionSyntaxNode(4), LRParser.GetReductionSyntaxNode(3), LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(1)));   //make                       
                            return _if_node;
                        }
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_ASSERT:
                    //<Statement> ::= 'tk_assert' <Expression>
                    {   //make it!
                        procedure_call _procedure_call = new procedure_call();
                        expression_list _expression_list = new expression_list();
                        _expression_list.expressions.Add((expression)LRParser.GetReductionSyntaxNode(1));
                        method_call _method_call = new method_call(_expression_list);
                        _method_call.dereferencing_value = new ident("assert");
                        _procedure_call.func_name = _method_call;

                        parsertools.create_source_context(_method_call.dereferencing_value, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_expression_list, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_procedure_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));

                        return _procedure_call;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_READ:
                    //<Statement> ::= 'tk_read' <Id_list1>
                    {
                        procedure_call _procedure_call = new procedure_call();
                        expression_list _expression_list = new expression_list();
                        ident_list _ident_list = GetIdents(LRParser.GetReductionSyntaxNode(1));

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

                        method_call _method_call = new method_call(_expression_list);
                        _method_call.dereferencing_value = new ident("read");
                        _procedure_call.func_name = _method_call;

                        parsertools.create_source_context(_method_call.dereferencing_value, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_ident_list, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_procedure_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _procedure_call;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_WRITE:
                    //<Statement> ::= 'tk_write' <List_of_expressions>
                    {
                        procedure_call _procedure_call = new procedure_call();
                        expression_list _expression_list = GetExpressions(LRParser.GetReductionSyntaxNode(1));
                        method_call _method_call = new method_call(_expression_list);
                        _method_call.dereferencing_value = new ident("write");
                        _procedure_call.func_name = _method_call;

                        parsertools.create_source_context(_method_call.dereferencing_value, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_expression_list, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_procedure_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _procedure_call;
                    }

                case (int)RuleConstants.RULE_STATEMENT_TK_IDENTIFIER_TK_ROUNDOPEN_TK_ROUNDCLOSE:
                    //<Statement> ::= 'tk_Identifier' 'tk_RoundOpen' <Fact_list> 'tk_RoundClose'
                    {
                        procedure_call _procedure_call = new procedure_call();
                        method_call _method_call;
                        expression_list _expression_list;

                        if (LRParser.GetReductionSyntaxNode(2) != null)
                        {
                            _expression_list = GetExpressions(LRParser.GetReductionSyntaxNode(2));
                            _method_call = new method_call(_expression_list);
                        }
                        else
                            _method_call = new method_call();


                        _method_call.dereferencing_value = new ident(((ident)LRParser.GetReductionSyntaxNode(0)).name);
                        _procedure_call.func_name = _method_call;

                        parsertools.create_source_context(_method_call.dereferencing_value, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        //parsertools.create_source_context(_expression_list, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        parsertools.create_source_context(_procedure_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _procedure_call;
                    }


                case (int)RuleConstants.RULE_STATEMENT_TK_IDENTIFIER:
                    //<Statement> ::= 'tk_Identifier'
                    {
                        procedure_call _procedure_call = new procedure_call();
                        method_call _method_call = new method_call(null);
                        _method_call.dereferencing_value = new ident(((ident)LRParser.GetReductionSyntaxNode(0)).name);
                        _procedure_call.func_name = _method_call;

                        parsertools.create_source_context(_method_call.dereferencing_value, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0)); parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        parsertools.create_source_context(_procedure_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _procedure_call;
                    }

                case (int)RuleConstants.RULE_EXPRESSION_TK_GREATER:
                    //<Expression> ::= <Expression> 'tk_Greater' <Add Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);

                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_EXPRESSION_TK_LOWER:
                    //<Expression> ::= <Expression> 'tk_Lower' <Add Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_EXPRESSION_TK_LOWEREQUAL:
                    //<Expression> ::= <Expression> 'tk_LowerEqual' <Add Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_EXPRESSION_TK_GREATEREQUAL:
                    //<Expression> ::= <Expression> 'tk_GreaterEqual' <Add Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_EXPRESSION_TK_EQUAL:
                    //<Expression> ::= <Expression> 'tk_Equal' <Add Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_EXPRESSION_TK_NOTEQUAL:
                    //<Expression> ::= <Expression> 'tk_NotEqual' <Add Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_EXPRESSION:
                    //<Expression> ::= <Add Exp>
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_ADDEXP_TK_OR:
                    //<Add Exp> ::= <Add Exp> 'tk_or' <Mult Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_ADDEXP_TK_PLUS:
                    //<Add Exp> ::= <Add Exp> 'tk_Plus' <Mult Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_ADDEXP_TK_MINUS:
                    //<Add Exp> ::= <Add Exp> 'tk_Minus' <Mult Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_ADDEXP:
                    //<Add Exp> ::= <Mult Exp>
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_MULTEXP_TK_AND:
                    //<Mult Exp> ::= <Mult Exp> 'tk_and' <Power Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_MULTEXP_TK_MULT:
                    //<Mult Exp> ::= <Mult Exp> 'tk_Mult' <Power Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_MULTEXP_TK_DIV:
                    //<Mult Exp> ::= <Mult Exp> 'tk_Div' <Power Exp>
                    {
                        bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        return _bin_expr;
                    }

                case (int)RuleConstants.RULE_MULTEXP:
                    //<Mult Exp> ::= <Power Exp>
                    return LRParser.GetReductionSyntaxNode(0);    //make it!

                case (int)RuleConstants.RULE_POWEREXP_TK_POWER:
                    {
                        //<Power Exp> ::= <Negate Exp> 'tk_Power' <Power Exp>

                        expression_list _expression_list = new expression_list();
                        _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
                        _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(2) as expression);
                        method_call _method_call = new method_call(_expression_list);
                        _method_call.dereferencing_value = new ident("Power");
                        parsertools.create_source_context(_method_call.dereferencing_value, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));
                        return _method_call;

                        //bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
                        //parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

                        //return _bin_expr;
                    }
                case (int)RuleConstants.RULE_POWEREXP:
                    //<Power Exp> ::= <Negate Exp>
                    return LRParser.GetReductionSyntaxNode(0);    //make it!

                case (int)RuleConstants.RULE_NEGATEEXP_TK_MINUS:
                    //<Negate Exp> ::= 'tk_Minus' <Value>
                    {
                        un_expr _un_expr = new un_expr(LRParser.GetReductionSyntaxNode(1) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(0)).type);
                        parsertools.create_source_context(_un_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));

                        return _un_expr;
                    }

                case (int)RuleConstants.RULE_NEGATEEXP_TK_NOT:
                    //<Negate Exp> ::= 'tk_not' <Value>
                    {
                        un_expr _un_expr = new un_expr(LRParser.GetReductionSyntaxNode(1) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(0)).type);
                        parsertools.create_source_context(_un_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));

                        return _un_expr;
                    }

                case (int)RuleConstants.RULE_NEGATEEXP:
                    //<Negate Exp> ::= <Value>
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_IDENTIFIER:
                    //<Value> ::= 'tk_Identifier'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_FUNC_VAL:
                    //<Value> ::= 'tk_func_val'
                    return new ident("result");

                case (int)RuleConstants.RULE_VALUE_TK_INTEGER:
                    //<Value> ::= 'tk_integer'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_REAL:
                    //<Value> ::= 'tk_real'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_TRUE:
                    //<Value> ::= 'tk_true'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_FALSE:
                    //<Value> ::= 'tk_false'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_STRINGLITERAL:
                    //<Value> ::= 'tk_StringLiteral'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_CHAR:
                    //<Value> ::= 'tk_char'
                    return LRParser.GetReductionSyntaxNode(0);

                case (int)RuleConstants.RULE_VALUE_TK_EOL:
                    //<Value> ::= 'tk_eol'
                    {
                        literal_const_line _literal_const_line = new literal_const_line();
                        sharp_char_const _sharp_char_const_13 = new sharp_char_const(13);
                        sharp_char_const _sharp_char_const_10 = new sharp_char_const(10);
                        _literal_const_line.literals.Add(_sharp_char_const_13);
                        _literal_const_line.literals.Add(_sharp_char_const_10);

                        parsertools.create_source_context(_sharp_char_const_13, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));    //make
                        parsertools.create_source_context(_sharp_char_const_10, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));    //make
                        parsertools.create_source_context(_literal_const_line, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));     //make
                        return _literal_const_line;
                    }

                case (int)RuleConstants.RULE_VALUE_TK_IDENTIFIER_TK_SQUAREOPEN_TK_SQUARECLOSE_TK_SQUAREOPEN_TK_SQUARECLOSE:
                    //<Value> ::= 'tk_Identifier' 'tk_SquareOpen' <Fact_list> 'tk_SquareClose' 'tk_SquareOpen' <Expression> 'tk_SquareClose'
                    {

                        indexer _indexer = new indexer(GetExpressions(LRParser.GetReductionSyntaxNode(2)));
                        indexer _indexer1 = new indexer(GetExpressions(LRParser.GetReductionSyntaxNode(5)));
                        _indexer.dereferencing_value = LRParser.GetReductionSyntaxNode(0) as ident;
                        _indexer1.dereferencing_value = _indexer;
                        parsertools.create_source_context(_indexer, LRParser.GetReductionSyntaxNode(2), LRParser.GetReductionSyntaxNode(2));
                        parsertools.create_source_context(_indexer, LRParser.GetReductionSyntaxNode(5), LRParser.GetReductionSyntaxNode(5));
                        return _indexer1;
                    }

                case (int)RuleConstants.RULE_VALUE_TK_IDENTIFIER_TK_SQUAREOPEN_TK_SQUARECLOSE:
                    //<Value> ::= 'tk_Identifier' 'tk_SquareOpen' <Fact_list> 'tk_SquareClose'
                    {

                        indexer _indexer = new indexer(GetExpressions(LRParser.GetReductionSyntaxNode(2)));
                        _indexer.dereferencing_value = LRParser.GetReductionSyntaxNode(0) as ident;
                        parsertools.create_source_context(_indexer, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(3));
                        return _indexer;
                    }

                case (int)RuleConstants.RULE_VALUE_TK_IDENTIFIER_TK_ROUNDOPEN_TK_ROUNDCLOSE:
                    //<Value> ::= 'tk_Identifier' 'tk_RoundOpen' <Fact_list> 'tk_RoundClose'
                    {
                        expression_list _expression_list;
                        method_call _method_call;
                        if (LRParser.GetReductionSyntaxNode(2) != null)
                        {
                            _expression_list = GetExpressions(LRParser.GetReductionSyntaxNode(2));
                            _method_call = new method_call(_expression_list);
                        }
                        else
                            _method_call = new method_call();
                        switch (((ident)LRParser.GetReductionSyntaxNode(0)).name)
                        {
                            case "tg": _method_call.dereferencing_value = new ident("tan"); break;
                            case "ctg": _method_call.dereferencing_value = new ident("ctg"); break;
                            case "arctg": _method_call.dereferencing_value = new ident("arctan"); break;
                            case "arcctg": _method_call.dereferencing_value = new ident("arcctg"); break;
                            case "lg": _method_call.dereferencing_value = new ident("log10"); break;
                            case "mod": _method_call.dereferencing_value = new ident("md"); break;
                            case "div": _method_call.dereferencing_value = new ident("dv"); break;
                            case "rnd": _method_call.dereferencing_value = new ident("random"); break;
                            case "int": _method_call.dereferencing_value = new ident("round"); break;

                            default:
                                _method_call.dereferencing_value = new ident(((ident)LRParser.GetReductionSyntaxNode(0)).name);
                                break;
                        }
                        //_method_call.dereferencing_value = LRParser.GetReductionSyntaxNode(0) as ident;

                        parsertools.create_source_context(_method_call.dereferencing_value, LRParser.GetReductionSyntaxNode(1), LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _method_call;
                    }

                case (int)RuleConstants.RULE_VALUE_TK_ROUNDOPEN_TK_ROUNDCLOSE:
                    //<Value> ::= 'tk_RoundOpen' <Expression> 'tk_RoundClose'
                    return LRParser.GetReductionSyntaxNode(1);

            }
            throw new RuleException("Unknown rule");
        }
示例#6
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public index_property(formal_parameters _property_parametres,default_indexer_property_node _is_default,SourceContext sc)
		{
			this._property_parametres=_property_parametres;
			this._is_default=_is_default;
			source_context = sc;
		}
		public void read_formal_parameters(formal_parameters _formal_parameters)
		{
			read_syntax_tree_node(_formal_parameters);
			if (br.ReadByte() == 0)
			{
				_formal_parameters.params_list = null;
			}
			else
			{
				_formal_parameters.params_list = new List<typed_parameters>();
				Int32 ssyy_count = br.ReadInt32();
				for(Int32 ssyy_i = 0; ssyy_i < ssyy_count; ssyy_i++)
				{
					_formal_parameters.params_list.Add(_read_node() as typed_parameters);
				}
			}
		}
		public void write_formal_parameters(formal_parameters _formal_parameters)
		{
			write_syntax_tree_node(_formal_parameters);
			if (_formal_parameters.params_list == null)
			{
				bw.Write((byte)0);
			}
			else
			{
				bw.Write((byte)1);
				bw.Write(_formal_parameters.params_list.Count);
				for(Int32 ssyy_i = 0; ssyy_i < _formal_parameters.params_list.Count; ssyy_i++)
				{
					if (_formal_parameters.params_list[ssyy_i] == null)
					{
						bw.Write((byte)0);
					}
					else
					{
						bw.Write((byte)1);
						_formal_parameters.params_list[ssyy_i].visit(this);
					}
				}
			}
		}
		public override void visit(formal_parameters _formal_parametres)
		{
			throw new NotImplementedException();
		}
示例#10
0
 public static procedure_definition BuildShortProcDefinition(formal_parameters fp, procedure_attributes_list att, method_name name, statement st, SourceContext headsc)
 {
     var ff = new procedure_header(fp, att, name, null, headsc);
     return BuildShortProcFuncDefinition(ff, st);
 }
示例#11
0
		private formal_parameters get_parameters(List<ICSharpCode.NRefactory.Ast.ParameterDeclarationExpression> prms)
		{
			formal_parameters fp = new formal_parameters();
			foreach (ICSharpCode.NRefactory.Ast.ParameterDeclarationExpression prm in prms)
			{
				typed_parameters tp = new typed_parameters();
				tp.source_context = get_source_context(prm);
				tp.idents = new ident_list();
				tp.idents.idents.Add(new ident(prm.ParameterName));
				tp.vars_type = get_type_reference(prm.TypeReference);
				tp.inital_value = get_expression(prm.DefaultValue);
				switch (prm.ParamModifier)
				{
					case ICSharpCode.NRefactory.Ast.ParameterModifiers.Ref : tp.param_kind = parametr_kind.var_parametr; break;
					case ICSharpCode.NRefactory.Ast.ParameterModifiers.Params : tp.param_kind = parametr_kind.params_parametr; break;
				}
				fp.params_list.Add(tp);
			}
			return fp;
		}
示例#12
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public procedure_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs)
		{
			this._attr_list=_attr_list;
			this._parameters=_parameters;
			this._proc_attributes=_proc_attributes;
			this._name=_name;
			this._of_object=_of_object;
			this._class_keyword=_class_keyword;
			this._template_args=_template_args;
			this._where_defs=_where_defs;
		}
public procedure_definition lambda(function_lambda_definition _function_lambda_definition)
{
    SyntaxTree.procedure_definition _func_def = new PascalABCCompiler.SyntaxTree.procedure_definition();
    SyntaxTree.method_name _method_name1 = new SyntaxTree.method_name(null, new SyntaxTree.ident(_function_lambda_definition.lambda_name), null);
    SyntaxTree.function_header _function_header1 = new SyntaxTree.function_header();

    object rt1 = new object();
    _function_header1.name = _method_name1;
    SyntaxTree.formal_parameters fps = new PascalABCCompiler.SyntaxTree.formal_parameters();
    _function_header1.parameters = _function_lambda_definition.formal_parameters;//fps;
    SyntaxTree.named_type_reference _named_type_reference = new SyntaxTree.named_type_reference();
    SyntaxTree.ident idtype = new SyntaxTree.ident("datatype");
    _named_type_reference.source_context = idtype.source_context;
    _named_type_reference.names.Add(idtype);

    rt1 = _named_type_reference;
    _function_header1.return_type = (SyntaxTree.type_definition)_named_type_reference;

    _function_header1.of_object = false;
    _function_header1.class_keyword = false;
    SyntaxTree.block _block1 = new SyntaxTree.block(null, null);
    SyntaxTree.statement_list sl1 = new SyntaxTree.statement_list();
    sl1.subnodes.Add(_function_lambda_definition.proc_body);
    _block1.program_code = sl1;
    _func_def.proc_header = _function_header1;
    _func_def.proc_body = (SyntaxTree.proc_block)_block1;
    if (_function_lambda_definition.defs != null)
    {
        if (((block)_func_def.proc_body).defs == null)
            ((block)_func_def.proc_body).defs = new declarations();
        for (int l = 0; l < _function_lambda_definition.defs.Count; l++)
            ((block)_func_def.proc_body).defs.defs.Add(_function_lambda_definition.defs[l] as procedure_definition);
    }
    _function_lambda_definition.proc_definition = _func_def;
    return _func_def;
}
/*public procedure_definition find_let_lambda_name(string name)
{
    int i = 0;
    while (i < let_funcs.Count && ((procedure_definition)let_funcs[i]).proc_header.name.meth_name.name != name)
        i++;
    if (i < let_funcs.Count)
        return (procedure_definition)let_funcs[i];
    else
        return null;
}*/

public type_definition func_type(int count)
{
    //int count = mc.parameters.expressions.Count;

    formal_parameters _formal_parametres = new formal_parameters();
    for (int i = 0; i < count; i++)
    {
        ident_list _ident_list = new ident_list();
        ident id = new ident("$a" + i.ToString());
        _ident_list.idents.Add(id);
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _named_type_reference1.names.Add(idtype1);
        typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference1, parametr_kind.none, null);
        _formal_parametres.params_list.Add(_typed_parametres);
    }
    named_type_reference _named_type_reference = new named_type_reference();
    ident idtype = new ident("datatype");
    _named_type_reference.names.Add(idtype);
    function_header _function_header = new function_header();
    _function_header.parameters = _formal_parametres;
    _function_header.return_type = (type_definition)_named_type_reference;
    _function_header.of_object = false;
    _function_header.class_keyword = false;
    return (type_definition)_function_header;
}
public Object CreateNonTerminalObject(int ReductionRuleIndex)
{
switch (ReductionRuleIndex)
{
    case (int)RuleConstants.RULE_MODULE_TKMODULE_TKMAINIDENT_TKWHERE :
	//<module> ::= 'tkModule' 'tkMainIdent' 'tkWhere' <reference> <imports> <body> <empty>
{
ident_list _ident_list = new ident_list();
    _ident_list.idents.Add(new ident("LibForHaskell"));
    unit_or_namespace _unit_or_namespace = new unit_or_namespace(_ident_list);
    uses_list ul = (uses_list)LRParser.GetReductionSyntaxNode(4);
    if (ul == null)
        ul = new uses_list();
    ul.units.Insert(0, _unit_or_namespace);
    ////////////////
    declarations _defs = new declarations();
    for (int i = 0; i < _function_lambda_definitions.Count; i++)
        _defs.defs.Add((declaration)lambda((function_lambda_definition)_function_lambda_definitions[i]));
    for (int i = 0; i < _functions.Count; i++)
    {
        _defs.defs.Add((declaration)_functions[i]);
        int k = 1;
        while (k < _function_lambda_definitions_after.Count)
        {
            int j = k;
            while (j < _function_lambda_definitions_after.Count && ((procedure_definition)_functions[i]).proc_header.name.meth_name.name != (string)_function_lambda_definitions_after[j])
                j += 2;
            if (j < _function_lambda_definitions_after.Count)
            {
                _defs.defs.Add((declaration)lambda((function_lambda_definition)_function_lambda_definitions_after[j - 1]));
                _function_lambda_definitions_after.RemoveAt(j);
                _function_lambda_definitions_after.RemoveAt(j - 1);
            }
            k = j;
        }
    }
    int kk = 1;
    while (kk < _function_lambda_definitions_after.Count)
    {
        int j = 0;
        while (j < _defs.defs.Count && ((procedure_definition)_defs.defs[j]).proc_header.name.meth_name.name != (string)_function_lambda_definitions_after[kk])
            j++;
        if (j < _defs.defs.Count)
        {
            _defs.defs.Insert(j+1, (declaration)lambda((function_lambda_definition)_function_lambda_definitions_after[kk - 1]));
            _function_lambda_definitions_after.RemoveAt(kk);
            _function_lambda_definitions_after.RemoveAt(kk - 1);
        }
        else
            kk += 2;
    }

    //for (int i = 0; i < _function_lambda_definitions.Count; i++)
        //_defs.defs.Add(lambda((function_lambda_definition)_function_lambda_definitions[i]));
    for (int i = 0; i < let_where_funcs.Count; i++)
        _defs.defs.Add((procedure_definition)let_where_funcs[i]);
    
    block _block = new block(_defs, ((block)LRParser.GetReductionSyntaxNode(5)).program_code);
                                                ///////////////////////////////////////
											    program_module _program_module = new program_module(null, ul, _block, null);

            									_program_module.Language = LanguageId.PascalABCNET;
            									parsertools.create_source_context(_program_module, parsertools.sc_not_null(null, ul, null, LRParser.GetReductionSyntaxNode(5)), LRParser.GetReductionSyntaxNode(5));
                                                
                                                _functions.Clear();
                                                _function_lambda_definitions.Clear();
                                                func_name.Clear();
                                                lambda_num = 0;
                                                list_method_calls.Clear();
                                                list_method_calls_main.Clear();
                                                list_return_funcs.Clear();
                                                list_return_funcs_main.Clear();
                                                list_params1.Clear();
                                                list_method_calls_lambda.Clear();
                                                last_list_method_calls.Clear();
                                                last_list_method_calls_lambda.Clear();
                                                last_function_lambda_definitions.Clear();
                                          let_funcs1.Clear();
                                                let_funcs_funcs.Clear();
                                                let_func_last.Clear();
                                                let_flag.Clear();
                                                token_where_count = 0;
                                                let_where_funcs_main.Clear();
                                                let_where_funcs.Clear();
                                                token_where = 0;
                                                last_where_funcs.Clear();
                                                let_where_list_params.Clear();
                                                _function_lambda_definitions_main.Clear();
                                                let_stack.Clear();
                                                token_let = 0;
                                                lambda_stack.Clear();

            									return _program_module;
										}
	case (int)RuleConstants.RULE_MODULE :
	//<module> ::= <reference> <imports> <body> <empty>
{
	ident_list _ident_list = new ident_list();
    _ident_list.idents.Add(new ident("LibForHaskell"));
    unit_or_namespace _unit_or_namespace = new unit_or_namespace(_ident_list);
    uses_list ul = (uses_list)LRParser.GetReductionSyntaxNode(1);
    if (ul == null)
        ul = new uses_list();
    ul.units.Insert(0, _unit_or_namespace);
    ////////////////
    declarations _defs = new declarations();
    for (int i = 0; i < _function_lambda_definitions.Count; i++)
        _defs.defs.Add((declaration)lambda((function_lambda_definition)_function_lambda_definitions[i]));
    for (int i = 0; i < _functions.Count; i++)
    {
        _defs.defs.Add((declaration)_functions[i]);
        int k = 1;
        while (k < _function_lambda_definitions_after.Count)
        {
            int j = k;
            while (j < _function_lambda_definitions_after.Count && ((procedure_definition)_functions[i]).proc_header.name.meth_name.name != (string)_function_lambda_definitions_after[j])
                j += 2;
            if (j < _function_lambda_definitions_after.Count)
            {
                _defs.defs.Add((declaration)lambda((function_lambda_definition)_function_lambda_definitions_after[j - 1]));
                _function_lambda_definitions_after.RemoveAt(j);
                _function_lambda_definitions_after.RemoveAt(j - 1);
            }
            k = j - 1;
        }
    }
    int kk = 1;
    while (kk < _function_lambda_definitions_after.Count)
    {
        int j = 0;
        while (j < _defs.defs.Count && ((procedure_definition)_defs.defs[j]).proc_header.name.meth_name.name != (string)_function_lambda_definitions_after[kk])
            j++;
        if (j < _defs.defs.Count)
        {
            _defs.defs.Insert(j + 1, (declaration)lambda((function_lambda_definition)_function_lambda_definitions_after[kk - 1]));
            _function_lambda_definitions_after.RemoveAt(kk);
            _function_lambda_definitions_after.RemoveAt(kk - 1);
        }
        else
            kk += 2;
    }
    block _block = new block(_defs, ((block)LRParser.GetReductionSyntaxNode(2)).program_code);
    ///////////////////////////////
											program_module _program_module = new program_module(null, ul, (block)LRParser.GetReductionSyntaxNode(2), null);

            									_program_module.Language = LanguageId.PascalABCNET;
            									parsertools.create_source_context(_program_module, parsertools.sc_not_null(null, ul, null, LRParser.GetReductionSyntaxNode(2)), LRParser.GetReductionSyntaxNode(2));

                                                _functions.Clear();
                                                _function_lambda_definitions.Clear();
                                                func_name.Clear();
                                                lambda_num = 0;
                                                list_method_calls.Clear();
                                                list_method_calls_main.Clear();
                                                list_return_funcs.Clear();
                                                list_return_funcs_main.Clear();
                                                list_params1.Clear();
                                                list_method_calls_lambda.Clear();
                                                last_list_method_calls.Clear();
                                                last_list_method_calls_lambda.Clear();
                                                last_function_lambda_definitions.Clear();
                                                let_funcs1.Clear();
                                                let_funcs_funcs.Clear();
                                                let_func_last.Clear();
                                                let_flag.Clear();
                                                let_where_funcs.Clear();
                                                token_where_count = 0;
                                                let_where_funcs_main.Clear();
                                                let_where_funcs.Clear();
                                                token_where = 0;
                                                last_where_funcs.Clear();
                                                let_where_list_params.Clear();
                                                _function_lambda_definitions_main.Clear();
                                                let_stack.Clear();
                                                lambda_stack.Clear();
                                                token_let = 0;

            									return _program_module;
										}
    case (int)RuleConstants.RULE_MODULE_TKMODULE_TKIDENT_TKWHERE:
//<module> ::= 'tkModule' 'tkIdent' 'tkWhere' <reference> <imports> <funcs> <empty>
{
    ident_list _ident_list = new ident_list();
    _ident_list.idents.Add(new ident("LibForHaskell"));
    unit_or_namespace _unit_or_namespace = new unit_or_namespace(_ident_list);
    uses_list ul = (uses_list)LRParser.GetReductionSyntaxNode(4);
    if (ul == null)
        ul = new uses_list();
    ul.units.Insert(0, _unit_or_namespace);
    ////////////////
    declarations _defs = new declarations();
    for (int i = 0; i < _function_lambda_definitions.Count; i++)
        _defs.defs.Add((declaration)lambda((function_lambda_definition)_function_lambda_definitions[i]));
    for (int i = 0; i < _functions.Count; i++)
    {
        _defs.defs.Add((declaration)_functions[i]);
        int k = 1;
        while (k < _function_lambda_definitions_after.Count)
        {
            int j = k;
            while (j < _function_lambda_definitions_after.Count && ((procedure_definition)_functions[i]).proc_header.name.meth_name.name != (string)_function_lambda_definitions_after[j])
                j += 2;
            if (j < _function_lambda_definitions_after.Count)
            {
                _defs.defs.Add((declaration)lambda((function_lambda_definition)_function_lambda_definitions_after[j - 1]));
                _function_lambda_definitions_after.RemoveAt(j);
                _function_lambda_definitions_after.RemoveAt(j - 1);
            }
            k = j;
        }
    }
    int kk = 1;
    while (kk < _function_lambda_definitions_after.Count)
    {
        int j = 0;
        while (j < _defs.defs.Count && ((procedure_definition)_defs.defs[j]).proc_header.name.meth_name.name != (string)_function_lambda_definitions_after[kk])
            j++;
        if (j < _defs.defs.Count)
        {
            _defs.defs.Insert(j + 1, (declaration)lambda((function_lambda_definition)_function_lambda_definitions_after[kk - 1]));
            _function_lambda_definitions_after.RemoveAt(kk);
            _function_lambda_definitions_after.RemoveAt(kk - 1);
        }
        else
            kk += 2;
    }

    //for (int i = 0; i < _function_lambda_definitions.Count; i++)
    //_defs.defs.Add(lambda((function_lambda_definition)_function_lambda_definitions[i]));
    for (int i = 0; i < let_where_funcs.Count; i++)
        _defs.defs.Add((procedure_definition)let_where_funcs[i]);

    //////////////////////////interface
    interface_node _interface_node = new interface_node();
    _interface_node.uses_modules = ul;
    _interface_node.using_namespaces = null;
    _interface_node.interface_definitions = LRParser.GetReductionSyntaxNode(5) as declarations;
    ///////////////////////////unit_heading
    unit_name _unit_name = new unit_name((ident)LRParser.GetReductionSyntaxNode(1), UnitHeaderKeyword.Unit);
    initfinal_part _initfinal_part=new initfinal_part();
    unit_module _unit_module = new unit_module(_unit_name, _interface_node, null, _initfinal_part.initialization_sect, _initfinal_part.finalization_sect);
    _unit_module.Language = LanguageId.PascalABCNET;

    _functions.Clear();
    _function_lambda_definitions.Clear();
    func_name.Clear();
    lambda_num = 0;
    list_method_calls.Clear();
    list_method_calls_main.Clear();
    list_return_funcs.Clear();
    list_return_funcs_main.Clear();
    list_params1.Clear();
    list_method_calls_lambda.Clear();
    last_list_method_calls.Clear();
    last_list_method_calls_lambda.Clear();
    last_function_lambda_definitions.Clear();
    let_funcs1.Clear();
    let_funcs_funcs.Clear();
    let_func_last.Clear();
    let_flag.Clear();
    token_where_count = 0;
    let_where_funcs_main.Clear();
    let_where_funcs.Clear();
    token_where = 0;
    last_where_funcs.Clear();
    let_where_list_params.Clear();
    _function_lambda_definitions_main.Clear();
    let_stack.Clear();
    token_let = 0;
    lambda_stack.Clear();

    return _unit_module;
}
	case (int)RuleConstants.RULE_REFERENCE :
	//<reference> ::= 
	//NONTERMINAL:<reference> ::= 
	return null;
	//ENDNONTERMINAL
	case (int)RuleConstants.RULE_REFERENCE_TKREF_TKSTRING :
	//<reference> ::= 'tkRef' 'tkString'
{
            							token_info t1 = new token_info();
            							t1.text = ((ident)LRParser.GetReductionSyntaxNode(0)).name;
            							t1.source_context = ((ident)LRParser.GetReductionSyntaxNode(0)).source_context;
            							token_info t2 = new token_info();
            							t2.text = ((string_const)LRParser.GetReductionSyntaxNode(1)).Value;
            							t2.source_context = ((string_const)LRParser.GetReductionSyntaxNode(1)).source_context;
            							compiler_directive cd = new compiler_directive(t1, t2);
            							parsertools.create_source_context(cd, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
            							CompilerDirectives.Add(cd);
            							return null;
        							}
	case (int)RuleConstants.RULE_IMPORTS :
	//<imports> ::= 
	//NONTERMINAL:<imports> ::= 
	return null;
	//ENDNONTERMINAL
	case (int)RuleConstants.RULE_IMPORTS2 :
	//<imports> ::= <import> <empty>
{
            							uses_list _uses_list = new uses_list();

            							_uses_list.units.Add((unit_or_namespace)LRParser.GetReductionSyntaxNode(0));

            							return _uses_list;
        							}
    case (int)RuleConstants.RULE_IMPORTS3:
//<imports> ::= <imports> <empty> <import>
{
            							uses_list _uses_list = (uses_list)LRParser.GetReductionSyntaxNode(0);
            							_uses_list.units.Add((unit_or_namespace)LRParser.GetReductionSyntaxNode(2));

            							return _uses_list;
        							}
	case (int)RuleConstants.RULE_IMPORT_TKIMPORT_TKIDENT :
	//<import> ::= 'tkImport' 'tkIdent'
{
            							ident_list _ident_list = new ident_list();
            							_ident_list.source_context = ((ident)LRParser.GetReductionSyntaxNode(1)).source_context;
            							_ident_list.idents.Add((ident)LRParser.GetReductionSyntaxNode(1));

            							unit_or_namespace _unit_or_namespace = new unit_or_namespace(_ident_list);
            							parsertools.create_source_context(_unit_or_namespace,_ident_list, _ident_list);

            							return _unit_or_namespace;
        							}
	case (int)RuleConstants.RULE_BODY :
	//<body> ::= <main_func>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_BODY2 :
	//<body> ::= <funcs> <main_func>

								{
            							token_info _token_info = new token_info(";");

           								_token_info.source_context = parsertools.GetTokenSourceContext();

            							block _block = new block((declarations)LRParser.GetReductionSyntaxNode(0), ((block)LRParser.GetReductionSyntaxNode(1)).program_code);

            							parsertools.create_source_context(_block, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(0), ((block)LRParser.GetReductionSyntaxNode(1)).program_code), _token_info);
            							return _block;
       							}

	case (int)RuleConstants.RULE_FUNCS :
	//<funcs> ::= <funcs_variants> <empty>
{
           								declarations _declarations = new declarations();
                                                      ArrayList funcs = (ArrayList)LRParser.GetReductionSyntaxNode(0);
                                        			for (int i = 0;i < funcs.Count;i++)
                                        			{
                                            			_declarations.defs.Add((declaration)funcs[i]);
                                            			parsertools.create_source_context(_declarations, parsertools.sc_not_null(_declarations, (declaration)funcs[i]), (declaration)funcs[i]);
                                        			}

                                        			param_value_list.Clear();
                                                      param_value_list_main.Clear();
                                        			body_variant_list.Clear();
                                        			body_variant_list_main.Clear();
								      guard_list.Clear();
                                                      guard_list_main.Clear();
							            list_params_main.Clear();
                                                      list_params.Clear();
                                                      list_param.Clear();
                                                      list_params_temp.Clear();
                                                      where_flag = false;
                                                      decls_counts = 0;
                                                      let_where_funcs.Clear();
            						      return _declarations;
        							}
	case (int)RuleConstants.RULE_FUNCS_VARIANTS :
	//<funcs_variants> ::= <variants> <empty>
{
param_value_list_main.Add(param_value_list.Clone());
    body_variant_list_main.Add(body_variant_list.Clone());
    list_method_calls_main.Add(list_method_calls.Clone());
    guard_list_main.Add(guard_list.Clone());
    list_params_main.Add(list_params.Clone());
    list_params.Clear();

    ArrayList funcs = new ArrayList();
    
    for (int k = 0; k < func_name.Count; k++)
    {
        //////////////////////////head

        method_name _method_name = new method_name(null, (ident)func_name[k], null);
        parsertools.create_source_context(_method_name, func_name[k], func_name[k]);

        function_header _function_header = new function_header();

        object rt = new object();
        _function_header.name = _method_name;
        if (_function_header.name.meth_name is template_type_name)
        {
            _function_header.template_args = (_function_header.name.meth_name as template_type_name).template_args;
            ident id = new ident(_function_header.name.meth_name.name);
            parsertools.create_source_context(id, _function_header.name.meth_name, _function_header.name.meth_name);
            _function_header.name.meth_name = id;
        }
        ////////////////////////////////params
        formal_parameters _formal_parametres = new formal_parameters();
        expression_list f = null;
        if (((ArrayList)param_value_list_main[k])[0] != null)
        {
            f = (expression_list)((ArrayList)param_value_list_main[k])[((ArrayList)param_value_list_main[k]).Count - 1];
            string s = "";
            for (int i = 0; i < ((ArrayList)param_value_list_main[k]).Count; i++)
            {
                for (int j = 0; j < ((expression_list)((ArrayList)param_value_list_main[k])[i]).expressions.Count; j++)
                    if (((expression_list)((ArrayList)param_value_list_main[k])[i]).expressions[j] is ident)
                        s += ((ident)((expression_list)((ArrayList)param_value_list_main[k])[i]).expressions[j]).name;
            }
            for (int i = 0; i < ((expression_list)((ArrayList)param_value_list_main[k])[((ArrayList)param_value_list_main[k]).Count - 1]).expressions.Count; i++)
            {
                ident_list _ident_list = new ident_list();
                ident id = new ident(s + i.ToString());
                _ident_list.source_context = id.source_context;
                _ident_list.idents.Add(id);
                named_type_reference _named_type_reference1 = new named_type_reference();

                ident idtype1 = new ident("datatype");
                _named_type_reference1.source_context = idtype1.source_context;
                _named_type_reference1.names.Add(idtype1);

                typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference1, parametr_kind.none, null);
                parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference1);

                _formal_parametres.params_list.Add(_typed_parametres);
            }
            _function_header.parameters = _formal_parametres;
        }
        //////////////////////////type
        {
            named_type_reference _named_type_reference11 = new named_type_reference();
            ident idtype11 = new ident("datatype");
            _named_type_reference11.source_context = idtype11.source_context;
            _named_type_reference11.names.Add(idtype11);

            rt = _named_type_reference11;
            _function_header.return_type = (type_definition)_named_type_reference11;
        }

        _function_header.of_object = false;
        _function_header.class_keyword = false;
        token_info _token_info = new token_info("function");
        _token_info.source_context = parsertools.GetTokenSourceContext();
        parsertools.create_source_context(_function_header, _token_info, rt);
        
        //////////////////////////////////////block
        statement_list stmt_l = new statement_list();

        statement last_if = null;
        ArrayList vars = new ArrayList();
        if (((ArrayList)param_value_list_main[k])[0] != null)
        {
            bool flag = false;
            for (int i = ((ArrayList)body_variant_list_main[k]).Count - 1; i >= 0; i--)
            {
                expression_list pv = (expression_list)((ArrayList)param_value_list_main[k])[i];
                statement body_part = (statement)((ArrayList)body_variant_list_main[k])[i];
                expression guard = null;
                if (i < ((ArrayList)guard_list_main[k]).Count)
                    guard = (expression)((ArrayList)guard_list_main[k])[i];

                if_node _if_node = new if_node(null, body_part, last_if);
                parsertools.create_source_context(_if_node, null, parsertools.sc_not_null(body_part, last_if));

                ///////////
                named_type_reference _named_type_reference111 = new named_type_reference();

                ident idtype111 = new ident("datatype");
                _named_type_reference111.source_context = idtype111.source_context;
                _named_type_reference111.names.Add(idtype111);

                expression_list el = new expression_list();
                el.expressions.Add(new ident("true") as expression);
                literal lt;
                string text = "boolean";
                lt = new string_const(text);
                el.expressions.Add(lt as expression);
                /////
                named_type_reference ntr = _named_type_reference111;
                new_expr newexpr = new new_expr(ntr, el, false, null);
                parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference111));
                ///////////
                expression last_expr = newexpr as expression;
                if (guard != null)
                    last_expr = guard;
                for (int j = 0; j < _function_header.parameters.params_list.Count; j++)
                {
                    typed_parameters tp = (typed_parameters)_function_header.parameters.params_list[j];
                    if (j < pv.expressions.Count && !(pv.expressions[j] is ident))//vstavka if (vyhod iz rekursii)
                    {
                        op_type_node _op_type_node = new op_type_node(Operators.Equal);
                        _op_type_node.source_context = parsertools.GetTokenSourceContext();
                        bin_expr _bin_expr = new bin_expr(tp.idents.idents[0] as expression, (expression)pv.expressions[j], _op_type_node.type);
                        parsertools.create_source_context(_bin_expr, tp.idents.idents[0], pv.expressions[j]);

                        op_type_node _op_type_node1 = new op_type_node(Operators.LogicalAND);
                        _op_type_node1.source_context = parsertools.GetTokenSourceContext();
                        bin_expr _bin_expr1 = new bin_expr(_bin_expr, last_expr, _op_type_node1.type);
                        parsertools.create_source_context(_bin_expr1, _bin_expr, last_expr);
                        last_expr = _bin_expr1;
                    }
                }
                _if_node.condition = _ob(last_expr);
                ////novye peremennye
                statement_list _ass = new statement_list();
                for (int j = 0; j < _function_header.parameters.params_list.Count; j++)
                {
                    if (j < pv.expressions.Count && pv.expressions[j] is ident && ((ident)pv.expressions[j]).name != _function_header.parameters.params_list[j].idents.idents[0].name)
                    {
                        ident_list il = new ident_list();
                        il.idents.Add(new ident(((ident)pv.expressions[j]).name));
                        method_call mc = find_method_call(((ident)pv.expressions[j]).name, k);
                        if (mc == null)
                        {
                            named_type_reference _named_type_reference1 = new named_type_reference();
                            ident idtype1 = new ident("datatype");
                            _named_type_reference1.source_context = idtype1.source_context;
                            _named_type_reference1.names.Add(idtype1);

                            var_def_statement _var_def_statement = new var_def_statement(il, (type_definition)_named_type_reference1, null, definition_attribute.None, false);
                            parsertools.create_source_context(_var_def_statement, il, _named_type_reference1);
                            var_statement _var_statement = new var_statement(_var_def_statement);
                            parsertools.create_source_context(_var_statement, null, _var_def_statement);
                            //((statement_list)_if_node.then_body).subnodes.Insert(0, _var_statement);//obyavlenie peremennoy
                            int ii = ((ArrayList)body_variant_list_main[k]).Count - 1;
                            int jj = 0;
                            bool b = false;
                            expression_list exl = (expression_list)((ArrayList)param_value_list_main[k])[ii];
                            while (ii > i && !b)
                            {
                                jj = 0;
                                while (jj < exl.expressions.Count && (!(exl.expressions[jj] is ident) || ((ident)exl.expressions[jj]).name != ((ident)pv.expressions[j]).name))
                                    jj++;
                                if (jj < exl.expressions.Count)
                                    b = true;
                                ii--;
                                if (ii > i)
                                    exl = (expression_list)((ArrayList)param_value_list_main[k])[ii];
                            }
                            if (!b)
                            {
                                int kk = 0;
                                while (kk < vars.Count && il.idents[0].name != ((var_statement)vars[kk]).var_def.vars.idents[0].name)
                                    kk++;
                                if (kk >= vars.Count)
                                    vars.Add(_var_statement);
                            }
                        }
                        else
                        {
                            bool b = false;
                            int ii = ((ArrayList)body_variant_list_main[k]).Count - 1;
                            int jj = 0;
                            expression_list exl = (expression_list)((ArrayList)param_value_list_main[k])[ii];
                            while (ii > i && !b)
                            {
                                jj = 0;
                                while (jj < exl.expressions.Count && (!(exl.expressions[jj] is ident) || ((ident)exl.expressions[jj]).name != ((ident)pv.expressions[j]).name))
                                    jj++;
                                if (jj < exl.expressions.Count)
                                    b = true;
                                ii--;
                                if (ii > i)
                                    exl = (expression_list)((ArrayList)param_value_list_main[k])[ii];
                            }
                            if (!b)
                            {
                                _function_header.parameters.params_list[j].vars_type = func_type(mc.parameters.expressions.Count);
                                stmt_l.subnodes.Add(var_st(((ident)pv.expressions[j]).name, func_type(mc.parameters.expressions.Count)));
                            }
                        }

                        op_type_node _op_type_node2 = new op_type_node(Operators.Assignment);
                        _op_type_node2.source_context = parsertools.GetTokenSourceContext();
                        assign _assign = new assign(il.idents[0] as addressed_value, _function_header.parameters.params_list[j].idents.idents[0] as expression, _op_type_node2.type);
                        parsertools.create_source_context(_assign, il.idents[0], _function_header.parameters.params_list[j].idents.idents[0]);
                        _ass.subnodes.Add(_assign);
                    }
                }

                ///////////////////////////////////////list_param
                if (((ArrayList)list_params_main[k]).Count != 0 && i < ((ArrayList)list_params_main[k]).Count)
                {
                    for (int ll = 0; ll < ((ArrayList)((ArrayList)list_params_main[k])[i]).Count; ll++)
                    {
                        //if (i == ((ArrayList)body_variant_list_main[k]).Count - 1)
                        for (int l = 0; l < ((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll]).Count; l++)
                        {
                            ident_list il1 = new ident_list();
                            il1.idents.Add(new ident(((ident)((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll])[l]).name));
                            named_type_reference _named_type_reference1 = new named_type_reference();
                            ident idtype1 = new ident("datatype");
                            _named_type_reference1.names.Add(idtype1);

                            var_def_statement _var_def_statement = new var_def_statement(il1, (type_definition)_named_type_reference1, null, definition_attribute.None, false);
                            parsertools.create_source_context(_var_def_statement, il1, _named_type_reference1);
                            var_statement _var_statement = new var_statement(_var_def_statement);
                            //stmt_l.subnodes.Add(_var_statement);
                            int j = 0;
                            while (j < vars.Count && il1.idents[0].name != ((var_statement)vars[j]).var_def.vars.idents[0].name)
                                j++;
                            if (j >= vars.Count)
                                vars.Add(_var_statement);
                        }
                        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
                        dot_node _dot_node = new dot_node(null, (addressed_value)(new ident("head")));
                        ident id = new ident();
                        for (int i1 = 0; i1 < ((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll]).Count; i1++)
                            id.name += ((ident)((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll])[i1]).name;
                        if (id.name != null)
                        {
                            _dot_node.left = (addressed_value)(id);
                            object o = null;
                            method_call _method_call = new method_call(o as expression_list);
                            if (_method_call is dereference)
                                ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                            assign _assign1 = new assign(((ident)((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll])[((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll]).Count - 1]) as addressed_value, _method_call as expression, _op_type_node.type);
                            _ass.subnodes.Add(_assign1);

                            ///
                            for (int i1 = ((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll]).Count - 2; i1 > 0; i1--)
                            {
                                _dot_node = new dot_node((addressed_value)id, (addressed_value)(new ident("tail")));
                                for (int j1 = 0; j1 < ((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll]).Count - 2 - i1; j1++)
                                {
                                    _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("tail")));
                                }
                                _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("head")));

                                _method_call = new method_call(o as expression_list);
                                if (_method_call is dereference)
                                    ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                                _assign1 = new assign(((ident)((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll])[i1]) as addressed_value, _method_call as expression, _op_type_node.type);
                                _ass.subnodes.Add(_assign1);
                            }

                            _dot_node = new dot_node((addressed_value)id, (addressed_value)(new ident("tail")));

                            for (int j1 = 0; j1 < ((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll]).Count - 2; j1++)
                            {
                                _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("tail")));
                            }
                            _method_call = new method_call(o as expression_list);
                            if (_method_call is dereference)
                                ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                            _assign1 = new assign(((ident)((ArrayList)((ArrayList)((ArrayList)list_params_main[k])[i])[ll])[0]) as addressed_value, _method_call as expression, _op_type_node.type);
                            _ass.subnodes.Add(_assign1);
                        }
                    }
                }
                ///////////////////////////////////////////////////////////////////////
                parsertools.create_source_context(_if_node, null, _if_node);
                last_if = new statement_list();
                for (int ii = 0; ii < _ass.subnodes.Count; ii++)
                    ((statement_list)last_if).subnodes.Add((assign)_ass.subnodes[ii]);

                ((statement_list)last_if).subnodes.Add(_if_node);
            }
            stmt_l.subnodes.Add(last_if);
        }
        else
        {
            stmt_l.subnodes.Add((statement)((ArrayList)body_variant_list_main[k])[0]);
        }

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

        block _block = new block(null, null);
        _block.defs = new declarations();
        for (int l = 0; l < vars.Count; l++)
            _block.defs.defs.Add(vars[l] as var_statement);

        statement_list sl = null;
        if (stmt_l is statement_list)
            sl = stmt_l as statement_list;
        else
        {
            sl = new statement_list();
            sl.subnodes.Add(stmt_l as statement);
            if (!(stmt_l is empty_statement))
                parsertools.assign_source_context(sl, stmt_l);
        }
        _block.program_code = sl;
        //////////////////
        ArrayList lamdas = find_lambda_funcs_main(_function_header.name.meth_name.name);
        for (int l = 0; l < lamdas.Count; l++)
            _block.defs.defs.Add(lambda((function_lambda_definition)lamdas[l]));
        //////////////////
        int r = 0;
        while (r < let_funcs_funcs.Count && ((string)((ArrayList)let_funcs_funcs[r])[0]) != _function_header.name.meth_name.name)
            r++;
        if (r < let_funcs_funcs.Count)
        {
            if (_block.defs == null)
                _block.defs = new declarations();
            for (int l = 0; l < ((ArrayList)((ArrayList)let_funcs_funcs[r])[1]).Count; l++)
                _block.defs.defs.Add(((ArrayList)((ArrayList)let_funcs_funcs[r])[1])[l] as procedure_definition);
        }
        let_funcs.Clear();
        //////////////////
        procedure_definition _procedure_definition = new procedure_definition(_function_header, null);
        rt = _function_header;
        if (_block != null)
        {
            rt = _block;
            if (_block is proc_block)
                _procedure_definition.proc_body = (proc_block)_block;
        }
        parsertools.create_source_context(_procedure_definition, _function_header, rt);
        funcs.Add(_procedure_definition);
        _functions.Add(_procedure_definition);
    }
    return funcs;}
	case (int)RuleConstants.RULE_VARIANTS :
	//<variants> ::= <variant> <empty>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_VARIANTS2 :
	//<variants> ::= <variants> <variant>
return LRParser.GetReductionSyntaxNode(0);
    case (int)RuleConstants.RULE_VARIANT_TKIDENT:
//<variant> ::= 'tkIdent' <params> <guard_body_list> <where_var>
{
    ArrayList body_list = (ArrayList)LRParser.GetReductionSyntaxNode(2);
    for (int g_ind = 0; g_ind < body_list.Count; g_ind++)
    {
        ///////////////////////////////////body
        statement_list st = null;

        statement_list body_1 = (statement_list)((ArrayList)body_list[g_ind])[1];

        if (LRParser.GetReductionSyntaxNode(3) != null)
        {
            ArrayList ar = (ArrayList)LRParser.GetReductionSyntaxNode(3);
            for (int ii = 0; ii < ar.Count; ii++)
                where_funcs.Add(ar[ii]);

            statement_list _statement_list = body_1;
            //////////////////////////////////////////////for guard
            formal_parameters _formal_parametres = null;
            //////////////////////////
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _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_parametres;
            _procedure_definition.return_type = (type_definition)_named_type_reference1;
            _procedure_definition.ident_list = null;
            _procedure_definition.proc_body = null;
            _procedure_definition.parameters = null;
            _procedure_definition.lambda_name = "__lam_where__" + lambda_num;
            //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, null, null, null, "lambda_where" + lambda_num);
            _procedure_definition.proc_body = _statement_list;
            procedure_definition pr = lambda(_procedure_definition);
            //_function_lambda_definitions.Add(_procedure_definition);////////////////
            ((block)pr.proc_body).defs = new declarations();
            int start = 0;
            int k = where_funcs.Count - 1;
            while (k > 0 && ((procedure_definition)where_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
                k--;
            int kk = 0;
            while (k > 0 && kk < ar.Count - 1 && !((procedure_definition)where_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
            {
                k--;
                kk++;
            }
            start = k;
            int i = start;
            int n = where_funcs.Count;
            if (start >= 0)
                while (i < n)
                {
                    ((block)pr.proc_body).defs.defs.Add((procedure_definition)where_funcs[start]);
                    where_funcs.RemoveAt(start);
                    i++;
                }
            /////////////////////////////////lambda
            if (lambda_stack.Count > 0 && ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count == 0)
                lambda_stack.RemoveAt(lambda_stack.Count - 1);
            if (lambda_stack.Count > 0)
            {
                if (((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count > 0)
                {
                    if (((block)pr.proc_body).defs == null)
                        ((block)pr.proc_body).defs = new declarations();
                    for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
                        ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[ii]);
                    for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
                        _function_lambda_definitions.RemoveAt(_function_lambda_definitions.Count - 1);
                }
                //lambda_stack.RemoveAt(lambda_stack.Count - 1);
            }
            //////////////////////////////////
            where_funcs.Add(pr);
            //if (let_flag.Count > 0)
            //let_func_last.Add(pr);
            expression_list el = new expression_list();
            //where_fact_params.Clear();
            op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            assign _assign = new assign((addressed_value)new ident("result"), new ident(_procedure_definition.lambda_name), Operators.Assignment);

            statement_list _statement_list1 = new statement_list();
            _statement_list1.subnodes.Add(_assign);
            st = _statement_list1;
        }
        else
        {
            //////////////////////////////////////////////for guard
            st = body_1;
        }
        ///////////////////////////////////\body


        ////////////////////////////////////////////////////for let & where
        let_where_funcs.Clear();
        while (let_where_funcs_main.Count > 1)
            let_where_funcs_main.RemoveAt(let_where_funcs_main.Count - 1);
        list_params1.Clear();
        let_flag.Clear();
        int iiii = 0;
        while (iiii < func_name.Count && ((ident)func_name[iiii]).name != ((ident)LRParser.GetReductionSyntaxNode(0)).name)
            iiii++;
        if (iiii == func_name.Count && let_funcs_funcs.Count == 0 || (let_funcs_funcs.Count > 0 && ((string)((ArrayList)let_funcs_funcs[let_funcs_funcs.Count - 1])[0]) != ((ident)LRParser.GetReductionSyntaxNode(0)).name))
        {
            ArrayList ar = new ArrayList();
            ar.Add(((ident)LRParser.GetReductionSyntaxNode(0)).name);
            if (where_funcs.Count > 0)
            {
                for (int i = 0; i < let_funcs.Count; i++)
                    ((block)((procedure_definition)where_funcs[0]).proc_body).defs.defs.Add((procedure_definition)let_funcs[i]);
                ar.Add(where_funcs.Clone());
            }
            else
                ar.Add(let_funcs.Clone());
            let_funcs_funcs.Add(ar);
            let_funcs.Clear();
            where_funcs.Clear();
            let_func_last.Clear();
        }
        else
        {
            int r = 0;
            while (r < let_funcs_funcs.Count && ((string)((ArrayList)let_funcs_funcs[r])[0]) !=
                ((ident)LRParser.GetReductionSyntaxNode(0)).name)
                r++;
            if (r < let_funcs_funcs.Count)
            {
                if (where_funcs.Count > 0)
                {
                    for (int i = 0; i < let_funcs.Count; i++)
                        ((block)((procedure_definition)where_funcs[0]).proc_body).defs.defs.Add((procedure_definition)let_funcs[i]);
                    for (int i = 0; i < where_funcs.Count; i++)
                        ((ArrayList)((ArrayList)let_funcs_funcs[r])[1]).Add(where_funcs[i]);
                }
                else
                    for (int i = 0; i < let_funcs.Count; i++)
                        ((ArrayList)((ArrayList)let_funcs_funcs[r])[1]).Add(let_funcs[i]);
                let_funcs.Clear();
                where_funcs.Clear();
                let_func_last.Clear();
            }
        }

        if (iiii == func_name.Count)
        {
            /////////////////////////////////////////////////////
            ArrayList ar_lambda = new ArrayList();
            ar_lambda.Add(((ident)LRParser.GetReductionSyntaxNode(0)).name);
            ar_lambda.Add(_function_lambda_definitions.Clone());
            _function_lambda_definitions_main.Add(ar_lambda.Clone());
            _function_lambda_definitions.Clear();
            /////////////////////////////////////////////////////
        }
        else
        {
            //////////////////////////////////
            ArrayList ar_lambda = (ArrayList)_function_lambda_definitions.Clone();
            for (int i = 0; i < ar_lambda.Count; i++)
                ((ArrayList)((ArrayList)_function_lambda_definitions_main[_function_lambda_definitions_main.Count - 1])[1]).Add(ar_lambda[i]);
            _function_lambda_definitions.Clear();
            //////////////////////////////////
        }
        ////////////////////////////////////////////////////

        if (st/* LRParser.GetReductionSyntaxNode(2)*/ != null)
        {
            int i = 0;
            while (i < func_name.Count && ((ident)func_name[i]).name != ((ident)LRParser.GetReductionSyntaxNode(0)).name)
                i++;
            if (i == func_name.Count)
            {
                func_name.Add((ident)LRParser.GetReductionSyntaxNode(0));
                list_return_funcs_main.Add(list_return_funcs.Clone());
                list_return_funcs.Clear();
                if (list_method_calls_main.Count > 0)
                    for (int iii = 0; iii < ((ArrayList)list_method_calls_main[list_method_calls_main.Count - 1]).Count; iii++)
                        if (list_method_calls.Count > 0)
                            list_method_calls.RemoveAt(0);
                list_method_calls_main.Add(list_method_calls.Clone());
                if (param_value_list.Count != 0)
                {
                    param_value_list_main.Add(param_value_list.Clone());
                    body_variant_list_main.Add(body_variant_list.Clone());
                    guard_list_main.Add(guard_list.Clone());
                    list_params_main.Add(list_params.Clone());
                }
                param_value_list.Clear();
                body_variant_list.Clear();
                guard_list.Clear();
                list_params.Clear();
                param_value_list.Add(LRParser.GetReductionSyntaxNode(1));
                ////////////////Dobavlyaem formalnye parametry
                //statement_list st = (statement_list)LRParser.GetReductionSyntaxNode(4);
                if (st.subnodes[0] is assign)
                {
                    if (((assign)st.subnodes[0]).from is function_lambda_call)
                    {
                        function_lambda_call flc = (function_lambda_call)(((assign)st.subnodes[0]).from);
                        function_lambda_definition fld = ((function_lambda_call)(((assign)st.subnodes[0]).from)).f_lambda_def;
                        for (int ind = flc.parameters.expressions.Count; ind < fld.parameters.expressions.Count; ind++)
                        {
                            if (param_value_list.Count == 0)
                                param_value_list.Add(new expression_list());
                            if (param_value_list[param_value_list.Count - 1] == null)
                                param_value_list[param_value_list.Count - 1] = new expression_list();
                            ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(fld.parameters.expressions[ind]);
                        }
                    }
                    if (((assign)st.subnodes[0]).from is method_call)
                    {
                        method_call mc = (method_call)(((assign)st.subnodes[0]).from);
                        int jjj = 0;
                        int ind_null = -1;
                        while (jjj < mc.parameters.expressions.Count)
                            if (mc.parameters.expressions[jjj] is new_expr && ((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0] is string_const &&
                                ((string_const)((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0]).Value == "$null")
                            {
                                ind_null = jjj;
                                jjj = mc.parameters.expressions.Count;
                            }
                            else
                                jjj++;
                        if (ind_null >= 0)
                            for (int ind = ind_null; ind < mc.parameters.expressions.Count; ind++)
                            {
                                //int j = 0;
                                //while ()
                                if (param_value_list.Count == 0)
                                    param_value_list.Add(new expression_list());
                                if (param_value_list[param_value_list.Count - 1] == null)
                                    param_value_list[param_value_list.Count - 1] = new expression_list();
                                ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.Insert(ind, new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.RemoveAt(ind + 1);
                            }
                    }
                }
                ////////////////
                body_variant_list.Add(st);
                //guard_list.Add(LRParser.GetReductionSyntaxNode(2));
                guard_list.Add(((ArrayList)body_list[g_ind])[0]);
                if (list_params_temp.Count != 0)
                {
                    list_params.Add(list_params_temp.Clone());
                    list_params_temp.Clear();
                }
            }
            else
            {
                ArrayList ar = (ArrayList)list_method_calls.Clone();
                for (int iii = 0; iii < list_method_calls.Count; iii++)
                    ((ArrayList)list_method_calls_main[list_method_calls_main.Count - 1]).Add(ar[iii]);
                param_value_list.Add(LRParser.GetReductionSyntaxNode(1));
                ////////////////Dobavlyaem formalnye parametry
                //statement_list st = (statement_list)LRParser.GetReductionSyntaxNode(4);
                if (st.subnodes[0] is assign)
                {
                    if (((assign)st.subnodes[0]).from is function_lambda_call)
                    {
                        function_lambda_call flc = (function_lambda_call)(((assign)st.subnodes[0]).from);
                        function_lambda_definition fld = ((function_lambda_call)(((assign)st.subnodes[0]).from)).f_lambda_def;
                        for (int ind = flc.parameters.expressions.Count; ind < fld.parameters.expressions.Count; ind++)
                        {
                            if (param_value_list.Count == 0)
                                param_value_list.Add(new expression_list());
                            if (param_value_list[param_value_list.Count - 1] == null)
                                param_value_list[param_value_list.Count - 1] = new expression_list();
                            ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(fld.parameters.expressions[ind]);
                        }
                    }
                    if (((assign)st.subnodes[0]).from is method_call)
                    {
                        method_call mc = (method_call)(((assign)st.subnodes[0]).from);
                        int jjj = 0;
                        int ind_null = -1;
                        while (jjj < mc.parameters.expressions.Count)
                            if (mc.parameters.expressions[jjj] is new_expr && ((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0] is string_const &&
                                ((string_const)((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0]).Value == "$null")
                            {
                                ind_null = jjj;
                                jjj = mc.parameters.expressions.Count;
                            }
                            else
                                jjj++;
                        if (ind_null >= 0)
                            for (int ind = ind_null; ind < mc.parameters.expressions.Count; ind++)
                            {
                                if (param_value_list.Count == 0)
                                    param_value_list.Add(new expression_list());
                                if (param_value_list[param_value_list.Count - 1] == null)
                                    param_value_list[param_value_list.Count - 1] = new expression_list();
                                ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.Insert(ind, new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.RemoveAt(ind + 1);
                            }
                    }
                }
                ////////////////
                body_variant_list.Add(st);
                //guard_list.Add(LRParser.GetReductionSyntaxNode(2));
                guard_list.Add(((ArrayList)body_list[g_ind])[0]);
                if (list_params_temp.Count != 0)
                {
                    list_params.Add(list_params_temp.Clone());
                    list_params_temp.Clear();
                }
            }
        }
        else
        {
            int i = 0;
            while (i < func_name.Count && ((ident)func_name[i]).name != ((ident)LRParser.GetReductionSyntaxNode(0)).name)
                i++;
            if (i == func_name.Count)
            {
                func_name.Add((ident)LRParser.GetReductionSyntaxNode(0));
            }
        }
        list_params1.Clear();
        //int kk = last_list_method_calls.Count;
        //kk = last_function_lambda_definitions.Count;
        for (int i = 0; i < last_function_lambda_definitions.Count; i++)
        {
            for (int j = 0; j < ((function_lambda_definition)last_function_lambda_definitions[i]).formal_parameters.params_list.Count; j++)
            {
                string name_param = ((function_lambda_definition)last_function_lambda_definitions[i]).formal_parameters.params_list[j].idents.idents[0].name;
                int k = 0;
                while (k < last_list_method_calls.Count && ((ident)((method_call)last_list_method_calls[k]).dereferencing_value).name != name_param)
                    k++;
                if (k < last_list_method_calls.Count)
                {
                    function_lambda_definition fld = find_func_lambda_after(((function_lambda_definition)last_function_lambda_definitions[i]).lambda_name);
                    fld.formal_parameters.params_list[j].vars_type = func_type(((method_call)last_list_method_calls[k]).parameters.expressions.Count);
                }
            }
        }
        last_list_method_calls.Clear();
        last_function_lambda_definitions.Clear();
    }
    return null;
}
    case (int)RuleConstants.RULE_VARIANT_TKQUOTE_TKIDENT_TKQUOTE:
//<variant> ::= <list_param1> 'tkQuote' 'tkIdent' 'tkQuote' <list_param1> <guard_body_list> <where_var>
{
    ArrayList body_list = (ArrayList)LRParser.GetReductionSyntaxNode(5);
    for (int g_ind = 0; g_ind < body_list.Count; g_ind++)
    {
        ///////////////////////////////////body
        statement_list st = null;

        statement_list body_1 = (statement_list)((ArrayList)body_list[g_ind])[1];

        if (LRParser.GetReductionSyntaxNode(6) != null)
        {
            ArrayList ar = (ArrayList)LRParser.GetReductionSyntaxNode(6);
            for (int ii = 0; ii < ar.Count; ii++)
                where_funcs.Add(ar[ii]);

            statement_list _statement_list = body_1;
            //////////////////////////////////////////////for guard
            formal_parameters _formal_parametres = null;
            //////////////////////////
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _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_parametres;
            _procedure_definition.return_type = (type_definition)_named_type_reference1;
            _procedure_definition.ident_list = null;
            _procedure_definition.proc_body = null;
            _procedure_definition.parameters = null;
            _procedure_definition.lambda_name = "__lam_where__" + lambda_num;
            //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, null, null, null, "lambda_where" + lambda_num);
            _procedure_definition.proc_body = _statement_list;
            procedure_definition pr = lambda(_procedure_definition);
            //_function_lambda_definitions.Add(_procedure_definition);////////////////
            ((block)pr.proc_body).defs = new declarations();
            int start = 0;
            int k = where_funcs.Count - 1;
            while (k > 0 && ((procedure_definition)where_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
                k--;
            int kk = 0;
            while (k > 0 && kk < ar.Count - 1 && !((procedure_definition)where_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
            {
                k--;
                kk++;
            }
            start = k;
            int i = start;
            int n = where_funcs.Count;
            if (start >= 0)
                while (i < n)
                {
                    ((block)pr.proc_body).defs.defs.Add((procedure_definition)where_funcs[start]);
                    where_funcs.RemoveAt(start);
                    i++;
                }
            /////////////////////////////////lambda
            if (lambda_stack.Count > 0 && ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count == 0)
                lambda_stack.RemoveAt(lambda_stack.Count - 1);
            if (lambda_stack.Count > 0)
            {
                if (((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count > 0)
                {
                    if (((block)pr.proc_body).defs == null)
                        ((block)pr.proc_body).defs = new declarations();
                    for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
                        ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[ii]);
                    for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
                        _function_lambda_definitions.RemoveAt(_function_lambda_definitions.Count - 1);
                }
                //lambda_stack.RemoveAt(lambda_stack.Count - 1);
            }
            //////////////////////////////////
            where_funcs.Add(pr);
            //if (let_flag.Count > 0)
            //let_func_last.Add(pr);
            expression_list el = new expression_list();
            //where_fact_params.Clear();
            op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            assign _assign = new assign((addressed_value)new ident("result"), new ident(_procedure_definition.lambda_name), Operators.Assignment);

            statement_list _statement_list1 = new statement_list();
            _statement_list1.subnodes.Add(_assign);
            st = _statement_list1;
        }
        else
        {
            //////////////////////////////////////////////for guard
            st = body_1;
        }
        ///////////////////////////////////\body

        ident _ident = (ident)LRParser.GetReductionSyntaxNode(2);
        expression_list _ex_l1 = (expression_list)LRParser.GetReductionSyntaxNode(0);
        expression_list _ex_l2 = (expression_list)LRParser.GetReductionSyntaxNode(4);
        for (int i = 0; i < _ex_l2.expressions.Count; i++)
            _ex_l1.expressions.Add(_ex_l2.expressions[i]);

        ////////////////////////////////////////////////////for let & where
        let_where_funcs.Clear();
        while (let_where_funcs_main.Count > 1)
            let_where_funcs_main.RemoveAt(let_where_funcs_main.Count - 1);
        list_params1.Clear();
        let_flag.Clear();
        int iiii = 0;
        while (iiii < func_name.Count && ((ident)func_name[iiii]).name != _ident.name)
            iiii++;
        if (iiii == func_name.Count && let_funcs_funcs.Count == 0 || (let_funcs_funcs.Count > 0 && ((string)((ArrayList)let_funcs_funcs[let_funcs_funcs.Count - 1])[0]) != _ident.name))
        {
            ArrayList ar = new ArrayList();
            ar.Add(_ident.name);
            if (where_funcs.Count > 0)
            {
                for (int i = 0; i < let_funcs.Count; i++)
                    ((block)((procedure_definition)where_funcs[0]).proc_body).defs.defs.Add((procedure_definition)let_funcs[i]);
                ar.Add(where_funcs.Clone());
            }
            else
                ar.Add(let_funcs.Clone());
            let_funcs_funcs.Add(ar);
            let_funcs.Clear();
            where_funcs.Clear();
            let_func_last.Clear();
        }
        else
        {
            int r = 0;
            while (r < let_funcs_funcs.Count && ((string)((ArrayList)let_funcs_funcs[r])[0]) !=
                _ident.name)
                r++;
            if (r < let_funcs_funcs.Count)
            {
                if (where_funcs.Count > 0)
                {
                    for (int i = 0; i < let_funcs.Count; i++)
                        ((block)((procedure_definition)where_funcs[0]).proc_body).defs.defs.Add((procedure_definition)let_funcs[i]);
                    for (int i = 0; i < where_funcs.Count; i++)
                        ((ArrayList)((ArrayList)let_funcs_funcs[r])[1]).Add(where_funcs[i]);
                }
                else
                    for (int i = 0; i < let_funcs.Count; i++)
                        ((ArrayList)((ArrayList)let_funcs_funcs[r])[1]).Add(let_funcs[i]);
                let_funcs.Clear();
                where_funcs.Clear();
                let_func_last.Clear();
            }
        }

        if (iiii == func_name.Count)
        {
            /////////////////////////////////////////////////////
            ArrayList ar_lambda = new ArrayList();
            ar_lambda.Add(_ident.name);
            ar_lambda.Add(_function_lambda_definitions.Clone());
            _function_lambda_definitions_main.Add(ar_lambda.Clone());
            _function_lambda_definitions.Clear();
            /////////////////////////////////////////////////////
        }
        else
        {
            //////////////////////////////////
            ArrayList ar_lambda = (ArrayList)_function_lambda_definitions.Clone();
            for (int i = 0; i < ar_lambda.Count; i++)
                ((ArrayList)((ArrayList)_function_lambda_definitions_main[_function_lambda_definitions_main.Count - 1])[1]).Add(ar_lambda[i]);
            _function_lambda_definitions.Clear();
            //////////////////////////////////
        }
        ////////////////////////////////////////////////////

        if (st/*LRParser.GetReductionSyntaxNode(7)*/ != null)
        {
            int i = 0;
            while (i < func_name.Count && ((ident)func_name[i]).name != _ident.name)
                i++;
            if (i == func_name.Count)
            {
                func_name.Add(_ident);
                list_return_funcs_main.Add(list_return_funcs.Clone());
                list_return_funcs.Clear();
                if (list_method_calls_main.Count > 0)
                    for (int iii = 0; iii < ((ArrayList)list_method_calls_main[list_method_calls_main.Count - 1]).Count; iii++)
                        if (list_method_calls.Count > 0)
                            list_method_calls.RemoveAt(0);
                list_method_calls_main.Add(list_method_calls.Clone());
                if (param_value_list.Count != 0)
                {
                    param_value_list_main.Add(param_value_list.Clone());
                    body_variant_list_main.Add(body_variant_list.Clone());
                    guard_list_main.Add(guard_list.Clone());
                    list_params_main.Add(list_params.Clone());
                }
                param_value_list.Clear();
                body_variant_list.Clear();
                guard_list.Clear();
                list_params.Clear();
                param_value_list.Add(_ex_l1);
                ////////////////Dobavlyaem formalnye parametry
                //statement_list st = (statement_list)LRParser.GetReductionSyntaxNode(7);
                if (st.subnodes[0] is assign)
                {
                    if (((assign)st.subnodes[0]).from is function_lambda_call)
                    {
                        function_lambda_call flc = (function_lambda_call)(((assign)st.subnodes[0]).from);
                        function_lambda_definition fld = ((function_lambda_call)(((assign)st.subnodes[0]).from)).f_lambda_def;
                        for (int ind = flc.parameters.expressions.Count; ind < fld.parameters.expressions.Count; ind++)
                        {
                            if (param_value_list.Count == 0)
                                param_value_list.Add(new expression_list());
                            if (param_value_list[param_value_list.Count - 1] == null)
                                param_value_list[param_value_list.Count - 1] = new expression_list();
                            ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(fld.parameters.expressions[ind]);
                        }
                    }
                    if (((assign)st.subnodes[0]).from is method_call)
                    {
                        method_call mc = (method_call)(((assign)st.subnodes[0]).from);
                        int jjj = 0;
                        int ind_null = -1;
                        while (jjj < mc.parameters.expressions.Count)
                            if (mc.parameters.expressions[jjj] is new_expr && ((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0] is string_const &&
                                ((string_const)((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0]).Value == "$null")
                            {
                                ind_null = jjj;
                                jjj = mc.parameters.expressions.Count;
                            }
                            else
                                jjj++;
                        if (ind_null >= 0)
                            for (int ind = ind_null; ind < mc.parameters.expressions.Count; ind++)
                            {
                                //int j = 0;
                                //while ()
                                if (param_value_list.Count == 0)
                                    param_value_list.Add(new expression_list());
                                if (param_value_list[param_value_list.Count - 1] == null)
                                    param_value_list[param_value_list.Count - 1] = new expression_list();
                                ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.Insert(ind, new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.RemoveAt(ind + 1);
                            }
                    }
                }
                ////////////////
                body_variant_list.Add(st);
                //guard_list.Add(LRParser.GetReductionSyntaxNode(5));
                guard_list.Add(((ArrayList)body_list[g_ind])[0]);
                if (list_params_temp.Count != 0)
                {
                    list_params.Add(list_params_temp.Clone());
                    list_params_temp.Clear();
                }
            }
            else
            {
                ArrayList ar = (ArrayList)list_method_calls.Clone();
                for (int iii = 0; iii < list_method_calls.Count; iii++)
                    ((ArrayList)list_method_calls_main[list_method_calls_main.Count - 1]).Add(ar[iii]);
                param_value_list.Add(_ex_l1);
                ////////////////Dobavlyaem formalnye parametry
                //statement_list st = (statement_list)LRParser.GetReductionSyntaxNode(7);
                if (st.subnodes[0] is assign)
                {
                    if (((assign)st.subnodes[0]).from is function_lambda_call)
                    {
                        function_lambda_call flc = (function_lambda_call)(((assign)st.subnodes[0]).from);
                        function_lambda_definition fld = ((function_lambda_call)(((assign)st.subnodes[0]).from)).f_lambda_def;
                        for (int ind = flc.parameters.expressions.Count; ind < fld.parameters.expressions.Count; ind++)
                        {
                            if (param_value_list.Count == 0)
                                param_value_list.Add(new expression_list());
                            if (param_value_list[param_value_list.Count - 1] == null)
                                param_value_list[param_value_list.Count - 1] = new expression_list();
                            ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(fld.parameters.expressions[ind]);
                        }
                    }
                    if (((assign)st.subnodes[0]).from is method_call)
                    {
                        method_call mc = (method_call)(((assign)st.subnodes[0]).from);
                        int jjj = 0;
                        int ind_null = -1;
                        while (jjj < mc.parameters.expressions.Count)
                            if (mc.parameters.expressions[jjj] is new_expr && ((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0] is string_const &&
                                ((string_const)((new_expr)mc.parameters.expressions[jjj]).params_list.expressions[0]).Value == "$null")
                            {
                                ind_null = jjj;
                                jjj = mc.parameters.expressions.Count;
                            }
                            else
                                jjj++;
                        if (ind_null >= 0)
                            for (int ind = ind_null; ind < mc.parameters.expressions.Count; ind++)
                            {
                                if (param_value_list.Count == 0)
                                    param_value_list.Add(new expression_list());
                                if (param_value_list[param_value_list.Count - 1] == null)
                                    param_value_list[param_value_list.Count - 1] = new expression_list();
                                ((expression_list)param_value_list[param_value_list.Count - 1]).expressions.Add(new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.Insert(ind, new ident("$param" + ind));
                                ((method_call)(((assign)st.subnodes[0]).from)).parameters.expressions.RemoveAt(ind + 1);
                            }
                    }
                }
                ////////////////
                body_variant_list.Add(st);
                //guard_list.Add(LRParser.GetReductionSyntaxNode(5));
                guard_list.Add(((ArrayList)body_list[g_ind])[0]);
                if (list_params_temp.Count != 0)
                {
                    list_params.Add(list_params_temp.Clone());
                    list_params_temp.Clear();
                }
            }
        }
        else
        {
            int i = 0;
            while (i < func_name.Count && ((ident)func_name[i]).name != _ident.name)
                i++;
            if (i == func_name.Count)
            {
                func_name.Add(_ident);
            }
        }
        list_params1.Clear();
        //int kk = last_list_method_calls.Count;
        //kk = last_function_lambda_definitions.Count;
        for (int i = 0; i < last_function_lambda_definitions.Count; i++)
        {
            for (int j = 0; j < ((function_lambda_definition)last_function_lambda_definitions[i]).formal_parameters.params_list.Count; j++)
            {
                string name_param = ((function_lambda_definition)last_function_lambda_definitions[i]).formal_parameters.params_list[j].idents.idents[0].name;
                int k = 0;
                while (k < last_list_method_calls.Count && ((ident)((method_call)last_list_method_calls[k]).dereferencing_value).name != name_param)
                    k++;
                if (k < last_list_method_calls.Count)
                {
                    function_lambda_definition fld = find_func_lambda_after(((function_lambda_definition)last_function_lambda_definitions[i]).lambda_name);
                    fld.formal_parameters.params_list[j].vars_type = func_type(((method_call)last_list_method_calls[k]).parameters.expressions.Count);
                }
            }
        }
        last_list_method_calls.Clear();
        last_function_lambda_definitions.Clear();
    }
    return null;
}
    case (int)RuleConstants.RULE_LIST_PARAM1:
//<list_param1> ::= <list_param> <empty>
{
    bool b = false;
    if (list_param.Count == 1)
    {
        list_params_temp.Add(new ArrayList());
        let_where_list_params.Add(new ArrayList());//
        if (list_param[0] is new_expr && ((string_const)((new_expr)list_param[0]).params_list.expressions[1]).Value == "empty")
            b = true;
        list_param.Clear();
    }
    else
    {
        list_params_temp.Add(list_param.Clone());
        let_where_list_params.Add(list_param.Clone());//
    }
    expression_list _expression_list = new expression_list();
    if (list_param.Count == 0)
    {
        if (b)
        {
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            el.expressions.Add(new int32_const(0));
            literal lt;
            string text = "empty_list";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            _expression_list.expressions.Add(newexpr);
        }
        else
        {
            _expression_list.source_context = ((expression)LRParser.GetReductionSyntaxNode(0)).source_context;
            _expression_list.expressions.Add((expression)LRParser.GetReductionSyntaxNode(0));
        }
    }
    else
    {
        ident id = new ident();
        for (int i = 0; i < list_param.Count; i++)
        {
            if (list_param[i] is ident)
                id.name += ((ident)list_param[i]).name;
            else
            {
                errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "идентификатор"));
                return null;
            }
        }
        _expression_list.source_context = ((expression)id).source_context;
        _expression_list.expressions.Add((expression)id);
        list_param.Clear();
    }
    list_params1.Clear();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        list_params1.Add(_expression_list.expressions[i]);
    last_list_method_calls_lambda.Clear();
    return _expression_list;
}
    case (int)RuleConstants.RULE_BODY_WHERE:
    //<body_where> ::= <body_func> <where_var>
{
    //guard_list.Add(LRParser.GetReductionSyntaxNode(0));
    if (LRParser.GetReductionSyntaxNode(1) != null)
    {
        ArrayList ar = (ArrayList)LRParser.GetReductionSyntaxNode(1);
        for (int ii = 0; ii < ar.Count; ii++)
            where_funcs.Add(ar[ii]);

        statement_list _statement_list = (statement_list)LRParser.GetReductionSyntaxNode(0);
        //////////////////////////////////////////////for guard
        formal_parameters _formal_parametres = null;
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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_parametres;
        _procedure_definition.return_type = (type_definition)_named_type_reference1;
        _procedure_definition.ident_list = null;
        _procedure_definition.proc_body = null;
        _procedure_definition.parameters = null;
        _procedure_definition.lambda_name = "__lam_where__" + lambda_num;
        //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, null, null, null, "lambda_where" + lambda_num);
        _procedure_definition.proc_body = _statement_list;
        procedure_definition pr = lambda(_procedure_definition);
        //_function_lambda_definitions.Add(_procedure_definition);////////////////
        ((block)pr.proc_body).defs = new declarations();
        int start = 0;
        int k = where_funcs.Count - 1;
        while (k > 0 && ((procedure_definition)where_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
            k--;
        int kk = 0;
        while (k > 0 && kk < ar.Count - 1 && !((procedure_definition)where_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
        {
            k--;
            kk++;
        }
        start = k;
        int i = start;
        int n = where_funcs.Count;
        if (start >= 0)
            while (i < n)
            {
                ((block)pr.proc_body).defs.defs.Add((procedure_definition)where_funcs[start]);
                where_funcs.RemoveAt(start);
                i++;
            }
        /////////////////////////////////lambda
        if (lambda_stack.Count > 0 && ((ArrayList)lambda_stack[lambda_stack.Count-1]).Count==0)
            lambda_stack.RemoveAt(lambda_stack.Count - 1);
        if (lambda_stack.Count > 0)
        {
            if (((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count > 0)
            {
                if (((block)pr.proc_body).defs == null)
                    ((block)pr.proc_body).defs = new declarations();
                for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
                    ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[ii]);
                for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
                    _function_lambda_definitions.RemoveAt(_function_lambda_definitions.Count - 1);
            }
            //lambda_stack.RemoveAt(lambda_stack.Count - 1);
        }
        //////////////////////////////////
        where_funcs.Add(pr);
        //if (let_flag.Count > 0)
        //let_func_last.Add(pr);
        expression_list el = new expression_list();
        //where_fact_params.Clear();
        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), new ident(_procedure_definition.lambda_name), Operators.Assignment);

        statement_list _statement_list1 = new statement_list();
        _statement_list1.subnodes.Add(_assign);
        return _statement_list1;
    }
    else
    {
        //////////////////////////////////////////////for guard
        statement_list _statement_list = (statement_list)LRParser.GetReductionSyntaxNode(0);
        return _statement_list;
    }
}
	case (int)RuleConstants.RULE_WHERE_VAR :
	//<where_var> ::= 
	//NONTERMINAL:<where_var> ::= 
	return null;
	//ENDNONTERMINAL
    case (int)RuleConstants.RULE_WHERE_VAR_TKWHERE:
    //<where_var> ::= 'tkWhere' <inits>
    {
        token_where_count--;
        //let_where_funcs_main.RemoveAt(let_where_funcs_main.Count-1);
        let_where_funcs.Clear();
        return LRParser.GetReductionSyntaxNode(1);
    }
    case (int)RuleConstants.RULE_INITS:
//<inits> ::= <init> <empty>
{
    ArrayList ar = new ArrayList();
    ar.Add(LRParser.GetReductionSyntaxNode(0));
    return ar;
}
    case (int)RuleConstants.RULE_INITS_TKSEMICOLON:
//<inits> ::= <inits> 'tkSemiColon' <init>
{
    ArrayList ar = (ArrayList)LRParser.GetReductionSyntaxNode(0);
    ar.Add(LRParser.GetReductionSyntaxNode(2));
    return ar;
}
    case (int)RuleConstants.RULE_INIT_TKIDENT:
//<init> ::= 'tkIdent' <params_where> <guard_body_list> <where_var>
{
    expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(1);
    /*statement_list _statement_list = (statement_list)LRParser.GetReductionSyntaxNode(4);*/
    statement_list _statement_list = new statement_list();
    ArrayList ar_main = (ArrayList)LRParser.GetReductionSyntaxNode(2);
    ////////////////////////////for list
    statement_list stmt_l = new statement_list();
    int start = let_where_list_params.Count;
    if (_expression_list !=null)
        start = let_where_list_params.Count - _expression_list.expressions.Count;
    int i_ex = 0;
    for (int ll = start; ll < let_where_list_params.Count; ll++)
    {
        for (int l = 0; l < ((ArrayList)let_where_list_params[ll]).Count; l++)
        {
            ident_list il1 = new ident_list();
            il1.idents.Add(new ident(((ident)((ArrayList)let_where_list_params[ll])[l]).name));
            named_type_reference _n_t_r = new named_type_reference();
            ident it = new ident("datatype");
            _n_t_r.names.Add(it);

            var_def_statement _var_def_statement = new var_def_statement(il1, (type_definition)_n_t_r, null, definition_attribute.None, false);
            var_statement _var_statement = new var_statement(_var_def_statement);
            stmt_l.subnodes.Add(_var_statement);
        }
        if (((ArrayList)let_where_list_params[ll]).Count > 0)
        {
            op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            dot_node _dot_node = new dot_node(null, (addressed_value)(new ident("head")));
            ident id = _expression_list.expressions[i_ex] as ident;
            /*for (int i1 = 0; i1 < ((ArrayList)let_where_list_params[ll]).Count; i1++)
                id.name += ((ident)((ArrayList)let_where_list_params[ll])[i1]).name;*/
            if (id.name != null)
            {
                _dot_node.left = (addressed_value)(id);
                object o = null;
                method_call _method_call = new method_call(o as expression_list);
                if (_method_call is dereference)
                    ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                assign _assign1 = new assign(((ident)((ArrayList)let_where_list_params[ll])[((ArrayList)let_where_list_params[ll]).Count - 1]) as addressed_value, _method_call as expression, _op_type_node.type);
                stmt_l.subnodes.Add(_assign1);

                ///
                for (int i1 = ((ArrayList)let_where_list_params[ll]).Count - 2; i1 > 0; i1--)
                {
                    _dot_node = new dot_node((addressed_value)id, (addressed_value)(new ident("tail")));
                    for (int j1 = 0; j1 < ((ArrayList)let_where_list_params[ll]).Count - 2 - i1; j1++)
                    {
                        _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("tail")));
                    }
                    _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("head")));

                    _method_call = new method_call(o as expression_list);
                    if (_method_call is dereference)
                        ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                    _assign1 = new assign(((ident)((ArrayList)let_where_list_params[ll])[i1]) as addressed_value, _method_call as expression, _op_type_node.type);
                    stmt_l.subnodes.Add(_assign1);
                }

                _dot_node = new dot_node((addressed_value)id, (addressed_value)(new ident("tail")));

                for (int j1 = 0; j1 < ((ArrayList)let_where_list_params[ll]).Count - 2; j1++)
                {
                    _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("tail")));
                }
                _method_call = new method_call(o as expression_list);
                if (_method_call is dereference)
                    ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                _assign1 = new assign(((ident)((ArrayList)let_where_list_params[ll])[0]) as addressed_value, _method_call as expression, _op_type_node.type);
                stmt_l.subnodes.Add(_assign1);
            }
        }
        i_ex++;
    }
    for (int ll = 0; ll < let_where_list_params.Count - start; ll++)
        list_params_temp.RemoveAt(list_params_temp.Count - 1);
    for (int i = stmt_l.subnodes.Count - 1; i >= 0; i--)
        _statement_list.subnodes.Insert(0, stmt_l.subnodes[i]);
    if (_expression_list != null)
        for (int i = 0; i < _expression_list.expressions.Count; i++)
            let_where_list_params.RemoveAt(let_where_list_params.Count - 1);
    ////////////////////////////
    formal_parameters _formal_parametres = null;
    ident_list i_l = new ident_list();
    if (_expression_list != null)
    {
        for (int i = 0; i < _expression_list.expressions.Count; i++)
            i_l.idents.Add((ident)_expression_list.expressions[i]);
        /////////////////////////////
        _formal_parametres = new formal_parameters();
        for (int i = 0; i < i_l.idents.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_expression_list.expressions[i];
            _ident_list.idents.Add(id);
            string name_param = id.name;
            typed_parameters _typed_parametres = null;
            int k = 0;
            while (k < last_list_method_calls_lambda.Count && ((ident)((method_call)last_list_method_calls_lambda[k]).dereferencing_value).name != name_param)
                k++;
            if (k < last_list_method_calls_lambda.Count)
                _typed_parametres = new typed_parameters(_ident_list, func_type(((method_call)last_list_method_calls_lambda[k]).parameters.expressions.Count), parametr_kind.none, null);
            else
            {
                named_type_reference _named_type_reference = new named_type_reference();

                ident idtype = new ident("datatype");
                _named_type_reference.names.Add(idtype);

                _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
                parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);
            }
            _formal_parametres.params_list.Add(_typed_parametres);
        }
    }
    //////////////////////////
    named_type_reference _named_type_reference1 = new named_type_reference();
    ident idtype1 = new ident("datatype");
    _named_type_reference1.source_context = idtype1.source_context;
    _named_type_reference1.names.Add(idtype1);
    /////////////////////////////
    function_lambda_definition _procedure_definition = new function_lambda_definition();
    _procedure_definition.formal_parameters = _formal_parametres;
    _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 = ((ident)LRParser.GetReductionSyntaxNode(0)).name;
    //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _expression_list, ((ident)LRParser.GetReductionSyntaxNode(0)).name);
    object rt = _expression_list;
    ////////////////////////////////////////for guard
    for (int i = 0; i < ar_main.Count; i++)
        if (((ArrayList)ar_main[i])[0] != null)
        {
            if_node _if_node = new if_node();
            _if_node.condition = _ob((expression)((ArrayList)ar_main[i])[0]);
            _if_node.then_body = new statement_list();
            _if_node.then_body = (statement)((ArrayList)ar_main[i])[1];
            procedure_call _exit = new procedure_call(new ident("exit") as addressed_value);
            ((statement_list)_if_node.then_body).subnodes.Add(_exit);
            _statement_list.subnodes.Add(_if_node);
        }
        else
        {
            _statement_list.subnodes.Add((statement)((ArrayList)ar_main[i])[1]);
            procedure_call _exit = new procedure_call(new ident("exit") as addressed_value);
            _statement_list.subnodes.Add(_exit);
        }
    //////////////////////////////////////////
    _procedure_definition.proc_body = _statement_list;
    parsertools.create_source_context(_procedure_definition, _expression_list, rt);
    procedure_definition pr = lambda(_procedure_definition);
    ///////////////////////////
    ///////////////////////////
    if (LRParser.GetReductionSyntaxNode(3) != null)
    {
        if (((block)pr.proc_body).defs == null)
            ((block)pr.proc_body).defs = new declarations();
        for (int i = 0; i < ((ArrayList)LRParser.GetReductionSyntaxNode(3)).Count; i++)
            ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)LRParser.GetReductionSyntaxNode(3))[i]);
    }
    if (let_where_funcs.Count > 0)
    {
        if (((block)pr.proc_body).defs == null)
            ((block)pr.proc_body).defs = new declarations();
        for (int i = 0; i < let_where_funcs.Count; i++)
            ((block)pr.proc_body).defs.defs.Add((procedure_definition)let_where_funcs[i]);
        if (let_where_funcs_main.Count+1 > token_where_count)
        {
            if (((block)pr.proc_body).defs == null)
                ((block)pr.proc_body).defs = new declarations();
            for (int i = 0; i < last_where_funcs.Count; i++)
                ((block)pr.proc_body).defs.defs.Add((procedure_definition)last_where_funcs[i]);
            for (int i = 0; i < last_where_funcs.Count; i++)
                if (let_funcs.Count > 0)
                    let_funcs.RemoveAt(let_funcs.Count - 1);
            last_where_funcs.Clear();
        }
        let_where_funcs.Clear();
        let_func_last.Clear();
        let_flag.Clear();
    }
    else
        if (let_where_funcs_main.Count > 2 && let_where_funcs_main.Count>token_where_count)
        {
            ArrayList ar = new ArrayList();
            ar = (let_where_funcs_main[let_where_funcs_main.Count - 1] as ArrayList).Clone() as ArrayList;

            if (((block)pr.proc_body).defs == null)
                ((block)pr.proc_body).defs = new declarations();
            for (int i = 0; i < ar.Count; i++)
                ((block)pr.proc_body).defs.defs.Add((procedure_definition)ar[i]);
            let_where_funcs.Clear();
            let_func_last.Clear();
            let_flag.Clear();
            let_where_funcs_main.RemoveAt(let_where_funcs_main.Count-1);
            for (int i = 0; i < ar.Count; i++)
                if (let_funcs.Count > 0)
                    let_funcs.RemoveAt(let_funcs.Count - 1);
        }
    ///////////////////////////lambda
    if (lambda_stack.Count > 0)
    {
        if (((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count > 0)
        {
            if (((block)pr.proc_body).defs == null)
                ((block)pr.proc_body).defs = new declarations();
            for (int i = 0; i < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; i++)
                ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[i]);
            for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
                _function_lambda_definitions.RemoveAt(_function_lambda_definitions.Count - 1);
        }
        int number = ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count;
        for (int i = 0; i < number;i++ )
            lambda_stack.RemoveAt(lambda_stack.Count - 1);
    }
    ///////////////////////////
    return pr;
}
        case (int)RuleConstants.RULE_PARAMS_WHERE :
	//<params_where> ::= 
	//NONTERMINAL:<params_where> ::= 
	return null;
	//ENDNONTERMINAL
	case (int)RuleConstants.RULE_PARAMS_WHERE2 :
	//<params_where> ::= <param> <empty>
{
            							bool b = false;
    if (list_param.Count == 1)
    {
        list_params_temp.Add(new ArrayList());
        let_where_list_params.Add(new ArrayList());//
        if (list_param[0] is new_expr && ((string_const)((new_expr)list_param[0]).params_list.expressions[1]).Value == "empty")
            b = true;
        list_param.Clear();
    }
    else
    {
        list_params_temp.Add(list_param.Clone());
        let_where_list_params.Add(list_param.Clone());//
    }
    expression_list _expression_list = new expression_list();
    if (list_param.Count == 0)
    {
        if (b)
        {
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            el.expressions.Add(new int32_const(0));
            literal lt;
            string text = "empty_list";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            _expression_list.expressions.Add(newexpr);
        }
        else
        {
            _expression_list.source_context = ((expression)LRParser.GetReductionSyntaxNode(0)).source_context;
            _expression_list.expressions.Add((expression)LRParser.GetReductionSyntaxNode(0));
        }
    }
    else
    {
        ident id = new ident();
        for (int i = 0; i < list_param.Count; i++)
        {
            if (list_param[i] is ident)
                id.name += ((ident)list_param[i]).name;
            else
            {
                errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "идентификатор"));
                return null;
            }
        }
        _expression_list.source_context = ((expression)id).source_context;
        _expression_list.expressions.Add((expression)id);
        list_param.Clear();
    }
    list_params1.Clear();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        list_params1.Add(_expression_list.expressions[i]);
    last_list_method_calls_lambda.Clear();
    return _expression_list;
        							}
	case (int)RuleConstants.RULE_PARAMS_WHERE3 :
	//<params_where> ::= <params_where> <param>

								{
            							bool b = false;
    if (list_param.Count == 1)
    {
        list_params_temp.Add(new ArrayList());
        let_where_list_params.Add(new ArrayList());//
        if (list_param[0] is new_expr && ((string_const)((new_expr)list_param[0]).params_list.expressions[1]).Value == "empty")
            b = true;
        list_param.Clear();
    }
    else
    {
        list_params_temp.Add(list_param.Clone());
        let_where_list_params.Add(list_param.Clone());
    }
    expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(0);
    if (list_param.Count == 0)
    {
        if (!b)
        {
            _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(1) as expression);
        }
        else
        {
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            el.expressions.Add(new int32_const(0));
            literal lt;
            string text = "empty_list";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            _expression_list.expressions.Add(newexpr);
        }
    }
    else
    {
        ident id = new ident();
        for (int i = 0; i < list_param.Count; i++)
        {
            if (list_param[i] is ident)
                id.name += ((ident)list_param[i]).name;
            else
            {
                errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "идентификатор"));
                return null;
            }
        }
        _expression_list.expressions.Add((expression)id);
        list_param.Clear();
    }
    list_params1.Clear();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        list_params1.Add(_expression_list.expressions[i]);
    last_list_method_calls_lambda.Clear();
    return _expression_list;
        							}
	case (int)RuleConstants.RULE_PARAMS :
	//<params> ::= 
	//NONTERMINAL:<params> ::= 
	return null;
	//ENDNONTERMINAL
	case (int)RuleConstants.RULE_PARAMS2 :
	//<params> ::= <param> <empty>
{
    //let_flag.Add(1);
            							bool b = false;
    if (list_param.Count == 1)
    {
        list_params_temp.Add(new ArrayList());
        let_where_list_params.Add(new ArrayList());//
        if (list_param[0] is new_expr && ((string_const)((new_expr)list_param[0]).params_list.expressions[1]).Value == "empty")
            b = true;
        list_param.Clear();
    }
    else
    {
        list_params_temp.Add(list_param.Clone());
        let_where_list_params.Add(list_param.Clone());//
    }
    expression_list _expression_list = new expression_list();
    if (list_param.Count == 0)
    {
        if (b)
        {
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            el.expressions.Add(new int32_const(0));
            literal lt;
            string text = "empty_list";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            _expression_list.expressions.Add(newexpr);
        }
        else
        {
            _expression_list.source_context = ((expression)LRParser.GetReductionSyntaxNode(0)).source_context;
            _expression_list.expressions.Add((expression)LRParser.GetReductionSyntaxNode(0));
        }
    }
    else
    {
        ident id = new ident();
        for (int i = 0; i < list_param.Count; i++)
        {
            if (list_param[i] is ident)
                id.name += ((ident)list_param[i]).name;
            else
            {
                errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "идентификатор"));
                return null;
            }
        }
        _expression_list.source_context = ((expression)id).source_context;
        _expression_list.expressions.Add((expression)id);
        list_param.Clear();
    }
    list_params1.Clear();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        list_params1.Add(_expression_list.expressions[i]);
    last_list_method_calls_lambda.Clear();
    return _expression_list;
        							}
	case (int)RuleConstants.RULE_PARAMS3 :
	//<params> ::= <params> <param>

								{
            							bool b = false;
    if (list_param.Count == 1)
    {
        list_params_temp.Add(new ArrayList());
        let_where_list_params.Add(new ArrayList());//
        if (list_param[0] is new_expr && ((string_const)((new_expr)list_param[0]).params_list.expressions[1]).Value == "empty")
            b = true;
        list_param.Clear();
    }
    else
    {
        list_params_temp.Add(list_param.Clone());
        let_where_list_params.Add(list_param.Clone());//
    }
    expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(0);
    if (list_param.Count == 0)
    {
        if (!b)
        {
            _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(1) as expression);
        }
        else
        {
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            el.expressions.Add(new int32_const(0));
            literal lt;
            string text = "empty_list";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            _expression_list.expressions.Add(newexpr);
        }
    }
    else
    {
        ident id = new ident();
        for (int i = 0; i < list_param.Count; i++)
        {
            if (list_param[i] is ident)
                id.name += ((ident)list_param[i]).name;
            else
            {
                errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "идентификатор"));
                return null;
            }
        }
        _expression_list.expressions.Add((expression)id);
        list_param.Clear();
    }
    list_params1.Clear();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        list_params1.Add(_expression_list.expressions[i]);
    last_list_method_calls_lambda.Clear();
    return _expression_list;
        							}
								
	case (int)RuleConstants.RULE_PARAM :
	//<param> ::= <list_param>
return LRParser.GetReductionSyntaxNode(0);
    case (int)RuleConstants.RULE_LIST_PARAM_TKIDENT:
//<list_param> ::= 'tkIdent' <empty>
{
    list_param.Add(LRParser.GetReductionSyntaxNode(0));
    return LRParser.GetReductionSyntaxNode(0);
}
    case (int)RuleConstants.RULE_LIST_PARAM :
	//<list_param> ::= <simple_type_expr> <empty>
{
    list_param.Add(LRParser.GetReductionSyntaxNode(0));
    return LRParser.GetReductionSyntaxNode(0);
}
    case (int)RuleConstants.RULE_LIST_PARAM_TKSQUAREOPEN_TKSQUARECLOSE:
//<list_param> ::= 'tkSquareOpen' 'tkSquareClose'
{
    ArrayList list_elements = new ArrayList();//(ArrayList)LRParser.GetReductionSyntaxNode(1);
    //////////////////////////////////////////////////////////proverka na type
    if (list_elements != null)
    {
        ArrayList types = new ArrayList();
        for (int i = 0; i < list_elements.Count; i++)
        {
            string tp = "";
            if (list_elements[i] is new_expr)
            {
                tp = ((string_const)((new_expr)list_elements[i]).params_list.expressions[1]).Value;
                if (!types.Contains(tp))
                    types.Add(tp);
            }
        }
        if ((types.Count == 2 && !(types.Contains("integer") && types.Contains("real"))) || types.Count > 2)
        {
            //errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "одинаковый тип элементов списка"));
            errors.Add(new PascalABCCompiler.Errors.Error("элементы списка имеют разный тип"));
            return null;
        }
    }
    //////////////////////////////////////////////////////////
    named_type_reference _named_type_reference1 = new named_type_reference();
    ident idtype1 = new ident("datatype_list");
    _named_type_reference1.source_context = idtype1.source_context;
    _named_type_reference1.names.Add(idtype1);
    expression_list el = new expression_list();
    if (list_elements == null)
        list_elements = new ArrayList();
    int32_const n = new int32_const(list_elements.Count);
    el.expressions.Add(n);
    if (list_elements.Count > 0)
    {
        el.expressions.Add(new string_const("list"));
    }
    else
        el.expressions.Add(new string_const("empty"));
    for (int i = 0; i < list_elements.Count; i++)
        el.expressions.Add(list_elements[i] as expression);
    named_type_reference ntr = _named_type_reference1;
    new_expr newexpr = new new_expr(ntr, el, false, null);
    parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
    list_param.Add(newexpr);
    return newexpr;
}
    case (int)RuleConstants.RULE_LIST_PARAM_TKBOTTOMMINUS:
//<list_param> ::= 'tkBottomMinus'
{
    ident _ident = new ident("$$$" + bottom_num);
    list_param.Add(_ident);
    bottom_num++;
    return _ident;
}
    case (int)RuleConstants.RULE_LIST_PARAM_TKIDENT_TKCOLON:
//<list_param> ::= 'tkIdent' 'tkColon' <list_param>
{  
								list_param.Add(LRParser.GetReductionSyntaxNode(0));
            							return LRParser.GetReductionSyntaxNode(0);
        							}
    case (int)RuleConstants.RULE_LIST_PARAM_TKBOTTOMMINUS_TKCOLON:
//<list_param> ::= 'tkBottomMinus' 'tkColon' <list_param>
{
    ident _ident = new ident("$$$" + bottom_num);
    list_param.Add(_ident);
    bottom_num++;
    return _ident;
}
    case (int)RuleConstants.RULE_LIST_PARAM_TKROUNDOPEN_TKROUNDCLOSE:
//<list_param> ::= 'tkRoundOpen' <list_param> 'tkRoundClose'
{
    return LRParser.GetReductionSyntaxNode(1);
}
    case (int)RuleConstants.RULE_GUARD :
	//<guard> ::= 
	//NONTERMINAL:<guard> ::= 
	return null;
	//ENDNONTERMINAL
	case (int)RuleConstants.RULE_GUARD_TKSPLIT :
	//<guard> ::= 'tkSplit' <expr>
    return LRParser.GetReductionSyntaxNode(1);
    case (int)RuleConstants.RULE_GUARD_TKSPLIT_TKOTHERWISE:
    //<guard> ::= 'tkSplit' 'tkOtherwise'
    {
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _named_type_reference1.names.Add(idtype1);
        /////
        expression_list el = new expression_list();
        el.expressions.Add(new ident("true") as expression);
        literal lt;
        string text = "boolean";
        lt = new string_const(text);
        el.expressions.Add(lt as expression);
        /////
        named_type_reference ntr = _named_type_reference1;
        new_expr newexpr = new new_expr(ntr, el, false, null);
        parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
        return newexpr;
    }
	case (int)RuleConstants.RULE_MAIN_FUNC_TKMAINIDENT1_TKASSIGN :
	//<main_func> ::= 'tkMainIdent1' 'tkAssign' <body_func>
    {
			block _block=new block(null, null);
			
							 	statement_list sl=null;
                                if (LRParser.GetReductionSyntaxNode(2) is statement_list)
                                {
                                    sl = LRParser.GetReductionSyntaxNode(2) as statement_list;
                                    ///////////////////////
                                    ident_list il = new ident_list();
                                    il.idents.Add(new ident("result"));
                                    named_type_reference _named_type_reference1 = new named_type_reference();
                                    ident idtype1 = new ident("datatype");
                                    _named_type_reference1.source_context = idtype1.source_context;
                                    _named_type_reference1.names.Add(idtype1);

                                    var_def_statement _var_def_statement = new var_def_statement(il, (type_definition)_named_type_reference1, null, definition_attribute.None, false);
                                    parsertools.create_source_context(_var_def_statement, il, _named_type_reference1);
                                    var_statement _var_statement = new var_statement(_var_def_statement);
                                    parsertools.create_source_context(_var_statement, null, _var_def_statement);
                                    sl.subnodes.Insert(0,_var_statement);
                                    /////////////////////////
                                }
                                else
                                {
                                    sl = new statement_list();
                                    ///////////////////////
                                    ident_list il = new ident_list();
                                    il.idents.Add(new ident("result"));
                                    named_type_reference _named_type_reference1 = new named_type_reference();
                                    ident idtype1 = new ident("datatype");
                                    _named_type_reference1.source_context = idtype1.source_context;
                                    _named_type_reference1.names.Add(idtype1);

                                    var_def_statement _var_def_statement = new var_def_statement(il, (type_definition)_named_type_reference1, null, definition_attribute.None, false);
                                    parsertools.create_source_context(_var_def_statement, il, _named_type_reference1);
                                    var_statement _var_statement = new var_statement(_var_def_statement);
                                    parsertools.create_source_context(_var_statement, null, _var_def_statement);
                                    sl.subnodes.Add(_var_statement);
                                    /////////////////////////
                                    sl.subnodes.Add(LRParser.GetReductionSyntaxNode(2) as statement);
                                    if (!(LRParser.GetReductionSyntaxNode(2) is empty_statement))
                                        parsertools.assign_source_context(sl, LRParser.GetReductionSyntaxNode(2));
                                }
								_block.program_code=sl;
								
			return _block;
		}
								
	case (int)RuleConstants.RULE_BODY_FUNC :
	//<body_func> ::= <stmt>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_STMTS :
	//<stmts> ::= <stmt> <empty> <empty>
         
		{
			statement_list _statement_list=new statement_list();
			
							_statement_list.subnodes.Add((statement)LRParser.GetReductionSyntaxNode(0));
							parsertools.assign_source_context(_statement_list,LRParser.GetReductionSyntaxNode(0)); 
			return _statement_list;
		}

	case (int)RuleConstants.RULE_STMTS_TKSEMICOLON :
	//<stmts> ::= <stmts> 'tkSemiColon' <stmt>
         
		{
			statement_list _statement_list;
			 _statement_list=(statement_list)LRParser.GetReductionSyntaxNode(0);
							_statement_list.subnodes.Add((statement)LRParser.GetReductionSyntaxNode(2));
							parsertools.create_source_context(_statement_list,_statement_list,parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(2),LRParser.GetReductionSyntaxNode(1))); 
			return _statement_list;
		}
    case (int)RuleConstants.RULE_STMTS1:
        //<stmts1> ::= <stmt> <empty> <empty>
        {
            statement_list _statement_list = new statement_list();

            _statement_list.subnodes.Add((statement)LRParser.GetReductionSyntaxNode(0));
            parsertools.assign_source_context(_statement_list, LRParser.GetReductionSyntaxNode(0));
            return _statement_list;
        }
    case (int)RuleConstants.RULE_STMTS12:
        //<stmts1> ::= <stmts1> <stmt>
        {
            statement_list _statement_list;
            _statement_list = (statement_list)LRParser.GetReductionSyntaxNode(0);
            _statement_list.subnodes.Add((statement)LRParser.GetReductionSyntaxNode(1));
            parsertools.create_source_context(_statement_list, _statement_list, parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(1), 
                LRParser.GetReductionSyntaxNode(1)));
            return _statement_list;
        } 
	case (int)RuleConstants.RULE_EXPR_TKEQUAL :
	//<expr> ::= <expr> 'tkEqual' <add_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

    case (int)RuleConstants.RULE_EXPR_TKNOTEQUAL:
        //<expr> ::= <expr> 'tkNotEqual' <add_expr>
        {
            bin_expr _bin_expr = new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression, LRParser.GetReductionSyntaxNode(2) as expression, ((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
            parsertools.create_source_context(_bin_expr, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(2));

            return _bin_expr;
        }
	
	case (int)RuleConstants.RULE_EXPR_TKMORE :
	//<expr> ::= <expr> 'tkMore' <add_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_EXPR_TKLESS :
	//<expr> ::= <expr> 'tkLess' <add_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_EXPR_TKMOREEQ :
	//<expr> ::= <expr> 'tkMoreEq' <add_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_EXPR_TKLESSEQ :
	//<expr> ::= <expr> 'tkLessEq' <add_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_EXPR :
	//<expr> ::= <add_expr>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_LIST_TKSQUAREOPEN_TKSQUARECLOSE :
	//<list> ::= 'tkSquareOpen' <list_elements> 'tkSquareClose'
{
		ArrayList list_elements = (ArrayList)LRParser.GetReductionSyntaxNode(1);
    //////////////////////////////////////////////////////////proverka na type
        if (list_elements != null)
        {
            ArrayList types = new ArrayList();
            for (int i = 0; i < list_elements.Count; i++)
            {
                string tp = "";
                if (list_elements[i] is new_expr)
                {
                    tp = ((string_const)((new_expr)list_elements[i]).params_list.expressions[1]).Value;
                    if (!types.Contains(tp))
                        types.Add(tp);
                }
            }
            if ((types.Count == 2 && !(types.Contains("integer") && types.Contains("real"))) || types.Count > 2)
            {
                //errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "одинаковый тип элементов списка"));
                errors.Add(new PascalABCCompiler.Errors.Error("элементы списка имеют разный тип"));
                return null;
            }
        }
    //////////////////////////////////////////////////////////
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype_list");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            if (list_elements == null)
                list_elements = new ArrayList();
            int32_const n = new int32_const(list_elements.Count);
            el.expressions.Add(n);
            if (list_elements.Count > 0)
            {
                el.expressions.Add(new string_const("list"));
            }
            else
                el.expressions.Add(new string_const("empty"));
            for (int i = 0; i < list_elements.Count;i++ )
                el.expressions.Add(list_elements[i] as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
            return newexpr;
		}
	case (int)RuleConstants.RULE_LIST_TKSQUAREOPEN_TKDOT_TKDOT_TKSQUARECLOSE :
	//<list> ::= 'tkSquareOpen' <list_elements> 'tkDot' 'tkDot' <simple_expr> 'tkSquareClose'
{ArrayList list_elements = (ArrayList)LRParser.GetReductionSyntaxNode(1);
//////////////////////////////////////////////////////////proverka na type
ArrayList types = new ArrayList();
for (int i = 0; i < list_elements.Count; i++)
{
    if (list_elements[i] is new_expr)
    {
        string tp = ((string_const)((new_expr)list_elements[i]).params_list.expressions[1]).Value;
        if (!types.Contains(tp))
            types.Add(tp);
    }
}
if (LRParser.GetReductionSyntaxNode(4) is new_expr)
{
    new_expr ex_last = (new_expr)LRParser.GetReductionSyntaxNode(4);
    string tp_last = ((string_const)ex_last.params_list.expressions[1]).Value;
    if (!types.Contains(tp_last))
        types.Add(tp_last);
}
if ((types.Count == 2 && !(types.Contains("integer") && types.Contains("real"))) || types.Count > 2)
{
    //errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "одинаковый тип элементов списка"));
    errors.Add(new PascalABCCompiler.Errors.Error("элементы списка имеют разный тип"));
    return null;
}
if (list_elements.Count > 2)
{
    errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "."));
    return null;
}
//////////////////////////////////////////////////////////
    named_type_reference _named_type_reference1 = new named_type_reference();
		      ident idtype1 = new ident("datatype_list");
		      _named_type_reference1.source_context = idtype1.source_context;
		      _named_type_reference1.names.Add(idtype1);
			expression_list el = new expression_list();
            el.expressions.Add(list_elements[0] as expression);
            if (list_elements.Count>1)
                el.expressions.Add(list_elements[1] as expression);
            el.expressions.Add(LRParser.GetReductionSyntaxNode(4) as expression);
            el.expressions.Add(new string_const("list"));
	named_type_reference ntr = _named_type_reference1;
			new_expr newexpr = new new_expr(ntr, el, false, null);
			parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
			return newexpr;
											}
	case (int)RuleConstants.RULE_LIST_TKSQUAREOPEN_TKDOT_TKDOT_TKSQUARECLOSE2 :
	//<list> ::= 'tkSquareOpen' <list_elements> 'tkDot' 'tkDot' 'tkSquareClose'
{ArrayList list_elements = (ArrayList)LRParser.GetReductionSyntaxNode(1);
//////////////////////////////////////////////////////////proverka na type
ArrayList types = new ArrayList();
for (int i = 0; i < list_elements.Count; i++)
{
    if (list_elements[i] is new_expr) 
    {
        string tp = ((string_const)((new_expr)list_elements[i]).params_list.expressions[1]).Value;
        if (!types.Contains(tp))
            types.Add(tp);
    }
}
if (types.Count == 2 && !(types.Contains("integer") && types.Contains("real")))
{
    //errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "одинаковый тип элементов списка"));
    errors.Add(new PascalABCCompiler.Errors.Error("элементы списка имеют разный тип"));
    return null;
}
if (list_elements.Count > 2)
{
    errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "."));
    return null;
}
//////////////////////////////////////////////////////////
    named_type_reference _named_type_reference1 = new named_type_reference();
             ident idtype1 = new ident("datatype_list");
             _named_type_reference1.source_context = idtype1.source_context;
             _named_type_reference1.names.Add(idtype1);
             expression_list el = new expression_list();
             el.expressions.Add(list_elements[0] as expression);
             el.expressions.Add(list_elements[1] as expression);
             named_type_reference _named_type_reference11 = new named_type_reference();
             ident idtype11 = new ident("datatype");
             _named_type_reference11.names.Add(idtype11);
             expression_list ell = new expression_list();
             new_expr ee = list_elements[0] as new_expr;
             ell.expressions.Add(ee.params_list.expressions[0]);
             literal lt;
             string text = "nil";
             lt = new string_const(text);
             ell.expressions.Add(lt as expression);
             named_type_reference ntrr = _named_type_reference11; 
             new_expr newexprr = new new_expr(ntrr, ell, false, null);
             el.expressions.Add(newexprr);
             el.expressions.Add(new string_const("list"));
             named_type_reference ntr = _named_type_reference1;
             new_expr newexpr = new new_expr(ntr, el, false, null);
             parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
             return newexpr;}
    case (int)RuleConstants.RULE_LIST:
    //<list> ::= <list_constructor>
    return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_LIST_TKCOLON :
	//<list> ::= <simple_expr> 'tkColon' <empty> <simple_expr>
{expression_list el = new expression_list();
    el.expressions.Add(LRParser.GetReductionSyntaxNode(3) as expression);
    dot_node _dot_node = new dot_node(null, new ident("colon"));
    _dot_node.left = (addressed_value)LRParser.GetReductionSyntaxNode(0);
    method_call _method_call = new method_call(el);
    _method_call.dereferencing_value = (addressed_value)_dot_node;
    return _method_call;}
    case (int)RuleConstants.RULE_LIST_CONSTRUCTOR_TKSQUAREOPEN_TKSPLIT_TKSQUARECLOSE:
//<list_constructor> ::= 'tkSquareOpen' <simple_expr> 'tkSplit' <generators> <conditions_comma> 'tkSquareClose'
{
    ArrayList generators=(ArrayList)LRParser.GetReductionSyntaxNode(3);
    ArrayList conditions = (ArrayList)LRParser.GetReductionSyntaxNode(4);
    //////////////////////////////////////////////////////////////////////////
    statement_list body = new statement_list();
    rec_num = 0;
    for (int i = 0; i < generators.Count; i++)
    {
        ident id = null;
        if (((ArrayList)generators[i])[0] is new_expr)
        {
            constructor_rec_var(body, ((ArrayList)generators[i])[0] as new_expr);
        }
        else
        {
            id = (ident)((ArrayList)generators[i])[0];
            ident_list _ident_list1 = new ident_list();
            _ident_list1.idents.Add(id);
            string name_param2 = id.name;
            typed_parameters _typed_parametres2 = null;
            named_type_reference _named_type_reference3 = new named_type_reference();
            ident idtype3 = new ident("datatype");
            _named_type_reference3.names.Add(idtype3);
            var_def_statement _var_def_statement2 = new var_def_statement(_ident_list1, (type_definition)_named_type_reference3, null, definition_attribute.None, false);
            var_statement _var_statement2 = new var_statement(_var_def_statement2);
            body.subnodes.Add(_var_statement2);
        }
    }
    ///////////////////////////////////////////////////////////////////////result
    named_type_reference _named_type_reference2 = new named_type_reference();
    ident idtype2 = new ident("datatype_list");
    _named_type_reference2.names.Add(idtype2);
    expression_list el2 = new expression_list();
    int32_const n = new int32_const(0);
    el2.expressions.Add(n);
    el2.expressions.Add(new string_const("list"));
    named_type_reference ntr = _named_type_reference2;
    new_expr newexpr = new new_expr(ntr, el2, false, null);
    assign _result = new assign();
    _result.operator_type = Operators.Assignment;
    _result.to = new ident("result");
    _result.from = newexpr;
    body.subnodes.Add(_result);
    //////////////////////////////////////////////////////////////////////if
    if_node _if_node = new if_node();
    if (conditions != null)
    {
        expression b_e = (expression)conditions[conditions.Count - 1];
        for (int i = conditions.Count - 2; i >= 0; i--)
        {
            bin_expr b_e1 = new bin_expr();
            b_e1.operation_type = Operators.LogicalAND;
            b_e1.left = (expression)conditions[i];
            b_e1.right = b_e;
            b_e = b_e1;
        }
        _if_node.condition = _ob(b_e);
    }
    //////////////////////////////////////////////////////////////////////assign
    statement_list stmt_list=new statement_list();
    rec_num = 0;
    for (int i = 0; i < generators.Count; i++)
    {
        if (((ArrayList)generators[i])[0] is new_expr)
        {
            constructor_rec_ass(stmt_list, ((ArrayList)generators[i])[0] as new_expr, _index((expression)((ArrayList)generators[i])[1], new ident("$i" + i)));
        }
        else
        {
            assign _assign = new assign();
            _assign.operator_type = Operators.Assignment;
            _assign.to = (ident)((ArrayList)generators[i])[0];
            _assign.from = _index((expression)((ArrayList)generators[i])[1], new ident("$i" + i));
            stmt_list.subnodes.Add(_assign);
        }
    }
    if (conditions != null)
    {
        _if_node.then_body = _add(new ident("result"), (expression)LRParser.GetReductionSyntaxNode(1));
        stmt_list.subnodes.Add(_if_node);
    }
    else
        stmt_list.subnodes.Add(_add(new ident("result"), (expression)LRParser.GetReductionSyntaxNode(1)));
    //////////////////////////////////////////////////////////////////////for
    statement _for_stmt = stmt_list;
    for (int i = generators.Count - 1; i >= 0; i--)
    {
        for_node _for_node = new for_node();
        _for_node.cycle_type = for_cycle_type.to;
        _for_node.loop_variable = new ident("$i"+i);
        named_type_reference _named_type_reference = new named_type_reference();
        ident idtype = new ident("integer");
        _named_type_reference.names.Add(idtype);
        _for_node.type_name = (type_definition)_named_type_reference;
        _for_node.initial_value = new int32_const(0);
        _for_node.finish_value = _count((expression)((ArrayList)generators[i])[1]);
        _for_node.increment_value = new int32_const(1);
        _for_node.statements = _for_stmt;
        _for_stmt = _for_node;
    }
    body.subnodes.Add(_for_stmt);
    ///////////////////////////////////////////////////////////////////////////////////////////////////////lambda
    formal_parameters _formal_parametres = null;
    //////////////////////////
    named_type_reference _named_type_reference1 = new named_type_reference();
    ident idtype1 = new ident("datatype");
    _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_parametres;
    _procedure_definition.return_type = (type_definition)_named_type_reference1;
    _procedure_definition.ident_list = null;
    _procedure_definition.proc_body = null;
    _procedure_definition.parameters = null;
    _procedure_definition.lambda_name = "__lambda__" + lambda_num;
    //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, null, null, null, "lambda" + lambda_num);
    _procedure_definition.proc_body = body;
    procedure_definition pr = lambda(_procedure_definition);
    //_function_lambda_definitions.Add(_procedure_definition);////////////////
    let_funcs.Add(pr);
    let_where_funcs.Add(pr);
    if (let_flag.Count > 0)
        let_func_last.Add(pr);
    expression_list el = new expression_list();
    let_fact_params.Clear();
    return new ident(_procedure_definition.lambda_name);
}
    case (int)RuleConstants.RULE_GENERATORS:
        //<generators> ::= <generator> <empty>
        {
            ArrayList ar = new ArrayList();
            ar.Add(LRParser.GetReductionSyntaxNode(0));
            return ar;
        }
    case (int)RuleConstants.RULE_GENERATORS_TKCOMMA:
        //<generators> ::= <generators> 'tkComma' <generator>
        {
            ArrayList ar = (ArrayList)LRParser.GetReductionSyntaxNode(0);
            ar.Add(LRParser.GetReductionSyntaxNode(2));
            return ar;
        }
    case (int)RuleConstants.RULE_GENERATOR_TKARROWGEN:
        //<generator> ::= <simple_expr> 'tkArrowGen' <simple_expr>
        {
            ArrayList ar = new ArrayList();
            ar.Add(LRParser.GetReductionSyntaxNode(0));
            ar.Add(LRParser.GetReductionSyntaxNode(2));
            return ar;
        }
    case (int)RuleConstants.RULE_CONDITIONS_COMMA:
        //<conditions_comma> ::= <empty>
        {
            return null;
        }
    case (int)RuleConstants.RULE_CONDITIONS_COMMA_TKCOMMA:
        //<conditions_comma> ::= 'tkComma' <conditions>
        {
            return LRParser.GetReductionSyntaxNode(1);
        }
    case (int)RuleConstants.RULE_CONDITIONS:
        //<conditions> ::= <condition> <empty>
        {
            ArrayList ar = new ArrayList();
            ar.Add(LRParser.GetReductionSyntaxNode(0));
            return ar;
        }
    case (int)RuleConstants.RULE_CONDITIONS_TKCOMMA:
        //<conditions> ::= <conditions> 'tkComma' <condition>
        {
            ArrayList ar = (ArrayList)LRParser.GetReductionSyntaxNode(0);
            ar.Add(LRParser.GetReductionSyntaxNode(2));
            return ar;
        }
    case (int)RuleConstants.RULE_CONDITION:
        //<condition> ::= <expr>
        return LRParser.GetReductionSyntaxNode(0);
    case (int)RuleConstants.RULE_CORTEG_TKROUNDOPEN_TKCOMMA_TKROUNDCLOSE:
//<corteg> ::= 'tkRoundOpen' <simple_expr> 'tkComma' <list_elements> 'tkRoundClose'
        {
            //new_expr first_el = (new_expr)LRParser.GetReductionSyntaxNode(1);
            ArrayList list_elements = (ArrayList)LRParser.GetReductionSyntaxNode(3);
            list_elements.Insert(0, LRParser.GetReductionSyntaxNode(1));
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype_list");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            if (list_elements == null)
                list_elements = new ArrayList();
            int32_const n = new int32_const(list_elements.Count);
            el.expressions.Add(n);
            if (list_elements.Count > 0)
            {
                el.expressions.Add(new string_const("corteg"));
            }
            else
                el.expressions.Add(new string_const("empty"));
            for (int i = 0; i < list_elements.Count; i++)
                el.expressions.Add(list_elements[i] as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
            return newexpr;
        }
	case (int)RuleConstants.RULE_LIST_ELEMENTS :
	//<list_elements> ::= <empty>
return null;
	case (int)RuleConstants.RULE_LIST_ELEMENTS2 :
	//<list_elements> ::= <simple_expr> <empty>
{
                 ArrayList list_elements = new ArrayList();
                 list_elements.Add(LRParser.GetReductionSyntaxNode(0));
                 return list_elements;
             }
	case (int)RuleConstants.RULE_LIST_ELEMENTS_TKCOMMA :
	//<list_elements> ::= <list_elements> 'tkComma' <simple_expr>
{
                 ((ArrayList)LRParser.GetReductionSyntaxNode(0)).Add(LRParser.GetReductionSyntaxNode(2));
                 return LRParser.GetReductionSyntaxNode(0);
             }
	case (int)RuleConstants.RULE_ADD_EXPR_TKAND :
	//<add_expr> ::= <add_expr> 'tkAnd' <mult_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_ADD_EXPR :
	//<add_expr> ::= <add_expr> <addop> <mult_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_ADD_EXPR2 :
	//<add_expr> ::= <mult_expr>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_MULT_EXPR_TKOR :
	//<mult_expr> ::= <mult_expr> 'tkOr' <negate_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_MULT_EXPR :
	//<mult_expr> ::= <mult_expr> <multop> <negate_expr>
         
		{
			bin_expr _bin_expr=new bin_expr(LRParser.GetReductionSyntaxNode(0) as expression,LRParser.GetReductionSyntaxNode(2) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(1)).type);
			parsertools.create_source_context(_bin_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(2));
			
			return _bin_expr;
		}

	case (int)RuleConstants.RULE_MULT_EXPR2 :
	//<mult_expr> ::= <negate_expr>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_NEGATE_EXPR_TKMINUS :
	//<negate_expr> ::= 'tkMinus' <simple_expr>
         
		{
			un_expr _un_expr=new un_expr(LRParser.GetReductionSyntaxNode(1) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(0)).type);
			parsertools.create_source_context(_un_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(1));
			
			return _un_expr;
		}

	case (int)RuleConstants.RULE_NEGATE_EXPR_TKNOT :
	//<negate_expr> ::= 'tkNot' <simple_expr>
         
		{
			un_expr _un_expr=new un_expr(LRParser.GetReductionSyntaxNode(1) as expression,((op_type_node)LRParser.GetReductionSyntaxNode(0)).type);
			parsertools.create_source_context(_un_expr,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(1));
			
			return _un_expr;
		}

	case (int)RuleConstants.RULE_NEGATE_EXPR :
	//<negate_expr> ::= <simple_expr>
return LRParser.GetReductionSyntaxNode(0);
    case (int)RuleConstants.RULE_SIMPLE_EXPR:
//<simple_expr> ::= <simple_type_expr>
return LRParser.GetReductionSyntaxNode(0);
    case (int)RuleConstants.RULE_SIMPLE_TYPE_EXPR_TKINT:
//<simple_type_expr> ::= 'tkInt'

{
            named_type_reference _named_type_reference1 = new named_type_reference();

            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);

            /////
            expression_list el = new expression_list();
            el.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
            literal lt;
            string text = "integer";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            /////
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false,null);
            parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
            return newexpr;
        }
    case (int)RuleConstants.RULE_SIMPLE_TYPE_EXPR_TKDOUBLE:
//<simple_type_expr> ::= 'tkDouble'
{
            named_type_reference _named_type_reference1 = new named_type_reference();

            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);

            /////
            expression_list el = new expression_list();
            el.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
            literal lt;
            string text = "real";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            /////
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false,null);
            parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
            return newexpr;
        }
    case (int)RuleConstants.RULE_SIMPLE_TYPE_EXPR_TKBOOL:
//<simple_type_expr> ::= 'tkBool'
{
            named_type_reference _named_type_reference1 = new named_type_reference();

            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);

            /////
            expression_list el = new expression_list();
            el.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
            literal lt;
            string text = "boolean";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            /////
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false,null);
            parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
            return newexpr;
        }
    case (int)RuleConstants.RULE_SIMPLE_TYPE_EXPR_TKCHAR:
//<simple_type_expr> ::= 'tkChar'
{
            named_type_reference _named_type_reference1 = new named_type_reference();

            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);

            /////
            expression_list el = new expression_list();
            el.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
            literal lt;
            string text = "char";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            /////
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false,null);
            parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
            return newexpr;
        }
    case (int)RuleConstants.RULE_SIMPLE_TYPE_EXPR_TKSTRING:
//<simple_type_expr> ::= 'tkString'
{
            named_type_reference _named_type_reference1 = new named_type_reference();

            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);

            /////
            expression_list el = new expression_list();
            el.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
            literal lt;
            string text = "string";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            /////
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false,null);
            parsertools.create_source_context(newexpr, new ident("new"), parsertools.sc_not_null(el, _named_type_reference1));
            return newexpr;
        }
	case (int)RuleConstants.RULE_SIMPLE_EXPR_TKROUNDOPEN_TKROUNDCLOSE :
	//<simple_expr> ::= 'tkRoundOpen' <expr> 'tkRoundClose'
return LRParser.GetReductionSyntaxNode(1);
    case (int)RuleConstants.RULE_SIMPLE_EXPR2:
//<simple_expr> ::= <infix_expr> <empty>
{
    if (LRParser.GetReductionSyntaxNode(0) is ArrayList)
    {
        ////////////////////////////////////////////////////////ident_params
        ArrayList arr = (ArrayList)LRParser.GetReductionSyntaxNode(0);
        ident _ident = (ident)arr[0];
        expression_list el = new expression_list();
        for (int ii = 1; ii < arr.Count; ii++)
            el.expressions.Add((expression)arr[ii]);
        ////////////////////////////////////////////////////////
        //expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
        ////////////////////////////for curring
        int n = el.expressions.Count;
        int fld_params_count = find_count_params(_ident.name);
        ////////////////////////////
        if (fld_params_count - n > 0)
        {
            expression_list _expression_list = el;
            expression_list _params = new expression_list();
            expression_list _params_el = new expression_list();
            for (int i = 0; i < list_params1.Count; i++)
                if (list_params1[i] is ident)
                {
                    _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                    _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
                }
            for (int i = 1; i <= fld_params_count - n; i++)
                _expression_list.expressions.Add(new ident("$$" + i));
            for (int i = 1; i <= fld_params_count - n; i++)
            {
                _params.expressions.Add(new ident("$$" + i));
                _params_el.expressions.Add(new ident("$$" + i));
            }
            method_call _method_call = new method_call(_expression_list);
            if (_method_call is dereference)
                ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;

            op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

            statement_list _statement_list = new statement_list();
            _statement_list.subnodes.Add(_assign);
            ////////////////////////////
            ident_list i_l = new ident_list();
            for (int i = 1; i <= fld_params_count - n; i++)
                i_l.idents.Add(new ident("$$" + i));
            /////////////////////////////
            formal_parameters _formal_parametres = new formal_parameters();
            for (int i = 0; i < _params.expressions.Count; i++)
            {
                ident_list _ident_list = new ident_list();
                ident id = (ident)_params.expressions[i];
                _ident_list.idents.Add(id);
                named_type_reference _named_type_reference = new named_type_reference();

                ident idtype = new ident("datatype");
                _named_type_reference.names.Add(idtype);

                typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
                parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

                _formal_parametres.params_list.Add(_typed_parametres);
            }
            //////////////////////////
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _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_parametres;
            _procedure_definition.return_type = (type_definition)_named_type_reference1;
            _procedure_definition.ident_list = i_l;
            _procedure_definition.proc_body = null;
            _procedure_definition.parameters = _params_el;
            _procedure_definition.lambda_name = "__lambda__" + lambda_num;
            //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
            object rt = _expression_list;
            _procedure_definition.proc_body = _statement_list;
            _function_lambda_definitions_after.Add(_procedure_definition);
            _function_lambda_definitions_after.Add(_ident.name);////////////////
            last_function_lambda_definitions.Add(_procedure_definition);
            return new ident(_procedure_definition.lambda_name);
        }
        else
        {
            method_call _method_call = new method_call(el);

            if (_method_call is dereference)
            {
                ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;
                parsertools.create_source_context(_method_call, _ident, _method_call);
            }
            list_method_calls.Add(_method_call);
            last_list_method_calls.Add(_method_call);
            last_list_method_calls_lambda.Add(_method_call);
            return _method_call;

        }
    }
    else
        return LRParser.GetReductionSyntaxNode(0);
}
	case (int)RuleConstants.RULE_SIMPLE_EXPR3 :
	//<simple_expr> ::= <variable>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_SIMPLE_EXPR_TKLET_TKIN :
	//<simple_expr> ::= 'tkLet' <def_vars> 'tkIn' <body_func>
{//////////////////////////
    expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(1);
    statement_list _statement_list = (statement_list)LRParser.GetReductionSyntaxNode(3);
    //////////////////////////
    formal_parameters _formal_parametres = null;
    //////////////////////////
    named_type_reference _named_type_reference1 = new named_type_reference();
    ident idtype1 = new ident("datatype");
    _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_parametres;
    _procedure_definition.return_type = (type_definition)_named_type_reference1;
    _procedure_definition.ident_list = null;
    _procedure_definition.proc_body = null;
    _procedure_definition.parameters = _expression_list;
    _procedure_definition.lambda_name = "__lambda__" + lambda_num;
    //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, null, null, _expression_list, "lambda" + lambda_num);
    object rt = _expression_list;
    _procedure_definition.proc_body = _statement_list;
    parsertools.create_source_context(_procedure_definition, _expression_list, rt);
    procedure_definition pr = lambda(_procedure_definition);
    //_function_lambda_definitions.Add(_procedure_definition);////////////////
    ((block)pr.proc_body).defs = new declarations();
    int start=0;
    int k = let_funcs.Count-1;
    while (k>0 && ((procedure_definition)let_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
        k--;
    int kk = 0;
    while (k > 0 && kk < _expression_list.expressions.Count-1 && !((procedure_definition)let_funcs[k]).proc_header.name.meth_name.name.Contains("__lambda__"))
    {
        k--;
        kk++;
    }
    start = k;
    int i = start;
    int n = let_funcs.Count;
    while (i < n)
    {
        if (let_where_funcs.Count > 0)
            if (start - (let_funcs.Count - let_where_funcs.Count) >= 0)
                let_where_funcs.RemoveAt(start - (let_funcs.Count - let_where_funcs.Count));
            else
                let_where_funcs.RemoveAt(let_where_funcs.Count - 1);
        ((block)pr.proc_body).defs.defs.Add((procedure_definition)let_funcs[start]);
        let_funcs.RemoveAt(start);
        i++;
    }
    ///////////////////////////lambda
    if (((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count > 0)
    {
        if (((block)pr.proc_body).defs==null)
            ((block)pr.proc_body).defs = new declarations();
        for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
            ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[ii]);
        for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
            _function_lambda_definitions.RemoveAt(_function_lambda_definitions.Count-1);
    }
    lambda_stack.RemoveAt(lambda_stack.Count - 1);
    //lambda_stack.RemoveAt(lambda_stack.Count - 1);
    /*if (((block)pr.proc_body).defs == null)
        ((block)pr.proc_body).defs = new declarations();
    for (int ii = 0; ii < _function_lambda_definitions.Count; ii++)
        ((block)pr.proc_body).defs.defs.Add(lambda((function_lambda_definition)_function_lambda_definitions[ii]));
    _function_lambda_definitions.Clear();*/
    ///////////////////////////
    let_funcs.Add(pr);
    let_where_funcs.Add(pr);
    if (let_flag.Count>0)
        let_func_last.Add(pr);
    expression_list el = new expression_list();
    let_fact_params.Clear();
    /////////////////////
    if (let_stack.Count > 0)
        ((ArrayList)let_stack[let_stack.Count - 1]).Add(pr);
    /*else
    {
        let_funcs.Add(pr);
        let_where_funcs.Add(pr);
    }*/
    /////////////////////
    return new ident(_procedure_definition.lambda_name);
}
	case (int)RuleConstants.RULE_SIMPLE_EXPR4 :
	//<simple_expr> ::= <list>
return LRParser.GetReductionSyntaxNode(0);
    case (int)RuleConstants.RULE_SIMPLE_EXPR5:
    //<simple_expr> ::= <corteg>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_SIMPLE_EXPR6 :
	//<simple_expr> ::= <lambda_func> <empty>
return LRParser.GetReductionSyntaxNode(0);
	//case (int)RuleConstants.RULE_SIMPLE_EXPR_TKROUNDOPEN_TKROUNDCLOSE_TKROUNDOPEN_TKROUNDCLOSE :
	//<simple_expr> ::= 'tkRoundOpen' <lambda_func> 'tkRoundClose' 'tkRoundOpen' <params_value> 'tkRoundClose'
    case (int)RuleConstants.RULE_SIMPLE_EXPR_TKROUNDOPEN_TKROUNDOPEN_TKROUNDCLOSE_TKROUNDCLOSE:
//<simple_expr> ::= 'tkRoundOpen' 'tkRoundOpen' <lambda_func> 'tkRoundClose' <params_value> 'tkRoundClose'
{
            function_lambda_definition fld = find_func_lambda_name(((ident)LRParser.GetReductionSyntaxNode(2)).name);
            //function_lambda_definition fld = find_lambda_funcs(((ident)LRParser.GetReductionSyntaxNode(1)).name);
            //lambda_funcs.RemoveAt(lambda_funcs.Count-1);
            expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(4);
            function_lambda_definition _lambda_definition = fld;
            function_lambda_call _lambda_call = new function_lambda_call(_lambda_definition, _expression_list);
            return _lambda_call;
        }
	/*case (int)RuleConstants.RULE_SIMPLE_EXPR_TKROUNDOPEN_TKROUNDCLOSE2 :
	//<simple_expr> ::= <simple_expr> 'tkRoundOpen' <params_value> 'tkRoundClose'
{
		if (LRParser.GetReductionSyntaxNode(0) is function_lambda_call)
            {
                expression_list _expression_list = new expression_list();
                expression_list el_new = (expression_list)LRParser.GetReductionSyntaxNode(2);
                function_lambda_call _lambda_definition_call = (function_lambda_call)LRParser.GetReductionSyntaxNode(0);
                function_lambda_definition fld = _lambda_definition_call.f_lambda_def;
                for (int i = 0; i < _lambda_definition_call.parameters.expressions.Count; i++)
                    _expression_list.expressions.Add(_lambda_definition_call.parameters.expressions[i]);
                for (int i = 0; i < el_new.expressions.Count; i++)
                    _expression_list.expressions.Add(el_new.expressions[i]);
                function_lambda_call _lambda_call = new function_lambda_call(fld, _expression_list);
                return _lambda_call;
            }
            else
                return null;}*/
	case (int)RuleConstants.RULE_VARIABLE_EXPR :
	//<variable_expr> ::= <simple_expr>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_DEF_VARS :
	//<def_vars> ::= <def_var> <empty>
{
            expression_list el=new expression_list();
            el.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
            return el;
        }
	case (int)RuleConstants.RULE_DEF_VARS_TKSEMICOLON :
	//<def_vars> ::= <def_vars> 'tkSemiColon' <def_var>
{
            expression_list el=(expression_list)LRParser.GetReductionSyntaxNode(0);
            el.expressions.Add(LRParser.GetReductionSyntaxNode(2) as expression);
            return el;

        }
    case (int)RuleConstants.RULE_DEF_VAR_TKIDENT:
//<def_var> ::= 'tkIdent' <params> <guard_body_list> <where_var>
{
    expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(1);
    /*statement_list _statement_list = (statement_list)LRParser.GetReductionSyntaxNode(4);*/
    statement_list _statement_list = new statement_list();
    ArrayList ar_main = (ArrayList)LRParser.GetReductionSyntaxNode(2);
    ////////////////////////////for list
    statement_list stmt_l = new statement_list();
    int start = let_where_list_params.Count;
    if (_expression_list != null)
        start = let_where_list_params.Count - _expression_list.expressions.Count;
    int i_ex = 0;
    for (int ll = start; ll < let_where_list_params.Count; ll++)
    {
        for (int l = 0; l < ((ArrayList)let_where_list_params[ll]).Count; l++)
        {
            ident_list il1 = new ident_list();
            il1.idents.Add(new ident(((ident)((ArrayList)let_where_list_params[ll])[l]).name));
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.names.Add(idtype1);

            var_def_statement _var_def_statement = new var_def_statement(il1, (type_definition)_named_type_reference1, null, definition_attribute.None, false);
            var_statement _var_statement = new var_statement(_var_def_statement);
            stmt_l.subnodes.Add(_var_statement);
        }
        if (((ArrayList)let_where_list_params[ll]).Count > 0)
        {
            op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            dot_node _dot_node = new dot_node(null, (addressed_value)(new ident("head")));
            ident id = _expression_list.expressions[i_ex] as ident;
            /*for (int i1 = 0; i1 < ((ArrayList)let_where_list_params[ll]).Count; i1++)
                id.name += ((ident)((ArrayList)let_where_list_params[ll])[i1]).name;*/
            if (id.name != null)
            {
                _dot_node.left = (addressed_value)(id);
                object o = null;
                method_call _method_call = new method_call(o as expression_list);
                if (_method_call is dereference)
                    ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                assign _assign1 = new assign(((ident)((ArrayList)let_where_list_params[ll])[((ArrayList)let_where_list_params[ll]).Count - 1]) as addressed_value, _method_call as expression, _op_type_node.type);
                stmt_l.subnodes.Add(_assign1);

                ///
                for (int i1 = ((ArrayList)let_where_list_params[ll]).Count - 2; i1 > 0; i1--)
                {
                    _dot_node = new dot_node((addressed_value)id, (addressed_value)(new ident("tail")));
                    for (int j1 = 0; j1 < ((ArrayList)let_where_list_params[ll]).Count - 2 - i1; j1++)
                    {
                        _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("tail")));
                    }
                    _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("head")));

                    _method_call = new method_call(o as expression_list);
                    if (_method_call is dereference)
                        ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                    _assign1 = new assign(((ident)((ArrayList)let_where_list_params[ll])[i1]) as addressed_value, _method_call as expression, _op_type_node.type);
                    stmt_l.subnodes.Add(_assign1);
                }

                _dot_node = new dot_node((addressed_value)id, (addressed_value)(new ident("tail")));

                for (int j1 = 0; j1 < ((ArrayList)let_where_list_params[ll]).Count - 2; j1++)
                {
                    _dot_node = new dot_node(_dot_node, (addressed_value)(new ident("tail")));
                }
                _method_call = new method_call(o as expression_list);
                if (_method_call is dereference)
                    ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
                _assign1 = new assign(((ident)((ArrayList)let_where_list_params[ll])[0]) as addressed_value, _method_call as expression, _op_type_node.type);
                stmt_l.subnodes.Add(_assign1);
            }
        }
        i_ex++;
    }
    for (int ll = 0; ll < let_where_list_params.Count - start; ll++)
        list_params_temp.RemoveAt(list_params_temp.Count - 1);
    for (int i = stmt_l.subnodes.Count - 1; i >= 0; i--)
        _statement_list.subnodes.Insert(0, stmt_l.subnodes[i]);
    if (_expression_list != null)
        for (int i = 0; i < _expression_list.expressions.Count; i++)
            let_where_list_params.RemoveAt(let_where_list_params.Count - 1);
    ////////////////////////////
    formal_parameters _formal_parametres = null;
    ident_list i_l = new ident_list();
    if (_expression_list != null)
    {
        for (int i = 0; i < _expression_list.expressions.Count; i++)
            i_l.idents.Add((ident)_expression_list.expressions[i]);
        /////////////////////////////
        _formal_parametres = new formal_parameters();
        for (int i = 0; i < i_l.idents.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_expression_list.expressions[i];
            _ident_list.idents.Add(id);
            string name_param = id.name;
            typed_parameters _typed_parametres = null;
            int k = 0;
            while (k < last_list_method_calls_lambda.Count && ((ident)((method_call)last_list_method_calls_lambda[k]).dereferencing_value).name != name_param)
                k++;
            if (k < last_list_method_calls_lambda.Count)
                _typed_parametres = new typed_parameters(_ident_list, func_type(((method_call)last_list_method_calls_lambda[k]).parameters.expressions.Count), parametr_kind.none, null);
            else
            {
                named_type_reference _named_type_reference = new named_type_reference();

                ident idtype = new ident("datatype");
                _named_type_reference.names.Add(idtype);

                _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
                parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);
            }
            _formal_parametres.params_list.Add(_typed_parametres);
        }
    }
    //////////////////////////
    named_type_reference _n_t_r = new named_type_reference();
    ident it = new ident("datatype");
    _n_t_r.names.Add(it);
    /////////////////////////////
    //lambda_num++;
    function_lambda_definition _procedure_definition = new function_lambda_definition();
    _procedure_definition.formal_parameters = _formal_parametres;
    _procedure_definition.return_type = (type_definition)_n_t_r;
    _procedure_definition.ident_list = i_l;
    _procedure_definition.proc_body = null;
    _procedure_definition.parameters = _expression_list;
    _procedure_definition.lambda_name = ((ident)LRParser.GetReductionSyntaxNode(0)).name;
    //new function_lambda_definition(_formal_parametres, (type_definition)_n_t_r, i_l, null, _expression_list, ((ident)LRParser.GetReductionSyntaxNode(0)).name);
    object rt = _expression_list;
    ////////////////////////////////////////////////for guard
    for (int i = 0; i < ar_main.Count;i++ )
        if (((ArrayList)ar_main[i])[0] != null)
        {
            if_node _if_node = new if_node();
            _if_node.condition = _ob((expression)((ArrayList)ar_main[i])[0]);
            _if_node.then_body = new statement_list();
            _if_node.then_body = (statement)((ArrayList)ar_main[i])[1];
            procedure_call _exit = new procedure_call(new ident("exit") as addressed_value);
            ((statement_list)_if_node.then_body).subnodes.Add(_exit);
            _statement_list.subnodes.Add(_if_node);
        }
        else
        {
            _statement_list.subnodes.Add((statement)((ArrayList)ar_main[i])[1]);
            procedure_call _exit = new procedure_call(new ident("exit") as addressed_value);
            _statement_list.subnodes.Add(_exit);
        }
    ////////////////////////////////////////////////
    _procedure_definition.proc_body = _statement_list;
    parsertools.create_source_context(_procedure_definition, _expression_list, rt);
    procedure_definition pr = lambda(_procedure_definition);
    ///////////////////////////
    /*if (let_func_last.Count > 0)
    {
        ((block)pr.proc_body).defs = new declarations();
        for (int i = 0; i < let_func_last.Count; i++)
            ((block)pr.proc_body).defs.defs.Add((procedure_definition)let_func_last[i]);
        for (int i = 0; i < let_func_last.Count; i++)
            if (let_where_funcs.Count > 0)
                let_where_funcs.RemoveAt(let_where_funcs.Count - 1);
        for (int i = 0; i < let_func_last.Count; i++)
            let_funcs.RemoveAt(let_funcs.Count - 1);
        let_func_last.Clear();
        let_flag.RemoveAt(let_flag.Count - 1);
    }
    else
        if ((let_flag.Count > 0 && _expression_list != null) || let_funcs.Count == 0)
            let_flag.Clear();*/
    if (((ArrayList)let_stack[let_stack.Count - 1]).Count > 0)
    {
        ((block)pr.proc_body).defs = new declarations();
        for (int i = 0; i < ((ArrayList)let_stack[let_stack.Count - 1]).Count; i++)
            ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)let_stack[let_stack.Count - 1])[i]);
        for (int i = 0; i < ((ArrayList)let_stack[let_stack.Count - 1]).Count; i++)
            if (let_where_funcs.Count > 0)
                let_where_funcs.RemoveAt(let_where_funcs.Count - 1);
        for (int i = 0; i < ((ArrayList)let_stack[let_stack.Count - 1]).Count; i++)
            if (let_funcs.Count > 0)
                let_funcs.RemoveAt(let_funcs.Count - 1);
        let_func_last.Clear();
        if (let_flag.Count>0)
            let_flag.RemoveAt(let_flag.Count - 1);
    }
    let_stack.RemoveAt(let_stack.Count - 1);
    ///////////////////////////////////////////////////////////////////
    if (LRParser.GetReductionSyntaxNode(3) != null)
    {
        if (((block)pr.proc_body).defs == null)
            ((block)pr.proc_body).defs = new declarations();
        for (int j = 0; j < ((ArrayList)LRParser.GetReductionSyntaxNode(3)).Count; j++)
            ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)LRParser.GetReductionSyntaxNode(3))[j]);
        ArrayList ar = ((ArrayList)let_where_funcs_main[let_where_funcs_main.Count - 1]).Clone() as ArrayList;
        for (int j = 0; j < ar.Count; j++)
            last_where_funcs.Add(ar[j]);
        let_where_funcs_main.RemoveAt(let_where_funcs_main.Count - 1);
    }
    ///////////////////////////lambda
    if (((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count > 0)
    {
        if (((block)pr.proc_body).defs == null)
            ((block)pr.proc_body).defs = new declarations();
        for (int i = 0; i < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; i++)
            ((block)pr.proc_body).defs.defs.Add((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[i]);
        for (int ii = 0; ii < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; ii++)
            _function_lambda_definitions.RemoveAt(_function_lambda_definitions.Count - 1);
    }
    lambda_stack.RemoveAt(lambda_stack.Count - 1);
    ///////////////////////////
    let_funcs.Add(pr);
    let_where_funcs.Add(pr);
    //let_funcs1.Add(_procedure_definition);
    //_function_lambda_definitions.Add(_procedure_definition);////////////////
    let_fact_params.Add(_procedure_definition.lambda_name);
    return new ident(((ident)LRParser.GetReductionSyntaxNode(0)).name);
}
    case (int)RuleConstants.RULE_GUARD_BODY_LIST:
    //<guard_body_list> ::= <guard_body> <empty>
    {
        ArrayList ar = (ArrayList)LRParser.GetReductionSyntaxNode(0);
        ArrayList ar_main = new ArrayList();
        ar_main.Add(ar);
        return ar_main;
    }
    case (int)RuleConstants.RULE_GUARD_BODY_LIST2:
    //<guard_body_list> ::= <guard_body_list> <guard_body>
    {
        ArrayList ar_main = (ArrayList)LRParser.GetReductionSyntaxNode(0);
        ar_main.Add(LRParser.GetReductionSyntaxNode(1));
        return ar_main;
    }
    case (int)RuleConstants.RULE_GUARD_BODY_TKASSIGN:
    //<guard_body> ::= <guard> 'tkAssign' <body_func>
    {
        ArrayList ar = new ArrayList();
        ar.Add(LRParser.GetReductionSyntaxNode(0));
        ar.Add(LRParser.GetReductionSyntaxNode(2));
        return ar;
    }
    case (int)RuleConstants.RULE_VARIABLE_TKIDENT:
//<variable> ::= 'tkIdent'
{
    if (token_where==1)
        token_where = 2;
    if (((ident)LRParser.GetReductionSyntaxNode(0)).name=="pi")
    {
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _named_type_reference1.names.Add(idtype1);
        expression_list ell = new expression_list();
        ell.expressions.Add(LRParser.GetReductionSyntaxNode(0) as expression);
        ell.expressions.Add(new string_const("real") as expression);
        named_type_reference ntr = _named_type_reference1;
        new_expr newexpr = new new_expr(ntr, ell, false, null);
        return newexpr;
    }
    else
        return LRParser.GetReductionSyntaxNode(0);
}
    case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKIDENT_TKROUNDCLOSE:
//<variable> ::= 'tkRoundOpen' 'tkIdent' <params_value> 'tkRoundClose'
{
    expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
    ////////////////////////////for curring
    int n = el.expressions.Count;
    int fld_params_count = find_count_params(((ident)LRParser.GetReductionSyntaxNode(1)).name);
    ////////////////////////////
    if (fld_params_count - n > 0)
    {
        expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(2);
        expression_list _params = new expression_list();
        expression_list _params_el = new expression_list();
        for (int i = 0; i < list_params1.Count; i++)
            if (list_params1[i] is ident)
            {
                _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
            }
        for (int i = 1; i <= fld_params_count - n; i++)
            _expression_list.expressions.Add(new ident("$$" + i));
        for (int i = 1; i <= fld_params_count - n; i++)
        {
            _params.expressions.Add(new ident("$$" + i));
            _params_el.expressions.Add(new ident("$$" + i));
        }
        method_call _method_call = new method_call(_expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(1);

        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

        statement_list _statement_list = new statement_list();
        _statement_list.subnodes.Add(_assign);
        ////////////////////////////
        ident_list i_l = new ident_list();
        for (int i = 1; i <= fld_params_count - n; i++)
            i_l.idents.Add(new ident("$$" + i));
        /////////////////////////////
        formal_parameters _formal_parametres = new formal_parameters();
        for (int i = 0; i < _params.expressions.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_params.expressions[i];
            _ident_list.idents.Add(id);
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

            _formal_parametres.params_list.Add(_typed_parametres);
        }
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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_parametres;
        _procedure_definition.return_type = (type_definition)_named_type_reference1;
        _procedure_definition.ident_list = i_l;
        _procedure_definition.proc_body = null;
        _procedure_definition.parameters = _params_el;
        _procedure_definition.lambda_name = "__lambda__" + lambda_num;
        //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
        object rt = _expression_list;
        _procedure_definition.proc_body = _statement_list;
        _function_lambda_definitions_after.Add(_procedure_definition);
        _function_lambda_definitions_after.Add(((ident)LRParser.GetReductionSyntaxNode(1)).name);////////////////
        last_function_lambda_definitions.Add(_procedure_definition);
        return new ident(_procedure_definition.lambda_name);
    }
    else
    {
        method_call _method_call = null;
        string name = ((ident)LRParser.GetReductionSyntaxNode(1)).name;
        if (name == "cos" || name == "sin" || name == "tan")
        {
            bin_expr b_e = new bin_expr();
            b_e.operation_type = Operators.Plus;
            b_e.left = el.expressions[0];
            named_type_reference _named_type_reference2 = new named_type_reference();
            ident idtype2 = new ident("datatype");
            _named_type_reference2.names.Add(idtype2);
            expression_list ell2 = new expression_list();
            ell2.expressions.Add(new double_const(0.0));
            ell2.expressions.Add(new string_const("real") as expression);
            named_type_reference ntr2 = _named_type_reference2;
            b_e.right = new new_expr(ntr2, ell2, false, null);
            //////////////////////////////////
            dot_node d_n = new dot_node();
            d_n.left = (addressed_value)b_e;
            d_n.right = new ident("ob");
            expression_list el1 = new expression_list();
            el1.expressions.Add(d_n);
            method_call m_c = new method_call(el1);
            m_c.dereferencing_value = new ident("real");
            ///////////////////////////////////
            expression_list el2 = new expression_list();
            el2.expressions.Add(m_c);
            _method_call = new method_call(el2);
            _method_call.dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(1);
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.names.Add(idtype1);
            expression_list ell = new expression_list();
            ell.expressions.Add(_method_call as expression);
            ell.expressions.Add(new string_const("real") as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, ell, false, null);
            return newexpr;
        }
        else
        {
            _method_call = new method_call(el);
            
            if (_method_call is dereference)
            {
                ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(1);
                parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(1), _method_call);
            }
            list_method_calls.Add(_method_call);
            last_list_method_calls.Add(_method_call);
            last_list_method_calls_lambda.Add(_method_call);
            return _method_call;
        }

                                                    }
									}
    //case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKROUNDCLOSE_TKROUNDOPEN_TKROUNDCLOSE:
//<variable> ::= 'tkRoundOpen' <variable> 'tkRoundClose' 'tkRoundOpen' <params_value> 'tkRoundClose'
    case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKROUNDCLOSE:
//<variable> ::= 'tkRoundOpen' <variable> <params_value> 'tkRoundClose'
{
    if (LRParser.GetReductionSyntaxNode(1) is ident)
    {
        expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
        int n = el.expressions.Count;
        int fld_params_count = find_count_params_lambda(((ident)LRParser.GetReductionSyntaxNode(1)).name);
        if (_function_lambda_definitions_after.Count > 0)
        {
            function_lambda_definition fld = (function_lambda_definition)_function_lambda_definitions_after[_function_lambda_definitions_after.Count - 2];
            for (int i = 0; i < fld.formal_parameters.params_list.Count; i++)
                if (!fld.formal_parameters.params_list[i].idents.idents[0].name.Contains("$"))
                    n++;
        }
        ////////////////////////////
        if (fld_params_count - n > 0)
        {
            expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(2);
            expression_list _params = new expression_list();
            expression_list _params_el = new expression_list();
            for (int i = 0; i < list_params1.Count; i++)
                if (list_params1[i] is ident)
                {
                    _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                    _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
                }
            for (int i = 1; i <= fld_params_count - n; i++)
                _expression_list.expressions.Add(new ident("$$" + i));
            for (int i = 1; i <= fld_params_count - n; i++)
            {
                _params.expressions.Add(new ident("$$" + i));
                _params_el.expressions.Add(new ident("$$" + i));
            }
            method_call _method_call = new method_call(_expression_list);
            if (_method_call is dereference)
                ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(1);

            op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

            statement_list _statement_list = new statement_list();
            _statement_list.subnodes.Add(_assign);
            ////////////////////////////
            ident_list i_l = new ident_list();
            for (int i = 1; i <= fld_params_count - n; i++)
                i_l.idents.Add(new ident("$$" + i));
            /////////////////////////////
            formal_parameters _formal_parametres = new formal_parameters();
            for (int i = 0; i < _params.expressions.Count; i++)
            {
                ident_list _ident_list = new ident_list();
                ident id = (ident)_params.expressions[i];
                _ident_list.idents.Add(id);
                named_type_reference _named_type_reference = new named_type_reference();

                ident idtype = new ident("datatype");
                _named_type_reference.names.Add(idtype);

                typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
                parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

                _formal_parametres.params_list.Add(_typed_parametres);
            }
            //////////////////////////
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _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_parametres;
            _procedure_definition.return_type = (type_definition)_named_type_reference1;
            _procedure_definition.ident_list = i_l;
            _procedure_definition.proc_body = null;
            _procedure_definition.parameters = _params_el;
            _procedure_definition.lambda_name = "__lambda__" + lambda_num;
            //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
            object rt = _expression_list;
            _procedure_definition.proc_body = _statement_list;
            _function_lambda_definitions_after.Add(_procedure_definition);
            _function_lambda_definitions_after.Add(((ident)LRParser.GetReductionSyntaxNode(1)).name);////////////////
            last_function_lambda_definitions.Add(_procedure_definition);
            return new ident(_procedure_definition.lambda_name);
        }
        else
        {
            for (int i = list_params1.Count - 1; i >= 0; i--)
                if (list_params1[i] is ident)
                {
                    el.expressions.Insert(0, (new ident(((ident)list_params1[i]).name)));
                }

            method_call _method_call = new method_call(el);
            if (_method_call is dereference)
            {
                ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(1);
            }
            list_method_calls.Add(_method_call);
            last_list_method_calls.Add(_method_call);
            last_list_method_calls_lambda.Add(_method_call);
            return _method_call;
        }
    }
    else
    {
        if (LRParser.GetReductionSyntaxNode(1) is method_call)
        {
            method_call mc = LRParser.GetReductionSyntaxNode(1) as method_call;
            expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
            expression_list _expression_list = new expression_list();
            for (int i = 0; i < mc.parameters.expressions.Count; i++)
                _expression_list.expressions.Add(mc.parameters.expressions[i]);
            for (int i = 0; i < el.expressions.Count; i++)
                _expression_list.expressions.Add(el.expressions[i]);
            method_call _method_call = new method_call(_expression_list);
            if (_method_call is dereference)
                ((dereference)_method_call).dereferencing_value = (addressed_value)(new ident(((ident)mc.dereferencing_value).name));
            list_method_calls.RemoveAt(list_method_calls.Count - 1);
            list_method_calls.Add(_method_call);
            last_list_method_calls.Add(_method_call);
            last_list_method_calls_lambda.RemoveAt(last_list_method_calls_lambda.Count - 1);
            last_list_method_calls_lambda.Add(_method_call);
            return _method_call;
        }
        else
            return null;
    }
}
    case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE:
//<variable> ::= 'tkRoundtkOpen' 'tkQuote' 'tkIdent' 'tkQuote' <params_value> 'tkRoundClose'
{
    expression_list el = LRParser.GetReductionSyntaxNode(4) as expression_list;
    ////////////////////////////for curring
    int n = el.expressions.Count;
    int fld_params_count = find_count_params(((ident)LRParser.GetReductionSyntaxNode(2)).name);
    ////////////////////////////
    if (fld_params_count - n > 0)
    {
        expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(4);
        expression_list _params = new expression_list();
        expression_list _params_el = new expression_list();
        for (int i = 0; i < list_params1.Count; i++)
            if (list_params1[i] is ident)
            {
                _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
            }
        for (int i = 1; i <= fld_params_count - n; i++)
            _expression_list.expressions.Insert(0,new ident("$$" + i));
        for (int i = 1; i <= fld_params_count - n; i++)
        {
            _params.expressions.Add(new ident("$$" + i));
            _params_el.expressions.Add(new ident("$$" + i));
        }
        method_call _method_call = new method_call(_expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(2);

        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

        statement_list _statement_list = new statement_list();
        _statement_list.subnodes.Add(_assign);
        ////////////////////////////
        ident_list i_l = new ident_list();
        for (int i = 1; i <= fld_params_count - n; i++)
            i_l.idents.Add(new ident("$$" + i));
        /////////////////////////////
        formal_parameters _formal_parametres = new formal_parameters();
        for (int i = 0; i < _params.expressions.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_params.expressions[i];
            _ident_list.idents.Add(id);
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

            _formal_parametres.params_list.Add(_typed_parametres);
        }
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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_parametres;
        _procedure_definition.return_type = (type_definition)_named_type_reference1;
        _procedure_definition.ident_list = i_l;
        _procedure_definition.proc_body = null;
        _procedure_definition.parameters = _params_el;
        _procedure_definition.lambda_name = "__lambda__" + lambda_num;
        //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
        object rt = _expression_list;
        _procedure_definition.proc_body = _statement_list;
        _function_lambda_definitions_after.Add(_procedure_definition);
        _function_lambda_definitions_after.Add(((ident)LRParser.GetReductionSyntaxNode(2)).name);////////////////
        last_function_lambda_definitions.Add(_procedure_definition);
        return new ident(_procedure_definition.lambda_name);
    }
    else
    {
        method_call _method_call = null;
        string name = ((ident)LRParser.GetReductionSyntaxNode(2)).name;
        _method_call = new method_call(el);
        if (_method_call is dereference)
        {
            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(2);
            parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(2), _method_call);
        }
        list_method_calls.Add(_method_call);
        last_list_method_calls.Add(_method_call);
        last_list_method_calls_lambda.Add(_method_call);
        return _method_call;
    }
}
    //case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE_TKROUNDOPEN_TKROUNDCLOSE:
//<variable> ::= 'tkRoundOpen' 'tkQuote' 'tkIdent' 'tkQuote' <params_value> 'tkRoundClose' 'tkRoundOpen' <params_value> 'tkRoundClose'
    /*case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE2:
//<variable> ::= 'tkRoundOpen' 'tkQuote' 'tkIdent' 'tkQuote' <params_value> 'tkRoundClose' <params_value>
{
    ////////////////////////////////////////////////////////ident_params
    ident _ident = (ident)LRParser.GetReductionSyntaxNode(2);
    expression_list el = new expression_list();
    el.expressions.Add(((expression_list)LRParser.GetReductionSyntaxNode(6)).expressions[0]);
    el.expressions.Add(((expression_list)LRParser.GetReductionSyntaxNode(4)).expressions[0]);
    ////////////////////////////////////////////////////////
    //expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
    ////////////////////////////for curring
    int n = el.expressions.Count;
    int fld_params_count = find_count_params(_ident.name);
    ////////////////////////////
    if (fld_params_count - n > 0)
    {
        expression_list _expression_list = el;
        expression_list _params = new expression_list();
        expression_list _params_el = new expression_list();
        for (int i = 0; i < list_params1.Count; i++)
            if (list_params1[i] is ident)
            {
                _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
            }
        for (int i = 1; i <= fld_params_count - n; i++)
            _expression_list.expressions.Add(new ident("$$" + i));
        for (int i = 1; i <= fld_params_count - n; i++)
        {
            _params.expressions.Add(new ident("$$" + i));
            _params_el.expressions.Add(new ident("$$" + i));
        }
        method_call _method_call = new method_call(_expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;

        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

        statement_list _statement_list = new statement_list();
        _statement_list.subnodes.Add(_assign);
        ////////////////////////////
        ident_list i_l = new ident_list();
        for (int i = 1; i <= fld_params_count - n; i++)
            i_l.idents.Add(new ident("$$" + i));
        /////////////////////////////
        formal_parameters _formal_parametres = new formal_parameters();
        for (int i = 0; i < _params.expressions.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_params.expressions[i];
            _ident_list.idents.Add(id);
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

            _formal_parametres.params_list.Add(_typed_parametres);
        }
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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_parametres;
        _procedure_definition.return_type = (type_definition)_named_type_reference1;
        _procedure_definition.ident_list = i_l;
        _procedure_definition.proc_body = null;
        _procedure_definition.parameters = _params_el;
        _procedure_definition.lambda_name = "__lambda__" + lambda_num;
        //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
        object rt = _expression_list;
        _procedure_definition.proc_body = _statement_list;
        _function_lambda_definitions_after.Add(_procedure_definition);
        _function_lambda_definitions_after.Add(_ident.name);////////////////
        last_function_lambda_definitions.Add(_procedure_definition);
        return new ident(_procedure_definition.lambda_name);
    }
    else
    {
        method_call _method_call = new method_call(el);

        if (_method_call is dereference)
        {
            ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;
            parsertools.create_source_context(_method_call, _ident, _method_call);
        }
        list_method_calls.Add(_method_call);
        last_list_method_calls.Add(_method_call);
        last_list_method_calls_lambda.Add(_method_call);
        return _method_call;

    }
}*/
    /*case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE:
//<variable> ::= 'tkRoundOpen' <params_value> 'tkQuote' 'tkIdent' 'tkQuote' 'tkRoundClose'
{
    expression_list el = LRParser.GetReductionSyntaxNode(1) as expression_list;
    ////////////////////////////for curring
    int n = el.expressions.Count;
    int fld_params_count = find_count_params(((ident)LRParser.GetReductionSyntaxNode(3)).name);
    ////////////////////////////
    if (fld_params_count - n > 0)
    {
        expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(1);
        expression_list _params = new expression_list();
        expression_list _params_el = new expression_list();
        for (int i = 0; i < list_params1.Count; i++)
            if (list_params1[i] is ident)
            {
                _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
            }
        for (int i = 1; i <= fld_params_count - n; i++)
            _expression_list.expressions.Add(new ident("$$" + i));
        for (int i = 1; i <= fld_params_count - n; i++)
        {
            _params.expressions.Add(new ident("$$" + i));
            _params_el.expressions.Add(new ident("$$" + i));
        }
        method_call _method_call = new method_call(_expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(3);

        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

        statement_list _statement_list = new statement_list();
        _statement_list.subnodes.Add(_assign);
        ////////////////////////////
        ident_list i_l = new ident_list();
        for (int i = 1; i <= fld_params_count - n; i++)
            i_l.idents.Add(new ident("$$" + i));
        /////////////////////////////
        formal_parameters _formal_parametres = new formal_parameters();
        for (int i = 0; i < _params.expressions.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_params.expressions[i];
            _ident_list.idents.Add(id);
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

            _formal_parametres.params_list.Add(_typed_parametres);
        }
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
        object rt = _expression_list;
        _procedure_definition.proc_body = _statement_list;
        _function_lambda_definitions_after.Add(_procedure_definition);
        _function_lambda_definitions_after.Add(((ident)LRParser.GetReductionSyntaxNode(3)).name);////////////////
        last_function_lambda_definitions.Add(_procedure_definition);
        return new ident(_procedure_definition.lambda_name);
    }
    else
    {
        method_call _method_call = null;
        string name = ((ident)LRParser.GetReductionSyntaxNode(3)).name;
        _method_call = new method_call(el);
        if (_method_call is dereference)
        {
            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(3);
            parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(3), _method_call);
        }
        list_method_calls.Add(_method_call);
        last_list_method_calls.Add(_method_call);
        last_list_method_calls_lambda.Add(_method_call);
        return _method_call;
    }
}
    case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE_TKROUNDOPEN_TKROUNDCLOSE:
//<variable> ::= 'tkRoundOpen' <params_value> 'tkQuote' 'tkIdent' 'tkQuote' 'tkRoundClose' 'tkRoundOpen' <params_value> 'tkRoundClose'
{
    ////////////////////////////////////////////////////////ident_params
    ident _ident = (ident)LRParser.GetReductionSyntaxNode(3);
    expression_list el = new expression_list();
    el.expressions.Add(((expression_list)LRParser.GetReductionSyntaxNode(1)).expressions[0]);
    el.expressions.Add(((expression_list)LRParser.GetReductionSyntaxNode(7)).expressions[0]);
    ////////////////////////////////////////////////////////
    //expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
    ////////////////////////////for curring
    int n = el.expressions.Count;
    int fld_params_count = find_count_params(_ident.name);
    ////////////////////////////
    if (fld_params_count - n > 0)
    {
        expression_list _expression_list = el;
        expression_list _params = new expression_list();
        expression_list _params_el = new expression_list();
        for (int i = 0; i < list_params1.Count; i++)
            if (list_params1[i] is ident)
            {
                _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
            }
        for (int i = 1; i <= fld_params_count - n; i++)
            _expression_list.expressions.Add(new ident("$$" + i));
        for (int i = 1; i <= fld_params_count - n; i++)
        {
            _params.expressions.Add(new ident("$$" + i));
            _params_el.expressions.Add(new ident("$$" + i));
        }
        method_call _method_call = new method_call(_expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;

        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

        statement_list _statement_list = new statement_list();
        _statement_list.subnodes.Add(_assign);
        ////////////////////////////
        ident_list i_l = new ident_list();
        for (int i = 1; i <= fld_params_count - n; i++)
            i_l.idents.Add(new ident("$$" + i));
        /////////////////////////////
        formal_parameters _formal_parametres = new formal_parameters();
        for (int i = 0; i < _params.expressions.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_params.expressions[i];
            _ident_list.idents.Add(id);
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

            _formal_parametres.params_list.Add(_typed_parametres);
        }
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
        object rt = _expression_list;
        _procedure_definition.proc_body = _statement_list;
        _function_lambda_definitions_after.Add(_procedure_definition);
        _function_lambda_definitions_after.Add(_ident.name);////////////////
        last_function_lambda_definitions.Add(_procedure_definition);
        return new ident(_procedure_definition.lambda_name);
    }
    else
    {
        method_call _method_call = new method_call(el);

        if (_method_call is dereference)
        {
            ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;
            parsertools.create_source_context(_method_call, _ident, _method_call);
        }
        list_method_calls.Add(_method_call);
        last_list_method_calls.Add(_method_call);
        last_list_method_calls_lambda.Add(_method_call);
        return _method_call;

    }
}*/
    /*case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE:
    //<variable> ::= 'tkRoundOpen' <params_value> 'tkQuote' 'tkIdent' 'tkQuote' <params_value> 'tkRoundClose'
    return null;
    case (int)RuleConstants.RULE_VARIABLE_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE_TKROUNDOPEN_TKROUNDCLOSE:
    //<variable> ::= 'tkRoundOpen' <params_value> 'tkQuote' 'tkIdent' 'tkQuote' <params_value> 'tkRoundClose' 'tkRoundOpen' <params_value> 'tkRoundClose'
    return null;*/
    case (int)RuleConstants.RULE_INFIX_EXPR_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE:
//<infix_expr> ::= 'tkRoundOpen' <simple_expr> 'tkQuote' 'tkIdent' 'tkQuote' <simple_expr> 'tkRoundClose'
{
    ArrayList ar = new ArrayList();
    ar.Add(LRParser.GetReductionSyntaxNode(3));
    ar.Add(LRParser.GetReductionSyntaxNode(1));
    ar.Add(LRParser.GetReductionSyntaxNode(5));
    return ar;
}
    case (int)RuleConstants.RULE_INFIX_EXPR_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE2:
//<infix_expr> ::= 'tkRoundOpen' <simple_expr> 'tkQuote' 'tkIdent' 'tkQuote' 'tkRoundClose'
{
    expression_list el = new expression_list();
    el.expressions.Add((expression)LRParser.GetReductionSyntaxNode(1));
    ////////////////////////////for curring
    int n = el.expressions.Count;
    int fld_params_count = find_count_params(((ident)LRParser.GetReductionSyntaxNode(3)).name);
    ////////////////////////////
    if (fld_params_count - n > 0)
    {
        expression_list _expression_list = new expression_list();
        _expression_list.expressions.Add((expression)LRParser.GetReductionSyntaxNode(1));
        expression_list _params = new expression_list();
        expression_list _params_el = new expression_list();
        for (int i = 0; i < list_params1.Count; i++)
            if (list_params1[i] is ident)
            {
                _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
            }
        for (int i = 1; i <= fld_params_count - n; i++)
            _expression_list.expressions.Add(new ident("$$" + i));
        for (int i = 1; i <= fld_params_count - n; i++)
        {
            _params.expressions.Add(new ident("$$" + i));
            _params_el.expressions.Add(new ident("$$" + i));
        }
        method_call _method_call = new method_call(_expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(3);

        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

        statement_list _statement_list = new statement_list();
        _statement_list.subnodes.Add(_assign);
        ////////////////////////////
        ident_list i_l = new ident_list();
        for (int i = 1; i <= fld_params_count - n; i++)
            i_l.idents.Add(new ident("$$" + i));
        /////////////////////////////
        formal_parameters _formal_parametres = new formal_parameters();
        for (int i = 0; i < _params.expressions.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_params.expressions[i];
            _ident_list.idents.Add(id);
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

            _formal_parametres.params_list.Add(_typed_parametres);
        }
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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_parametres;
        _procedure_definition.return_type = (type_definition)_named_type_reference1;
        _procedure_definition.ident_list = i_l;
        _procedure_definition.proc_body = null;
        _procedure_definition.parameters = _params_el;
        _procedure_definition.lambda_name = "__lambda__" + lambda_num;
        //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
        object rt = _expression_list;
        _procedure_definition.proc_body = _statement_list;
        _function_lambda_definitions_after.Add(_procedure_definition);
        _function_lambda_definitions_after.Add(((ident)LRParser.GetReductionSyntaxNode(3)).name);////////////////
        last_function_lambda_definitions.Add(_procedure_definition);
        return new ident(_procedure_definition.lambda_name);
    }
    else
    {
        method_call _method_call = null;
        string name = ((ident)LRParser.GetReductionSyntaxNode(3)).name;
        _method_call = new method_call(el);
        if (_method_call is dereference)
        {
            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(3);
            parsertools.create_source_context(_method_call, LRParser.GetReductionSyntaxNode(3), _method_call);
        }
        list_method_calls.Add(_method_call);
        last_list_method_calls.Add(_method_call);
        last_list_method_calls_lambda.Add(_method_call);
        return _method_call;
    }
}
    //case (int)RuleConstants.RULE_INFIX_EXPR_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE_TKROUNDOPEN_TKROUNDCLOSE:
//<infix_expr> ::= 'tkRoundOpen' <simple_expr> 'tkQuote' 'tkIdent' 'tkQuote' 'tkRoundClose' 'tkRoundOpen' <params_value> 'tkRoundClose'
    //case (int)RuleConstants.RULE_INFIX_EXPR_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE3:
//<infix_expr> ::= 'tkRoundOpen' <simple_expr> 'tkQuote' 'tkIdent' 'tkQuote' 'tkRoundClose' <params_value>
    case (int)RuleConstants.RULE_INFIX_EXPR_TKROUNDOPEN_TKROUNDOPEN_TKQUOTE_TKIDENT_TKQUOTE_TKROUNDCLOSE_TKROUNDCLOSE:
//<infix_expr> ::= 'tkRoundOpen' 'tkRoundOpen' <simple_expr> 'tkQuote' 'tkIdent' 'tkQuote' 'tkRoundClose' <params_value> 'tkRoundClose'
{
    ////////////////////////////////////////////////////////ident_params
    ident _ident = (ident)LRParser.GetReductionSyntaxNode(4);
    expression_list el = new expression_list();
    el.expressions.Add((expression)LRParser.GetReductionSyntaxNode(2));
    el.expressions.Add(((expression_list)LRParser.GetReductionSyntaxNode(7)).expressions[0]);
    ////////////////////////////////////////////////////////
    //expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
    ////////////////////////////for curring
    int n = el.expressions.Count;
    int fld_params_count = find_count_params(_ident.name);
    ////////////////////////////
    if (fld_params_count - n > 0)
    {
        expression_list _expression_list = el;
        expression_list _params = new expression_list();
        expression_list _params_el = new expression_list();
        for (int i = 0; i < list_params1.Count; i++)
            if (list_params1[i] is ident)
            {
                _params.expressions.Add(new ident(((ident)list_params1[i]).name));
                _params_el.expressions.Add(new ident(((ident)list_params1[i]).name));
            }
        for (int i = 1; i <= fld_params_count - n; i++)
            _expression_list.expressions.Add(new ident("$$" + i));
        for (int i = 1; i <= fld_params_count - n; i++)
        {
            _params.expressions.Add(new ident("$$" + i));
            _params_el.expressions.Add(new ident("$$" + i));
        }
        method_call _method_call = new method_call(_expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;

        op_type_node _op_type_node = new op_type_node(Operators.Assignment);
        assign _assign = new assign((addressed_value)new ident("result"), _method_call as expression, _op_type_node.type);

        statement_list _statement_list = new statement_list();
        _statement_list.subnodes.Add(_assign);
        ////////////////////////////
        ident_list i_l = new ident_list();
        for (int i = 1; i <= fld_params_count - n; i++)
            i_l.idents.Add(new ident("$$" + i));
        /////////////////////////////
        formal_parameters _formal_parametres = new formal_parameters();
        for (int i = 0; i < _params.expressions.Count; i++)
        {
            ident_list _ident_list = new ident_list();
            ident id = (ident)_params.expressions[i];
            _ident_list.idents.Add(id);
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            typed_parameters _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);

            _formal_parametres.params_list.Add(_typed_parametres);
        }
        //////////////////////////
        named_type_reference _named_type_reference1 = new named_type_reference();
        ident idtype1 = new ident("datatype");
        _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_parametres;
        _procedure_definition.return_type = (type_definition)_named_type_reference1;
        _procedure_definition.ident_list = i_l;
        _procedure_definition.proc_body = null;
        _procedure_definition.parameters = _params_el;
        _procedure_definition.lambda_name = "__lambda__" + lambda_num;
        //new function_lambda_definition(_formal_parametres, (type_definition)_named_type_reference1, i_l, null, _params_el, "lambda" + lambda_num);
        object rt = _expression_list;
        _procedure_definition.proc_body = _statement_list;
        _function_lambda_definitions_after.Add(_procedure_definition);
        _function_lambda_definitions_after.Add(_ident.name);////////////////
        last_function_lambda_definitions.Add(_procedure_definition);
        return new ident(_procedure_definition.lambda_name);
    }
    else
    {
        method_call _method_call = new method_call(el);

        if (_method_call is dereference)
        {
            ((dereference)_method_call).dereferencing_value = (addressed_value)_ident;
            parsertools.create_source_context(_method_call, _ident, _method_call);
        }
        list_method_calls.Add(_method_call);
        last_list_method_calls.Add(_method_call);
        last_list_method_calls_lambda.Add(_method_call);
        return _method_call;

    }
}
    case (int)RuleConstants.RULE_MULTOP_TKSTAR:
	//<multop> ::= 'tkStar'
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_MULTOP_TKSLASH :
	//<multop> ::= 'tkSlash'
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_ADDOP_TKPLUS :
	//<addop> ::= 'tkPlus'
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_ADDOP_TKMINUS :
	//<addop> ::= 'tkMinus'
return LRParser.GetReductionSyntaxNode(0);
	/*case (int)RuleConstants.RULE_STMT_TKPRINT :
	//<stmt> ::= 'tkPrint' <expr>
{
	if (!(LRParser.GetReductionSyntaxNode(1) is function_lambda_call))
    {
        dot_node _dot_node = new dot_node(null, (addressed_value)(new ident("print")));
        _dot_node.left = (addressed_value)LRParser.GetReductionSyntaxNode(1);
        object o = null;
        method_call _method_call = new method_call(o as expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
        procedure_call _procedure_call = new procedure_call(_method_call as addressed_value);
        return _procedure_call;
    }
    else
    {
        function_lambda_call flc = LRParser.GetReductionSyntaxNode(1) as function_lambda_call;
        method_call _method_call1 = new SyntaxTree.method_call(flc.parameters);
        ((dereference)_method_call1).dereferencing_value = (addressed_value)(new ident(flc.f_lambda_def.lambda_name));
        
        dot_node _dot_node = new dot_node(null, (addressed_value)(new ident("print")));
        _dot_node.left = (addressed_value)_method_call1;
        object o = null;
        method_call _method_call = new method_call(o as expression_list);
        if (_method_call is dereference)
            ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;
        procedure_call _procedure_call = new procedure_call(_method_call as addressed_value);
        return _procedure_call;
    }
}*/
    case (int)RuleConstants.RULE_STMT_TKIDENT_TKARROWGEN_TKIDENT:
//<stmt> ::= 'tkIdent' 'tkArrowGen' 'tkIdent'
{
    named_type_reference _named_type_reference1 = new named_type_reference();
    ident idtype1 = new ident("datatype");
    _named_type_reference1.source_context = idtype1.source_context;
    _named_type_reference1.names.Add(idtype1);
    ident_list il = new ident_list();
    il.idents.Add((ident)LRParser.GetReductionSyntaxNode(0));
    ////////////////////////////////////////
    named_type_reference _named_type_reference2 = new named_type_reference();
    _named_type_reference2.names.Add(new SyntaxTree.ident("datatype"));
    expression_list ell = new expression_list();
                 ////////////////////////////////////////
    dot_node _dot_node = new dot_node(null, (addressed_value)LRParser.GetReductionSyntaxNode(2)/*(new ident("getChar"))*/);
    /////*****************
    named_type_reference _named_type_reference3 = new named_type_reference();
    _named_type_reference3.names.Add(new SyntaxTree.ident("datatype"));
    expression_list ell3 = new expression_list();
    ell3.expressions.Add(new string_const("$null"));
    ell3.expressions.Add(new string_const("string") as expression);
    named_type_reference ntr3 = _named_type_reference2;
    new_expr ne3= new new_expr(ntr3, ell3, false, null);
    /////*****************
    _dot_node.left = (addressed_value)ne3;
    object o = null;
    method_call _method_call = new method_call(o as expression_list);
    if (_method_call is dereference)
        ((dereference)_method_call).dereferencing_value = (addressed_value)_dot_node;//LRParser.GetReductionSyntaxNode(2);
                  /////////////////////////////////
    /*ell.expressions.Add(_method_call);
    ell.expressions.Add(new string_const("string") as expression);
    named_type_reference ntr = _named_type_reference2;
    new_expr ne = new new_expr(ntr, ell, false, null);*/
    ////////////////////////////////////////
    var_def_statement _var_def_statement = new var_def_statement(il, (type_definition)_named_type_reference1, _method_call, definition_attribute.None, false);
    var_statement _var_statement = new var_statement(_var_def_statement);
    
    return _var_statement;
}
    case (int)RuleConstants.RULE_STMT_TKIF_TKTHEN_TKELSE:
	//<stmt> ::= 'tkIf' <expr> 'tkThen' <body_func> 'tkElse' <body_func>
{
            								if_node _if_node = new if_node(null, (statement)LRParser.GetReductionSyntaxNode(3), (statement)LRParser.GetReductionSyntaxNode(5));
            								parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(4), parsertools.sc_not_null(LRParser.GetReductionSyntaxNode(5), LRParser.GetReductionSyntaxNode(4)));
            
            								_if_node.condition = _ob((expression)LRParser.GetReductionSyntaxNode(1));
            								parsertools.create_source_context(_if_node, LRParser.GetReductionSyntaxNode(0), _if_node);
            								statement_list sl = new statement_list();
                                            			sl.subnodes.Add(_if_node);
                                            			return sl;
        								}
	case (int)RuleConstants.RULE_STMT_TKCASE_TKROUNDOPEN_TKROUNDCLOSE_TKOF :
	//<stmt> ::= 'tkCase' 'tkRoundOpen' <params1> 'tkRoundClose' 'tkOf' <case_variants>
return null;
    case (int)RuleConstants.RULE_STMT_TKDO_TKFIGUREOPEN_TKSEMICOLON_TKFIGURECLOSE :
	//<stmt> ::= 'tkDo' 'tkFigureOpen' <stmts> 'tkSemiColon' 'tkFigureClose'
return LRParser.GetReductionSyntaxNode(2);
    case (int)RuleConstants.RULE_STMT_TKDO:
//<stmt> ::= 'tkDo' <stmts1>
{
    return LRParser.GetReductionSyntaxNode(1);
}
	case (int)RuleConstants.RULE_STMT_TKRETURN :
	//<stmt> ::= 'tkReturn' <expr>
{
												statement_list _statement_list = new statement_list();

            										ident id = new ident("result");
            										op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            										_op_type_node.source_context = parsertools.GetTokenSourceContext();

            										assign _assign = new assign((addressed_value)id, LRParser.GetReductionSyntaxNode(1) as expression, _op_type_node.type);
            										parsertools.create_source_context(_assign, id, LRParser.GetReductionSyntaxNode(1));
            
            										_statement_list.subnodes.Add((statement)_assign);
            										parsertools.assign_source_context(_statement_list, _assign);
            										return _statement_list;
										}
	case (int)RuleConstants.RULE_STMT :
	//<stmt> ::= <func_call>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_CASE_VARIANTS :
	//<case_variants> ::= <case_variant> <empty>
return LRParser.GetReductionSyntaxNode(0);
    case (int)RuleConstants.RULE_CASE_VARIANTS_TKSPLIT:
//<case_variants> ::= <case_variants> tkSplit <case_variant>
    return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_CASE_VARIANT_TKROUNDOPEN_TKROUNDCLOSE_TKARROW :
	//<case_variant> ::= 'tkRoundOpen' <params1> 'tkRoundClose' 'tkArrow' <body_func>
{
    												param_value_list.Add(LRParser.GetReductionSyntaxNode(1));
        											body_variant_list.Add(LRParser.GetReductionSyntaxNode(4));
    												return null;
											}
    case (int)RuleConstants.RULE_PARAMS1:
//<params1> ::= <param> <empty>
{
    //let_flag.Add(1);
    bool b = false;
    if (list_param.Count == 1)
    {
        list_params_temp.Add(new ArrayList());
        let_where_list_params.Add(new ArrayList());//
        if (list_param[0] is new_expr && ((string_const)((new_expr)list_param[0]).params_list.expressions[1]).Value == "empty")
            b = true;
        list_param.Clear();
    }
    else
    {
        list_params_temp.Add(list_param.Clone());
        let_where_list_params.Add(list_param.Clone());//
    }
    expression_list _expression_list = new expression_list();
    if (list_param.Count == 0)
    {
        if (b)
        {
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            el.expressions.Add(new int32_const(0));
            literal lt;
            string text = "empty_list";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            _expression_list.expressions.Add(newexpr);
        }
        else
        {
            _expression_list.source_context = ((expression)LRParser.GetReductionSyntaxNode(0)).source_context;
            _expression_list.expressions.Add((expression)LRParser.GetReductionSyntaxNode(0));
        }
    }
    else
    {
        ident id = new ident();
        for (int i = 0; i < list_param.Count; i++)
        {
            if (list_param[i] is ident)
                id.name += ((ident)list_param[i]).name;
            else
            {
                errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "идентификатор"));
                return null;
            }
        }
        _expression_list.source_context = ((expression)id).source_context;
        _expression_list.expressions.Add((expression)id);
        list_param.Clear();
    }
    list_params1.Clear();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        list_params1.Add(_expression_list.expressions[i]);
    last_list_method_calls_lambda.Clear();
    return _expression_list;
}
    case (int)RuleConstants.RULE_PARAMS1_TKCOMMA:
//<params1> ::= <params1> 'tkComma' <param>
{
    bool b = false;
    if (list_param.Count == 1)
    {
        list_params_temp.Add(new ArrayList());
        let_where_list_params.Add(new ArrayList());//
        if (list_param[0] is new_expr && ((string_const)((new_expr)list_param[0]).params_list.expressions[1]).Value == "empty")
            b = true;
        list_param.Clear();
    }
    else
    {
        list_params_temp.Add(list_param.Clone());
        let_where_list_params.Add(list_param.Clone());//
    }
    expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(0);
    if (list_param.Count == 0)
    {
        if (!b)
        {
            _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(2) as expression);
        }
        else
        {
            named_type_reference _named_type_reference1 = new named_type_reference();
            ident idtype1 = new ident("datatype");
            _named_type_reference1.source_context = idtype1.source_context;
            _named_type_reference1.names.Add(idtype1);
            expression_list el = new expression_list();
            el.expressions.Add(new int32_const(0));
            literal lt;
            string text = "empty_list";
            lt = new string_const(text);
            el.expressions.Add(lt as expression);
            named_type_reference ntr = _named_type_reference1;
            new_expr newexpr = new new_expr(ntr, el, false, null);
            _expression_list.expressions.Add(newexpr);
        }
    }
    else
    {
        ident id = new ident();
        for (int i = 0; i < list_param.Count; i++)
        {
            if (list_param[i] is ident)
                id.name += ((ident)list_param[i]).name;
            else
            {
                errors.Add(new PascalABCCompiler.Errors.UnexpectedToken(this, "идентификатор"));
                return null;
            }
        }
        _expression_list.expressions.Add((expression)id);
        list_param.Clear();
    }
    list_params1.Clear();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        list_params1.Add(_expression_list.expressions[i]);
    last_list_method_calls_lambda.Clear();
    return _expression_list;
}
	
	case (int)RuleConstants.RULE_FUNC_CALL :
	//<func_call> ::= <expr> <empty>
{
            										statement_list _statement_list = new statement_list();

            										ident id = new ident("result");
            										op_type_node _op_type_node = new op_type_node(Operators.Assignment);
            										_op_type_node.source_context = parsertools.GetTokenSourceContext();
                                                    expression from = (expression)LRParser.GetReductionSyntaxNode(0);
                                                    if (LRParser.GetReductionSyntaxNode(0) is ident && 
                                                        (find_func_name(((ident)LRParser.GetReductionSyntaxNode(0)).name) || find_count_params_lambda(((ident)LRParser.GetReductionSyntaxNode(0)).name) >= 0))
                                                    {
                                                        //expression_list el = LRParser.GetReductionSyntaxNode(2) as expression_list;
                                                        //int n = el.expressions.Count;
                                                        expression_list el = new expression_list();
                                                        int fld_params_count = 0;
                                                        if (find_func_name(((ident)LRParser.GetReductionSyntaxNode(0)).name))
                                                            fld_params_count = find_count_params(((ident)LRParser.GetReductionSyntaxNode(0)).name);
                                                        else
                                                            fld_params_count = find_count_params_lambda(((ident)LRParser.GetReductionSyntaxNode(0)).name);
                                                        if (fld_params_count != 0)
                                                            for (int i = 0; i < fld_params_count; i++)
                                                            {
                                                                string param_name = find_name_params_lambda(((ident)LRParser.GetReductionSyntaxNode(0)).name, i);
                                                                if (param_name.Contains("$"))
                                                                {
                                                                    named_type_reference _named_type_reference1 = new named_type_reference();
                                                                    _named_type_reference1.names.Add(new SyntaxTree.ident("datatype"));
                                                                    expression_list ell = new expression_list();
                                                                    ell.expressions.Add(new string_const("$null") as expression);
                                                                    ell.expressions.Add(new string_const("string") as expression);
                                                                    named_type_reference ntr = _named_type_reference1;
                                                                    new_expr newexpr = new new_expr(ntr, ell, false, null);
                                                                    el.expressions.Add(newexpr);
                                                                }
                                                                else
                                                                {
                                                                    el.expressions.Add(new ident(param_name));
                                                                }
                                                            }
                                                        method_call _method_call = new method_call(el);
                                                        
                                                        if (_method_call is dereference)
                                                            ((dereference)_method_call).dereferencing_value = (addressed_value)LRParser.GetReductionSyntaxNode(0);
                                                        from = _method_call;
                                                    }
                                                    if (LRParser.GetReductionSyntaxNode(0) is ident)
                                                    {
                                                        function_lambda_definition fld = find_func_lambda_name(((ident)LRParser.GetReductionSyntaxNode(0)).name);
                                                        if (fld != null)
                                                        {
                                                            expression_list _expression_list1 = new expression_list();
                                                            function_lambda_call _lambda_call = new function_lambda_call(fld, _expression_list1);
                                                            from = _lambda_call;
                                                        }
                                                    }

            										assign _assign = new assign((addressed_value)id, from, _op_type_node.type);
            										parsertools.create_source_context(_assign, id, LRParser.GetReductionSyntaxNode(0));
            
            										_statement_list.subnodes.Add((statement)_assign);
            										parsertools.assign_source_context(_statement_list, _assign);
                                                    ////////////////////////////
                                                    if (LRParser.GetReductionSyntaxNode(0) is ident)
                                                    {
                                                        list_return_funcs.Add(find_count_params(((ident)LRParser.GetReductionSyntaxNode(0)).name));
                                                    }
                                                    ////////////////////////////
            										return _statement_list;
							}
	case (int)RuleConstants.RULE_PARAMS_VALUE :
	//<params_value> ::= <param_value> <empty>
{
            						expression_list _expression_list = new expression_list();
                                    if (LRParser.GetReductionSyntaxNode(0) != null)
                                        _expression_list.expressions.Add((expression)LRParser.GetReductionSyntaxNode(0));
                                    else
                                        _expression_list.expressions.Add(null);
                                    return _expression_list;
        						}
	case (int)RuleConstants.RULE_PARAMS_VALUE2 :
	//<params_value> ::= <params_value> <param_value>
{
            expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(0);
            parsertools.create_source_context(_expression_list, _expression_list, LRParser.GetReductionSyntaxNode(1));
            _expression_list.expressions.Add(LRParser.GetReductionSyntaxNode(1) as expression);
            return _expression_list;
        }
    case (int)RuleConstants.RULE_PARAM_VALUE:
//<param_value> ::= <expr> <empty>
return LRParser.GetReductionSyntaxNode(0);
	case (int)RuleConstants.RULE_LAMBDA_FUNC_TKLEFTSLASH_TKARROW :
	//<lambda_func> ::= 'tkLeftSlash' <params> 'tkArrow' <body_func>

{
    expression_list _expression_list = (expression_list)LRParser.GetReductionSyntaxNode(1);
    statement_list _statement_list = (statement_list)LRParser.GetReductionSyntaxNode(3);
    ////////////////////////////
    ident_list i_l = new ident_list();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
        i_l.idents.Add((ident)_expression_list.expressions[i]);
    /////////////////////////////
    formal_parameters _formal_parametres = new formal_parameters();
    for (int i = 0; i < _expression_list.expressions.Count; i++)
    {
        ident_list _ident_list = new ident_list();
        ident id = (ident)_expression_list.expressions[i];
        _ident_list.idents.Add(id);
        string name_param = id.name;
        typed_parameters _typed_parametres = null;
        int k = 0;
        while (k < last_list_method_calls_lambda.Count && ((ident)((method_call)last_list_method_calls_lambda[k]).dereferencing_value).name != name_param)
            k++;
        if (k < last_list_method_calls_lambda.Count)
            _typed_parametres = new typed_parameters(_ident_list, func_type(((method_call)last_list_method_calls_lambda[k]).parameters.expressions.Count), parametr_kind.none, null);
        else
        {
            named_type_reference _named_type_reference = new named_type_reference();

            ident idtype = new ident("datatype");
            _named_type_reference.names.Add(idtype);

            _typed_parametres = new typed_parameters(_ident_list, (type_definition)_named_type_reference, parametr_kind.none, null);
            parsertools.create_source_context(_typed_parametres, _ident_list, _named_type_reference);
        }
        _formal_parametres.params_list.Add(_typed_parametres);
    }
    //////////////////////////
    named_type_reference _named_type_reference1 = new named_type_reference();
    ident idtype1 = new ident("datatype");
    _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_parametres;
    _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_parametres,(type_definition)_named_type_reference1,i_l, null,_expression_list, "lambda"+lambda_num);
    object rt = _expression_list;
    _procedure_definition.proc_body = _statement_list;
    //////////////////////let & where
    if (let_stack.Count>0 && ((ArrayList)let_stack[let_stack.Count - 1]).Count > 0)
    {
        _procedure_definition.defs = new List<object>();
        for (int i = 0; i < ((ArrayList)let_stack[let_stack.Count - 1]).Count; i++)
            _procedure_definition.defs.Add((procedure_definition)((ArrayList)let_stack[let_stack.Count - 1])[i]);
        if (let_where_funcs_main.Count + 1 > token_where_count)
        {
            for (int i = 0; i < last_where_funcs.Count; i++)
                //if (((procedure_definition)last_where_funcs[i]).proc_header.name.meth_name.name.Contains("lambda"))
                _procedure_definition.defs.Add((procedure_definition)last_where_funcs[i]);
            for (int i = 0; i < last_where_funcs.Count; i++)
                if (let_funcs.Count > 0)
                    let_funcs.RemoveAt(let_funcs.Count - 1);
            last_where_funcs.Clear();
        }
        for (int i = 0; i < ((ArrayList)let_stack[let_stack.Count - 1]).Count; i++)
            if (let_where_funcs.Count > 0)
                let_where_funcs.RemoveAt(let_where_funcs.Count - 1);
        for (int i = 0; i < ((ArrayList)let_stack[let_stack.Count - 1]).Count; i++)
            if (let_funcs.Count > 0)
                let_funcs.RemoveAt(let_funcs.Count - 1);
        let_func_last.Clear();
        if (let_flag.Count > 0)
            let_flag.RemoveAt(let_flag.Count - 1);
    }
    if (let_stack.Count>0)
        let_stack.RemoveAt(let_stack.Count - 1);
    /*if (let_where_funcs.Count > 0)
    {
        _procedure_definition.defs = new ArrayList();
        for (int i = 0; i < let_where_funcs.Count; i++)
            if (((procedure_definition)let_where_funcs[i]).proc_header.name.meth_name.name.Contains("lambda"))
                _procedure_definition.defs.Add(let_where_funcs[i]);
        if (let_where_funcs_main.Count + 1 > token_where_count)
        {
            for (int i = 0; i < last_where_funcs.Count; i++)
                //if (((procedure_definition)last_where_funcs[i]).proc_header.name.meth_name.name.Contains("lambda"))
                    _procedure_definition.defs.Add((procedure_definition)last_where_funcs[i]);
            for (int i = 0; i < last_where_funcs.Count; i++)
                if (let_funcs.Count > 0)
                    let_funcs.RemoveAt(let_funcs.Count - 1);
            last_where_funcs.Clear();
        }
        int j=0;
        while (j < let_where_funcs.Count)
            if (((procedure_definition)let_where_funcs[j]).proc_header.name.meth_name.name.Contains("lambda"))
                let_where_funcs.RemoveAt(j);
            else
                j++;
        //let_where_funcs.Clear();
        let_func_last.Clear();
        let_flag.Clear();
    }*/
    //////////////////////
    parsertools.create_source_context(_procedure_definition, _expression_list, rt);
    _function_lambda_definitions.Add(_procedure_definition);////////////////
    if (lambda_stack.Count > 0)
    {
        if (((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count > 0)
        {
            if (_procedure_definition.defs == null)
                _procedure_definition.defs = new List<object>();
            for (int i = 0; i < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; i++)
            {
                _procedure_definition.defs.Add((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[i]);
                int j = 0;
                while (j < _function_lambda_definitions.Count && ((function_lambda_definition)_function_lambda_definitions[j]).lambda_name !=
                        ((procedure_definition)((ArrayList)lambda_stack[lambda_stack.Count - 1])[i]).proc_header.name.meth_name.name)
                    j++;
                if (j < _function_lambda_definitions.Count)
                    _function_lambda_definitions.RemoveAt(j);
            }
            //for (int i = 0; i < ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Count; i++)
                //_function_lambda_definitions.RemoveAt(_function_lambda_definitions.Count-1);
            lambda_stack.RemoveAt(lambda_stack.Count - 1);
        }
        if (lambda_stack.Count > 1 && ((ArrayList)lambda_stack[lambda_stack.Count - 2]).Count > 0)
        {
            ((ArrayList)lambda_stack[lambda_stack.Count - 2]).Add(lambda(_procedure_definition));
            lambda_stack.RemoveAt(lambda_stack.Count - 1);
        }
        else
            ((ArrayList)lambda_stack[lambda_stack.Count - 1]).Add(lambda(_procedure_definition));
    }
    //lambda_funcs.Add(_procedure_definition);

    //let_funcs.Add(lambda(_procedure_definition));
    //let_where_funcs.Add(lambda(_procedure_definition));

    return new ident(_procedure_definition.lambda_name);
}
	case (int)RuleConstants.RULE_EMPTY :
	//<empty> ::= 
	//NONTERMINAL:<empty> ::= 
	return null;
	//ENDNONTERMINAL
}
throw new RuleException("Unknown rule");
}  
        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;
        }
        public procedure_definition lambda(function_lambda_definition _function_lambda_definition)
        {
            procedure_definition _func_def = new procedure_definition();
            method_name _method_name1 = new method_name(null,null, new ident(_function_lambda_definition.lambda_name), null);
            //parsertools.create_source_context(_method_name1, _method_name1.meth_name, _method_name1.meth_name);
            function_header _function_header1 = new function_header();

            object rt1 = new object();
            _function_header1.name = _method_name1;
            if (_function_header1.name.meth_name is template_type_name)
            {
                _function_header1.template_args = (_function_header1.name.meth_name as template_type_name).template_args;
                ident id = new ident(_function_header1.name.meth_name.name);
                //parsertools.create_source_context(id, _function_header1.name.meth_name, _function_header1.name.meth_name);
                _function_header1.name.meth_name = id;
            }

            formal_parameters fps = new PascalABCCompiler.SyntaxTree.formal_parameters();
            _function_header1.parameters = _function_lambda_definition.formal_parameters;//fps;

            /*SyntaxTree.named_type_reference _named_type_reference = new SyntaxTree.named_type_reference();
            SyntaxTree.ident idtype = new SyntaxTree.ident("object");
            _named_type_reference.source_context = idtype.source_context;
            _named_type_reference.names.Add(idtype);
            rt1 = _named_type_reference;
            _function_header1.return_type = (SyntaxTree.type_definition)_named_type_reference;*/
            _function_header1.return_type = _function_lambda_definition.return_type;

            _function_header1.of_object = false;
            _function_header1.class_keyword = false;
            token_info _token_info = new token_info("function");
            //_token_info.source_context = parsertools.GetTokenSourceContext();
            //parsertools.create_source_context(_function_header1, _token_info, _token_info);

            block _block1 = new block(null, null);
            statement_list sl1 = new statement_list();
            sl1.subnodes.Add(_function_lambda_definition.proc_body);
            _block1.program_code = sl1;
            _func_def.proc_header = _function_header1;
            _func_def.proc_body = (proc_block)_block1;
            if (_function_lambda_definition.defs != null)
            {
                if (((block)_func_def.proc_body).defs == null)
                    ((block)_func_def.proc_body).defs = new declarations();
                for (int l = 0; l < _function_lambda_definition.defs.Count; l++)
                    ((block)_func_def.proc_body).defs.defs.Add(_function_lambda_definition.defs[l] as procedure_definition);
            }
            _function_lambda_definition.proc_definition = _func_def;
            //parsertools.create_source_context(_func_def, _function_header1, _function_header1);
            return _func_def;
        }
示例#18
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public index_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,formal_parameters _property_parametres,default_indexer_property_node _is_default,SourceContext sc)
		{
			this._property_name=_property_name;
			this._property_type=_property_type;
			this._index_expression=_index_expression;
			this._accessors=_accessors;
			this._array_default=_array_default;
			this._parameter_list=_parameter_list;
			this._attr=_attr;
			this._property_parametres=_property_parametres;
			this._is_default=_is_default;
			source_context = sc;
		}
 public override void visit(formal_parameters _formal_parametres)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#20
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public function_lambda_definition(ident_list _ident_list,type_definition _return_type,formal_parameters _formal_parameters,statement _proc_body,procedure_definition _proc_definition,expression_list _parameters,string _lambda_name,List<declaration> _defs,LambdaVisitMode _lambda_visit_mode,syntax_tree_node _substituting_node,SourceContext sc)
		{
			this._ident_list=_ident_list;
			this._return_type=_return_type;
			this._formal_parameters=_formal_parameters;
			this._proc_body=_proc_body;
			this._proc_definition=_proc_definition;
			this._parameters=_parameters;
			this._lambda_name=_lambda_name;
			this._defs=_defs;
			this._lambda_visit_mode=_lambda_visit_mode;
			this._substituting_node=_substituting_node;
			source_context = sc;
		}
 private ProcScope select_function_definition(ProcScope ps, formal_parameters prms, TypeScope return_type, TypeScope declType)
 {
 	SymScope tmp = returned_scope;
 	List<ElementScope> lst = new List<ElementScope>();
 	if (prms != null)
 	{
 	foreach (typed_parameters pars in prms.params_list)
     {
     	pars.vars_type.visit(this);
     	
     	if (returned_scope != null)
     	{
     		foreach (ident id in pars.idents.idents)
     		{
     			if (returned_scope is ProcScope)
     				returned_scope = new ProcType(returned_scope as ProcScope);
     			ElementScope si = new ElementScope(new SymInfo(id.name, SymbolKind.Parameter,id.name),returned_scope,ps);
     			si.loc = get_location(id);
     			si.param_kind = pars.param_kind;
     			lst.Add(si);
     		}
     	}
     }
 	while (ps != null)
 	{
 		if (ps.parameters != null)
 		{
 			if (ps.parameters.Count == lst.Count)
 			{
 				bool eq = true;
 				for (int i=0; i<lst.Count; i++)
 				{
 					TypeScope left = ps.parameters[i].sc as TypeScope;
 					TypeScope right = lst[i].sc as TypeScope;
 					if (!left.IsEqual(right) || ps.parameters[i].param_kind != lst[i].param_kind)
 					{
 						eq = false;
 						break;
 					}
 				}
 				if (eq)
 				{
 					if (ps.return_type == null && return_type == null) return ps;
 					if (ps.return_type != null && return_type != null)
 					{
 						if ((ps.return_type as TypeScope).IsEqual(return_type))
 						return ps;
 					}
 				}
 			}
 		}
 		ps = ps.nextProc;
 	}
 	}
 	else 
 	{
 		while (ps != null)
 		{
 			if (ps.parameters == null || ps.parameters.Count == 0)
 			{
 				if (ps.return_type == null && return_type == null) return ps;
 					if (ps.return_type != null && return_type != null)
 					{
 						if ((ps.return_type as TypeScope).IsEqual(return_type))
 						return ps;
 					}
 					else return null;
 			}
 			ps = ps.nextProc;
 		}
 	}
 	returned_scope = tmp;
 	return ps;
 }
示例#22
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public function_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,type_definition _return_type,SourceContext sc)
		{
			this._attr_list=_attr_list;
			this._parameters=_parameters;
			this._proc_attributes=_proc_attributes;
			this._name=_name;
			this._of_object=_of_object;
			this._class_keyword=_class_keyword;
			this._template_args=_template_args;
			this._where_defs=_where_defs;
			this._return_type=_return_type;
			source_context = sc;
		}
示例#23
0
 public override void visit(formal_parameters _formal_parametres)
 {
     foreach (typed_parameters tp in _formal_parametres.params_list)
         tp.visit(this);
 }
示例#24
0
 public static procedure_definition BuildShortFuncDefinition(formal_parameters fp, procedure_attributes_list att, method_name name, type_definition result, expression ex, SourceContext headsc)
 {
     var ff = new function_header(fp, att, name, null, result, headsc);
     procedure_definition pd = BuildShortProcFuncDefinition(ff, new assign("Result", ex, ex.source_context));
     return pd;
 }
		public void visit(formal_parameters _formal_parameters)
		{
			read_formal_parameters(_formal_parameters);
		}
示例#26
0
        public static procedure_definition BuildToStringFuncForAutoClass(List<ident> names)
        {
            var pal = new procedure_attributes_list(proc_attribute.attr_override);
            var fp = new formal_parameters();
            var ff = new function_header("ToString", "string", fp, pal);

            var cleft = new char_const('(');
            var cright = new char_const(')');
            var ccomma = new char_const(',');
            bin_expr ex = new bin_expr(cleft, cright, Operators.Plus);
            for (var i = 0; i < names.Count; i++)
            { 
                var dn = new dot_node(names[i], new ident("ToString"));
                var asnode = new typecast_node(names[i], new named_type_reference("object"), op_typecast.as_op);
                var eqnode = new bin_expr(asnode, new nil_const(), Operators.Equal);
                var expr = new question_colon_expression(eqnode, new string_const("nil"), dn);
                ex.left = new bin_expr(ex.left, expr, Operators.Plus);
                if (i<names.Count-1)
                    ex.left = new bin_expr(ex.left, ccomma, Operators.Plus);
            }
            var ass = new assign("Result", ex);

            return BuildShortProcFuncDefinitionNoSC(ff, ass);
        }
示例#27
0
            public static procedure_definition CreateFunctionDefinitionNode(method_name methName, formal_parameters formalPars, bool ofObject, bool classKeyword, statement procBody, type_definition returnType, SourceContext sc)
            {
                procedure_definition procDef = new procedure_definition();

                function_header procHeader = new function_header();
                procHeader.name = methName;
                procHeader.source_context = sc;
                if (procHeader.name.meth_name is template_type_name)
                {
                    procHeader.template_args = (procHeader.name.meth_name as template_type_name).template_args;
                    ident id = new ident(procHeader.name.meth_name.name);
                    procHeader.name.meth_name = id;
                }
                procHeader.parameters = formalPars;
                procHeader.of_object = ofObject;
                procHeader.class_keyword = classKeyword;
                procHeader.return_type = returnType;

                statement_list stmtList = new statement_list();
                stmtList.subnodes.Add(procBody);

                block bl = new block(null, null);
                bl.program_code = stmtList;

                procDef.proc_header = procHeader;
                procDef.proc_body = (proc_block)bl;

                return procDef;
            }
		public void visit(formal_parameters _formal_parameters)
		{
			bw.Write((Int16)39);
			write_formal_parameters(_formal_parameters);
		}
示例#29
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public index_property(formal_parameters _property_parametres,default_indexer_property_node _is_default)
		{
			this._property_parametres=_property_parametres;
			this._is_default=_is_default;
		}
示例#30
0
 /// <summary>
 /// Вывод типа параметров лямбд и типа возвращаемого значения при присваивании лямбды переменной 
 /// </summary>
 public static void InferTypesFromVarStmt(type_node leftType, function_lambda_definition lambdaDef, syntax_tree_visitor visitor)
 {
     if (lambdaDef == null)
         return;
     if (leftType != null)
     {
         delegate_internal_interface dii_left =
             (delegate_internal_interface)leftType.get_internal_interface(internal_interface_kind.delegate_interface);
         if (dii_left == null)
             visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_VARIABLE_TYPE");
         int leftTypeParamsNumber = dii_left.parameters.Count;
         int lambdaDefParamsCount = 0;
         if (lambdaDef.formal_parameters != null && lambdaDef.formal_parameters.params_list.Count != 0)
         {
             for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++)
                 lambdaDefParamsCount += lambdaDef.formal_parameters.params_list[i].idents.idents.Count;
             if (lambdaDefParamsCount != leftTypeParamsNumber)
                 visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_PARAMETERS_NUMBER");
             bool flag = true;
             SyntaxTree.formal_parameters lambdaDefParamsTypes = new formal_parameters();
             for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++)
                 for (int j = 0; j < lambdaDef.formal_parameters.params_list[i].idents.idents.Count; j++)
                 {
                     var param = new SyntaxTree.typed_parameters();
                     param.idents = new ident_list();
                     param.idents.Add(lambdaDef.formal_parameters.params_list[i].idents.idents[j]);
                     param.vars_type = lambdaDef.formal_parameters.params_list[i].vars_type;
                     lambdaDefParamsTypes.Add(param);
                 }
             for (int i = 0; i < leftTypeParamsNumber && flag; i++)
             {
                 if (lambdaDefParamsTypes.params_list[i].vars_type is SyntaxTree.lambda_inferred_type)
                 {
                     if ((lambdaDefParamsTypes.params_list[i].vars_type as SyntaxTree.lambda_inferred_type).real_type is lambda_any_type_node)
                     {
                         var curLeftParType = dii_left.parameters[i].type;
                         lambdaDefParamsTypes.params_list[i].vars_type = new SyntaxTree.lambda_inferred_type();
                         (lambdaDefParamsTypes.params_list[i].vars_type as SyntaxTree.lambda_inferred_type).real_type = curLeftParType;
                         continue;
                     }
                 }
                 var lambdaPar = visitor.convert_strong(lambdaDefParamsTypes.params_list[i].vars_type);
                 if (!convertion_data_and_alghoritms.eq_type_nodes(dii_left.parameters[i].type, lambdaPar))
                 {
                     visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_VARIABLE_TYPE");
                 }
             }
             lambdaDef.formal_parameters = lambdaDefParamsTypes;
         }
         if (lambdaDef.return_type != null && lambdaDef.return_type is lambda_inferred_type)
         {
             if (dii_left.return_value_type != null)
                 (lambdaDef.return_type as lambda_inferred_type).real_type = dii_left.return_value_type;
             else // SSM 23/07/16 - попытка бороться с var p: Shape->() := a->a.Print()
             {
                 var b = TryConvertFuncLambdaBodyWithMethodCallToProcLambdaBody(lambdaDef);
                 if (!b)
                     throw new SimpleSemanticError(visitor.get_location(lambdaDef), "UNABLE_TO_CONVERT_FUNCTIONAL_TYPE_TO_PROCEDURAL_TYPE");
             }
         }
     }
     else
     {
         if (lambdaDef.formal_parameters != null)
             for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++)
                 if (lambdaDef.formal_parameters.params_list[i].vars_type is lambda_inferred_type)
                     visitor.AddError(visitor.get_location(lambdaDef), "IMPOSSIBLE_TO_INFER_TYPES_IN_LAMBDA");
     }
 }
 public formal_parameters GetFormals(object _object)
 {
     if (_object == null)
         return null;
     formal_parameters _formal_parametres;
     if (_object is formal_parameters)
         _formal_parametres = _object as formal_parameters;
     else
     {
         _formal_parametres = new formal_parameters();
         _formal_parametres.params_list.Add(_object as typed_parameters);
     }
     return _formal_parametres;
 }