javacc-7.0.3.examples.JJTreeExamples.cpp.eg4.Eg4DumpVisitor.cc Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javacc Show documentation
Show all versions of javacc Show documentation
JavaCC is a parser/scanner generator for Java.
/*
* EG4DumpVisitor.cpp
*
* Created on: 28 mars 2014
* Author: FrancisANDRE
*/
#include
#include "JavaCC.h"
#include "EG4DumpVisitor.h"
#include "ASTMyID.h"
#include "ASTMyOtherID.h"
using namespace std;
namespace EG4 {
EG4DumpVisitor::EG4DumpVisitor() : indent (0) {
}
EG4DumpVisitor::~EG4DumpVisitor() {
}
JAVACC_SIMPLE_STRING EG4DumpVisitor::indentString() const {
JAVACC_STRING_TYPE buffer;
for (int i = 0; i < indent; i++) {
buffer.append(" ");
}
return buffer;
}
void* EG4DumpVisitor::visit(const SimpleNode* node, void* data) {
// System.out.println(indentString() + node +
// ": acceptor not unimplemented in subclass?");
++indent;
node->jjtChildrenAccept(this, data);
--indent;
return data;
}
void* EG4DumpVisitor::visit(const ASTStart* node, void* data) {
cout << indentString() + node->toString() << endl;
++indent;
node->jjtChildrenAccept(this, data);
--indent;
return data;
}
void* EG4DumpVisitor::visit(const ASTAdd* node, void* data) {
cout << indentString() + node->toString() << endl;
++indent;
node->jjtChildrenAccept(this, data);
--indent;
return data;
}
void* EG4DumpVisitor::visit(const ASTMult* node, void* data) {
cout << indentString() + node->toString() << endl;
++indent;
node->jjtChildrenAccept(this, data);
--indent;
return data;
}
void* EG4DumpVisitor::visit(const ASTMyID* node, void* data) {
cout << indentString() + node->toString() << endl;
++indent;
node->jjtChildrenAccept(this, data);
--indent;
return data;
}
void* EG4DumpVisitor::visit(const ASTMyOtherID* node, void* data) {
cout << indentString() + node->toString() << endl;
++indent;
node->jjtChildrenAccept(this, data);
--indent;
return data;
}
void* EG4DumpVisitor::visit(const ASTInteger* node, void* data) {
cout << indentString() + node->toString() << endl;
++indent;
node->jjtChildrenAccept(this, data);
--indent;
return data;
}
} /* namespace EG4 */