// {[(
-#include <config.h>
-
-#include "Lsstream.h"
#include "tex2lyx.h"
+#include "context.h"
+
+#include "debug.h"
+#include "lyx_main.h"
+#include "lyxtextclass.h"
+#include "support/path_defines.h"
+#include "support/os.h"
#include <cctype>
#include <fstream>
#include <iostream>
-#include <stack>
#include <string>
+#include <sstream>
#include <vector>
using std::cout;
using std::cerr;
using std::endl;
using std::getline;
+using std::istream;
using std::ifstream;
using std::istringstream;
using std::ostream;
using std::ostringstream;
-using std::stack;
+using std::stringstream;
using std::string;
using std::vector;
+// Hacks to allow the thing to link in the lyxlayout stuff
+Debug::type const Debug::ANY = Debug::type(0);
+DebugStream lyxerr;
-//namespace {
-
+void LyX::emergencyCleanup() {}
void handle_comment(Parser & p)
{
string s;
while (p.good()) {
- Token const & t = p.getToken();
+ Token const & t = p.get_token();
if (t.cat() == catNewline)
break;
s += t.asString();
}
//cerr << "comment: " << s << "\n";
- p.skipSpaces();
+ p.skip_spaces();
}
-
-
string const trim(string const & a, char const * p)
{
// lyx::Assert(p);
// current stack of nested environments
-stack<string> active_environments;
-
-
-void active_environments_push(std::string const & name)
-{
- active_environments.push(name);
-}
+vector<string> active_environments;
-void active_environments_pop()
+string active_environment()
{
- active_environments.pop();
+ return active_environments.empty() ? string() : active_environments.back();
}
-bool active_environments_empty()
-{
- return active_environments.empty();
-}
-
-
-string curr_env()
-{
- return active_environments.empty() ? string() : active_environments.top();
-}
-
-
-
-
-//} // anonymous namespace
-
-
int main(int argc, char * argv[])
{
if (argc <= 1) {
return 2;
}
+ lyx::support::os::init(&argc, &argv);
+ lyx::support::setLyxPaths();
+
ifstream is(argv[1]);
Parser p(is);
- parse_preamble(p, cout);
- active_environments.push("document");
- parse_text(p, cout, FLAG_END, true);
- cout << "\n\\the_end";
-
+ //p.dump();
+
+ stringstream ss;
+ LyXTextClass textclass = parse_preamble(p, ss);
+ active_environments.push_back("document");
+ Context context(true, textclass);
+ parse_text(p, ss, FLAG_END, true, context);
+ context.check_end_layout(ss);
+ ss << "\n\\end_document\n";
+
+ ss.seekg(0);
+ cout << ss.str();
return 0;
}