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, DOMX::XSLTStylesheet& ts)
18 : buffer(s), i(0), lexer(l), parser(p), texStyle(ts) { };
22 if (i < buffer.length()) lexer.push(buffer[i++]);
23 else lexer.push('\n');
30 DOMX::XSLTStylesheet& texStyle;
34 edit_output_tex(Context* data)
37 DOM::Document res = data->texStyle.apply(data->parser.document());
40 DOM::Node c = res.get_firstChild();
41 if (c) cout << "HEY, there is a child! " << c.get_nodeName() << " " << c.get_nodeValue() << endl;
43 data->texStyle.save(res, stdout);
47 edit_timeout(Context* data)
57 edit_push_char(Context* context, gchar ch)
59 assert(context != NULL);
61 cout << "*** SENDING " << ch << endl;
62 context->lexer.push(ch);
67 edit_push_string(Context* context, const gchar* s)
69 assert(context != NULL);
72 context->parser.freeze();
73 for (unsigned i = 0; s[i]; i++) context->lexer.push(s[i]);
74 context->parser.thaw();
79 edit_drop(Context* context, gboolean alt)
81 assert(context != NULL);
83 context->lexer.drop(alt);
88 edit_reset_tex(Context* context)
90 assert(context != NULL);
92 context->lexer.reset();
93 context->parser.reset();
98 main(int argc, char* argv[])
100 CLoggerConsole logger;
101 logger.verbosity(ALogger::Debug);
103 TDictionary dictionary(logger);
104 logger.info("loading the dictionary...");
105 dictionary.load("dictionary-test.xml");
107 logger.info("loading the stylesheet...");
108 DOM::DOMImplementation di;
109 DOM::Document mmlStyleDoc = di.createDocumentFromURI("./xsl/tml-mmlp.xsl");
110 DOMX::XSLTStylesheet mmlStyle(mmlStyleDoc);
112 DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-tex.xsl");
113 DOMX::XSLTStylesheet texStyle(texStyleDoc);
115 CMathMLFactoryXSLTDiff factory(logger, mmlStyle);
116 TPushParser parser(logger, factory, dictionary);
117 TPushLexer lexer(logger, parser);
126 DOM::Document doc = parser.document().document();
127 std::vector< std::pair<DOM::GdomeString, DOM::GdomeString> > np;
128 result = style.apply(doc, np);
129 style.save(result, stdout);
132 Context context("", lexer, parser, texStyle);
134 GUI_init(&argc, &argv, "mathmleditor", 500, 600, &context);
135 GUI_load_document(gdome_cast_doc(static_cast<GdomeNode*>(factory.document())));
138 GUI_unload_document();