Skip to content
Snippets Groups Projects
Commit dc76953e authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Dump the AST.

parent af8f7c43
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,15 @@
#include <glslengine.h>
#include <glslparser.h>
#include <glsllexer.h>
#include <glslastdump.h>
#include <QtCore/QTextStream>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cassert>
#include <cstdio>
using namespace GLSL;
......@@ -16,6 +21,10 @@ using namespace GLSL;
#define EXIT_SUCCESS 0
#endif
namespace {
QTextStream qout(stdout, QIODevice::WriteOnly);
}
int main(int argc, char *argv[])
{
int variant = 0;
......@@ -69,16 +78,8 @@ int main(int argc, char *argv[])
TranslationUnit *ast = parser.parse();
std::cout << argv[1] << (ast ? " OK " : " KO ") << std::endl;
if (ast) {
assert(ast->asTranslationUnit() != 0);
int n = 0;
for (List<Declaration *> *it = ast->declarations; it; it = it->next, ++n) {
Declaration *decl = it->value;
// ### do something with decl
(void) decl;
}
std::cout << "found " << n << " level declarations" << std::endl;
}
ASTDump dump(qout);
dump(ast);
delete source;
delete ast;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment