Microsoft.R.Core.Utility.AstWriter.WriteTree C# (CSharp) Method

WriteTree() public method

public WriteTree ( AstRoot ast ) : string
ast Microsoft.R.Core.AST.AstRoot
return string
        public string WriteTree(AstRoot ast) {
            _sb = new StringBuilder();
            _indent = 0;
            _ast = ast;

            foreach (IAstNode node in ast.Children) {
                WriteNode(node);
            }

            if (_ast.Errors.Count > 0) {
                _sb.AppendLine();

                foreach (var error in _ast.Errors) {
                    _sb.AppendFormat(CultureInfo.InvariantCulture,
                        "{0} {1} [{2}...{3})\r\n",
                        error.ErrorType.ToString(), error.Location.ToString(),
                        error.Start, error.End);
                }
            }

            string text = _sb.ToString();

            _sb = null;
            _ast = null;

            return text;
        }

Usage Example

示例#1
0
        public static void CompareTrees(string expected, AstRoot actualTree)
        {
            AstWriter astWriter = new AstWriter();
            string actual = astWriter.WriteTree(actualTree);
            
            string expectedLine, actualLine;
            int index;
            int result = BaselineCompare.CompareLines(expected, actual, out expectedLine, out actualLine, out index);

            result.Should().Be(0, "Line at {0} should be {1}, but found {2}, different at position {3}", result, expectedLine, actualLine, index);
        }
All Usage Examples Of Microsoft.R.Core.Utility.AstWriter::WriteTree