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


C# syntax_tree_node.ToString方法代码示例

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


在下文中一共展示了syntax_tree_node.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Enter

        public virtual void Enter(syntax_tree_node st)
        {
            if (st is statement_list)
            {
                Println("begin");
                off += 2;
            }
            else if (st is type_declarations)  // надо в visit и самому всё обрабатывать
            {
                var tds = st is type_declarations;
                Println("type ");
                off += 2;
            }
            else if (st is case_variant)
            {
                var td = st as case_variant;
                Println(td.conditions.ToString()+": ");
                off += 2;
                //ProcessNode(td.type_def);
                //visitNode = false;
            }
            else if (st is type_declaration)
            {
                var td = st as type_declaration;
                Print(td.type_name + " = ");
                ProcessNode(td.type_def);
                visitNode = false;
            }
            else if (st is class_definition)
            {
                var cd = st as class_definition;
                PrintNoOffset("class");
                if (cd.class_parents != null && cd.class_parents.types.Count > 0)
                {
                    PrintlnNoOffset("(" + cd.class_parents.ToString() + ")");
                }
                else
                    PrintlnNoOffset("");
                off += 2;
                ProcessNode(cd.body);
                visitNode = false;
            }
            else if (st is access_modifer_node)
            {
                var am = st as access_modifer_node;
                Println(am.access_level.ToString());

            }
            else if (st is variable_definitions)
            {
                var vds = st as variable_definitions;
                Println("var");
                off += 2;
            }
            else if (st is var_def_statement)
            {
                var vds = st as var_def_statement;
                Println(vds.ToString());
            }
            else if (st is empty_statement || st is declarations || st is block || st is class_body || st is class_members || st is case_variants || st is program_module)
            {
            }
            else if (st is if_node)
            {
                var ifn = st as if_node;

                Println("if " + ifn.condition.ToString() + " then");
                off += 2;
                ProcessNode(ifn.then_body);
                if (ifn.else_body == null)
                {
                    visitNode = false;
                    return;
                }
                off -= 2;
                Println("else ");
                off += 2;
                ProcessNode(ifn.else_body);
                visitNode = false;
            }
            else if (st is while_node)
            {
                var wn = st as while_node;

                Println("while " + wn.expr.ToString() + " do");
                off += 2;
            }
            else if (st is case_node)
            {
                var cn = st as case_node;

                Println("case " + cn.param.ToString() + " of");
                off += 2;
            }
            else if (st is labeled_statement)
            {
                var lst = st as labeled_statement;

                Println(lst.label_name.name + ": ");
                ProcessNode(lst.to_statement);
//.........这里部分代码省略.........
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:101,代码来源:SimplePrettyPrinterVisitor.cs


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