当前位置: 首页>>代码示例>>C#>>正文


C# SyntaxTree.formal_parameters类代码示例

本文整理汇总了C#中PascalABCCompiler.SyntaxTree.formal_parameters的典型用法代码示例。如果您正苦于以下问题:C# formal_parameters类的具体用法?C# formal_parameters怎么用?C# formal_parameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


formal_parameters类属于PascalABCCompiler.SyntaxTree命名空间,在下文中一共展示了formal_parameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildFormalParameters

 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;
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:7,代码来源:NodesBuilder.cs

示例2: visit

 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);
     }
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:8,代码来源:CheckVariablesRedefenitionVisitor.cs

示例3: visit

 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
 }
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:17,代码来源:RenameSameBlockLocalVarsVisitor.cs

示例4: CreateFunctionDefinitionNode

            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;
            }
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:29,代码来源:LambdaHelper.cs

示例5: index_property

		///<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;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:8,代码来源:Tree.cs

示例6: BuildToStringFuncForAutoClass

        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);
        }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:24,代码来源:NodesBuilder.cs

示例7: GetFormals

 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;
 }
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:14,代码来源:KuMir_lrparser_rules.cs

示例8: function_header

		///<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;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:16,代码来源:Tree.cs

示例9: BuildShortFuncDefinition

 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;
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:6,代码来源:NodesBuilder.cs

示例10: while

/*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;
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:37,代码来源:Haskell_lrparser_rules.cs

示例11: function_lambda_definition

		///<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;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:17,代码来源:Tree.cs

示例12: CreateNonTerminalObject


//.........这里部分代码省略.........
            						      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
        {
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:67,代码来源:Haskell_lrparser_rules.cs

示例13: lambda

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;
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:36,代码来源:Haskell_lrparser_rules.cs

示例14: func_decl_lambda

        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;
        }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:82,代码来源:ABCPascalParserTools.cs

示例15: lambda

        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;
        }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:51,代码来源:ABCPascalParserTools.cs


注:本文中的PascalABCCompiler.SyntaxTree.formal_parameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。