]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/mathml_editor/test/editor.cc
ocaml 3.09 transition
[helm.git] / helm / DEVEL / mathml_editor / test / editor.cc
index 00aa28eb98c04654e6c3c3738c4015331b4f5506..3efc17cee2168b72acb5429a1f73c3c9bdb12c78 100644 (file)
  * or send an email to <lpadovan@cs.unibo.it>
  */
 
+#include <cassert>
+
 #include "dom.hh"
 #include "TPushParser.hh"
+#include "timer.hh"
 
-#include "LPushLexer.hh"
-
-#include "TPushLexer.hh"
 #include "ILPushLexer.hh"
 #include "TDictionary.hh"
 #include "CLoggerConsole.hh"
@@ -38,8 +38,6 @@
 
 #include "guiGTK.h"
 
-typedef ILPushLexer MyPushLexer;
-
 extern void *parseMathMLFile(char *);
 
 struct Context
@@ -47,7 +45,7 @@ struct Context
   /*
   Context(const std::string& s, TPushLexer& l, TPushParser& p) : buffer(s), i(0), lexer(l), parser(p) { };
   */
-  Context(const std::string& s, MyPushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) 
+  Context(const std::string& s, APushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) 
     : buffer(s), i(0), lexer(l), parser(p), texStyle(ts) { };
 
   void send(void)
@@ -57,8 +55,7 @@ struct Context
 
   std::string buffer;
   unsigned i;
-  //TPushLexer& lexer;
-  MyPushLexer& lexer;
+  APushLexer& lexer;
   TPushParser& parser;
   DOMX::XSLTStylesheet& texStyle;
 };
@@ -71,9 +68,9 @@ edit_output_tex(Context* data)
 #if 0
   res.normalize();
   DOM::Node c = res.get_firstChild();
-  if (c) cout << "HEY, there is a child! " << c.get_nodeName() << " " << c.get_nodeValue() << endl;
+  if (c) std::cout << "HEY, there is a child! " << c.get_nodeName() << " " << c.get_nodeValue() << std::endl;
 #endif
-  data->texStyle.save(res, stdout);
+  //data->texStyle.save(res, stdout);
 }
 
 extern "C" int
@@ -90,10 +87,13 @@ extern "C" void
 edit_push_char(Context* context, gchar ch)
 {
   assert(context != NULL);
+  long t0 = getTimer();
   GUI_freeze();
-  cout << "*** SENDING " << ch << endl;
+  std::cout << "*** SENDING " << ch << std::endl;
   context->lexer.push(ch);
   GUI_thaw();
+  long t1 = getTimer();
+  std::cout << "=== OVERALL TIME = " << (t1 - t0) / 1000 << std::endl;
 }
 
 #include <unistd.h>
@@ -150,7 +150,7 @@ edit_complete(Context* context)
   GUI_thaw();
 }
 
-void
+int
 main(int argc, char* argv[])
 {
   CLoggerConsole logger;
@@ -158,7 +158,7 @@ main(int argc, char* argv[])
 
   TDictionary dictionary(logger);
   logger.info("loading the dictionary...");
-  dictionary.load("./dictionary-test.xml");
+  dictionary.load("./dict/dictionary-tex.xml");
 
   logger.info("loading the stylesheet...");
   DOM::DOMImplementation di;
@@ -170,7 +170,7 @@ main(int argc, char* argv[])
 
   CMathMLFactoryXSLT factory(logger, mmlStyle);
   TPushParser parser(logger, factory, dictionary);
-  MyPushLexer lexer(logger, parser, dictionary);
+  ILPushLexer lexer(logger, parser, dictionary);
 
 #if 0
   lexer.push('$');
@@ -192,4 +192,5 @@ main(int argc, char* argv[])
   GUI_run();
   GUI_uninit();
   GUI_unload_document();
+
 }