Files
sdk/runtime/vm/ast_printer.h
T
kmillikin@google.com e9eec70cad Change --print-ast output to be more regular.
The print-ast output is useful for debugging front end issues.  It is a mix
of fully-parenthesized prefix notation (i.e., Lisp S-expressions) with some
infix.

It is not valid S-expressions for various other reasons.  Most obviously, it
uses ' (single quote) instead of " (double quote) to delimit strings.

This change makes the print-ast output a valid Scheme S-expression.  It can
be pretty printed by copying it, quoting it (by preceding it with a single
quote), and evaluating it at the REPL of a Scheme implementation.

Also, the AST node pretty names are changed to predictably match the class
name.  It doesn't seem helpful to have them be arbitrary.

BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org//23923005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27282 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-09 10:20:55 +00:00

44 lines
1.2 KiB
C++

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef VM_AST_PRINTER_H_
#define VM_AST_PRINTER_H_
#include "vm/ast.h"
#include "vm/growable_array.h"
namespace dart {
// Forward declaration.
class ParsedFunction;
class AstPrinter : public AstNodeVisitor {
public:
static void PrintNode(AstNode* node);
static void PrintFunctionScope(const ParsedFunction& parsed_function);
static void PrintFunctionNodes(const ParsedFunction& parsed_function);
static void PrintLocalScope(const LocalScope* scope, int variable_index);
#define DECLARE_VISITOR_FUNCTION(BaseName) \
virtual void Visit##BaseName##Node(BaseName##Node* node);
FOR_EACH_NODE(DECLARE_VISITOR_FUNCTION)
#undef DECLARE_VISITOR_FUNCTION
private:
AstPrinter();
~AstPrinter();
void VisitGenericAstNode(AstNode* node);
void VisitGenericLocalNode(AstNode* node, const LocalVariable& local);
void VisitGenericFieldNode(AstNode* node, const Field& field);
DISALLOW_COPY_AND_ASSIGN(AstPrinter);
};
} // namespace dart
#endif // VM_AST_PRINTER_H_