/usr/include/Synopsis/PTree/Display.hh is in libsynopsis0.12-dev 0.12-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | //
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef Synopsis_PTree_Display_hh_
#define Synopsis_PTree_Display_hh_
#include <Synopsis/PTree.hh>
namespace Synopsis
{
namespace PTree
{
//. The Display class provides an annotated view of the ptree,
//. for debugging purposes
class Display : private Visitor
{
public:
Display(std::ostream &os, bool encoded);
void display(Node const *);
virtual void visit(Atom *);
virtual void visit(List *);
// atoms...
virtual void visit(DupAtom *);
// ...lists...
virtual void visit(Brace *);
virtual void visit(Block *b) { visit(static_cast<Brace *>(b));}
virtual void visit(ClassBody *b) { visit(static_cast<Brace *>(b));}
virtual void visit(Declarator *l) { print_encoded(l);}
virtual void visit(Name *l) { print_encoded(l);}
virtual void visit(FstyleCastExpr *l) { print_encoded(l);}
private:
void newline();
bool too_deep();
void print_encoded(List *);
std::ostream &my_os;
size_t my_indent;
bool my_encoded;
};
class RTTIDisplay : private Visitor
{
public:
RTTIDisplay(std::ostream &os, bool encoded);
void display(Node const *);
virtual void visit(Atom *);
virtual void visit(List *);
virtual void visit(DupAtom *);
private:
void newline();
std::ostream &my_os;
size_t my_indent;
bool my_encoded;
};
class DotFileGenerator : public PTree::Visitor
{
public:
DotFileGenerator(std::ostream &);
void write(PTree::Node const *ptree);
private:
virtual void visit(PTree::Atom *a);
virtual void visit(PTree::List *l);
std::ostream &my_os;
};
//. Display the given parse tree segment on the given output stream.
//. If 'encoded' is set to 'true', print encoded names / types
//. on appropriate nodes. If 'typeinfo' is set to 'true', print
//. the class names of the nodes.
inline void display(Node const *node, std::ostream &os,
bool encoded = false, bool typeinfo = false)
{
if (typeinfo)
{
RTTIDisplay d(os, encoded);
d.display(node);
}
else
{
Display d(os, encoded);
d.display(node);
}
}
//. Generate a dot file for the given parse tree segment.
inline void generate_dot_file(Node const *node, std::ostream &os)
{
DotFileGenerator generator(os);
generator.write(node);
}
}
}
#endif
|