當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。