]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/tex2lyx.C
* funcrequest.C: initialize button_ member
[lyx.git] / src / tex2lyx / tex2lyx.C
index 6fdf33aaab328944b89e5cae2e57428500d6f4f4..a2a60e2370fdbdb2a89415f69d13a0d7d595bb98 100644 (file)
@@ -4,50 +4,55 @@
 
 // {[(
 
-#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);
@@ -100,38 +105,15 @@ char const ** is_known(string const & str, char const ** what)
 
 
 // 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) {
@@ -139,13 +121,23 @@ int main(int argc, char * argv[])
                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;
 }