3 #include "TPushParser.hh"
4 #include "TPushLexer.hh"
5 #include "LPushLexer.hh"
6 #include "TDictionary.hh"
7 #include "CLoggerConsole.hh"
8 #include "CMathMLFactoryXSLT.hh"
9 #include "CMathMLFactoryXSLTDiff.hh"
10 #include "AMathMLConsumer.hh"
14 extern void *parseMathMLFile(char *);
18 Context(const std::string& s, APushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts)
19 : buffer(s), i(0), lexer(l), parser(p), texStyle(ts) { };
23 if (i < buffer.length()) lexer.push(buffer[i++]);
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);
69 edit_push_string(Context* context, const gchar* s)
71 assert(context != NULL);
75 // context->parser.freeze();
76 for (unsigned i = 0; s[i]; i++)
79 context->lexer.push(s[i]);
84 // context->parser.thaw();
91 edit_drop(Context* context, gboolean alt)
93 assert(context != NULL);
95 context->lexer.drop(alt);
100 edit_reset_tex(Context* context)
102 assert(context != NULL);
104 context->lexer.reset();
105 context->parser.reset();
110 main(int argc, char* argv[])
112 CLoggerConsole logger;
113 logger.verbosity(ALogger::Debug);
115 TDictionary dictionary(logger);
116 logger.info("loading the dictionary...");
117 dictionary.load("/home/luca/projects/helm/DEVEL/mathml_editor/dictionary-test.xml");
119 logger.info("loading the stylesheet...");
120 DOM::DOMImplementation di;
121 DOM::Document mmlStyleDoc = di.createDocumentFromURI("./xsl/tml-mmlp.xsl");
122 DOMX::XSLTStylesheet mmlStyle(mmlStyleDoc);
124 DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-tex.xsl");
125 DOMX::XSLTStylesheet texStyle(texStyleDoc);
127 CMathMLFactoryXSLT factory(logger, mmlStyle);
128 TPushParser parser(logger, factory, dictionary);
129 LPushLexer lexer(logger, parser);
138 DOM::Document doc = parser.document().document();
139 std::vector< std::pair<DOM::GdomeString, DOM::GdomeString> > np;
140 result = style.apply(doc, np);
141 style.save(result, stdout);
144 Context context("", lexer, parser, texStyle);
146 GUI_init(&argc, &argv, "mathmleditor", 500, 600, &context);
147 GUI_load_document(gdome_cast_doc(static_cast<GdomeNode*>(factory.document())));
150 GUI_unload_document();