3 #include "TPushParser.hh"
4 #include "TPushLexer.hh"
5 #include "TDictionary.hh"
6 #include "CLoggerConsole.hh"
7 #include "CMathMLFactoryXSLT.hh"
8 #include "AMathMLConsumer.hh"
12 TDictionary dictionary;
14 extern void *parseMathMLFile(char *);
16 class CMathMLConsumer : public AMathMLConsumer
19 CMathMLConsumer(void) { firstTime = true; };
21 virtual void documentModified(const DOM::Document& result)
25 if (GUI_load_document(gdome_cast_doc(static_cast<GdomeNode*>(result))) < 0)
26 cerr << "c'e' stato un errore" << endl;
37 Context(const std::string& s, TPushLexer& l) : buffer(s), i(0), lexer(l) { };
41 if (i < buffer.length()) lexer.push(buffer[i++]);
42 else lexer.push('\n');
51 edit_timeout(Context* data)
61 push_char(Context* context, gchar ch)
64 cout << "*** SENDING " << ch << endl;
65 context->lexer.push(ch);
69 main(int argc, char* argv[])
71 CLoggerConsole logger;
72 logger.info("loading the dictionary...");
73 dictionary.load("dictionary.xml");
75 logger.info("loading the stylesheet...");
76 DOM::DOMImplementation di;
77 DOM::Document docStyle = di.createDocumentFromURI("./xsl/tml-mmlp.xsl");
78 DOM::XSLTStylesheet style(docStyle);
80 CMathMLConsumer consumer;
81 CMathMLFactoryXSLT factory(logger, consumer, style);
82 TPushParser parser(logger, factory, dictionary);
83 TPushLexer lexer(logger, parser);
92 DOM::Document doc = parser.document().document();
93 std::vector< std::pair<DOM::GdomeString, DOM::GdomeString> > np;
94 result = style.apply(doc, np);
95 style.save(result, stdout);
98 Context context("", lexer);
100 GUI_init(&argc, &argv, "mathmleditor", 500, 600, &context);
103 GUI_unload_document();