3 #include "TPushParser.hh"
4 #include "TPushLexer.hh"
5 #include "TDictionary.hh"
6 #include "CLoggerConsole.hh"
7 #include "CMathMLFactoryXSLT.hh"
8 #include "CMathMLFactoryXSLTDiff.hh"
9 #include "AMathMLConsumer.hh"
13 extern void *parseMathMLFile(char *);
17 Context(const std::string& s, TPushLexer& l, TPushParser& p) : buffer(s), i(0), lexer(l), parser(p) { };
21 if (i < buffer.length()) lexer.push(buffer[i++]);
22 else lexer.push('\n');
32 edit_timeout(Context* data)
42 edit_push_char(Context* context, gchar ch)
44 assert(context != NULL);
46 cout << "*** SENDING " << ch << endl;
47 context->lexer.push(ch);
52 edit_push_string(Context* context, const gchar* s)
54 assert(context != NULL);
57 context->parser.freeze();
58 for (unsigned i = 0; s[i]; i++) context->lexer.push(s[i]);
59 context->parser.thaw();
64 edit_drop(Context* context, gboolean alt)
66 assert(context != NULL);
68 context->lexer.drop(alt);
73 main(int argc, char* argv[])
75 CLoggerConsole logger;
76 logger.verbosity(ALogger::Debug);
78 TDictionary dictionary(logger);
79 logger.info("loading the dictionary...");
80 dictionary.load("dictionary-test.xml");
82 logger.info("loading the stylesheet...");
83 DOM::DOMImplementation di;
84 DOM::Document docStyle = di.createDocumentFromURI("./xsl/tml-mmlp.xsl");
85 DOMX::XSLTStylesheet style(docStyle);
87 CMathMLFactoryXSLTDiff factory(logger, style);
88 TPushParser parser(logger, factory, dictionary);
89 TPushLexer lexer(logger, parser);
98 DOM::Document doc = parser.document().document();
99 std::vector< std::pair<DOM::GdomeString, DOM::GdomeString> > np;
100 result = style.apply(doc, np);
101 style.save(result, stdout);
104 Context context("", lexer, parser);
106 GUI_init(&argc, &argv, "mathmleditor", 500, 600, &context);
107 GUI_load_document(gdome_cast_doc(static_cast<GdomeNode*>(factory.document())));
110 GUI_unload_document();