From dc76953e366a7f49f30992d1d724778607a9b6ef Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Thu, 25 Nov 2010 09:48:30 +0100
Subject: [PATCH] Dump the AST.

---
 src/libs/glsl/tests/main.cpp | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/libs/glsl/tests/main.cpp b/src/libs/glsl/tests/main.cpp
index 25c65892793..7ae42c3fb5a 100644
--- a/src/libs/glsl/tests/main.cpp
+++ b/src/libs/glsl/tests/main.cpp
@@ -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;
-- 
GitLab