00001 
00002 #include <basix/int.hpp>
00003 #include <basix/vector.hpp>
00004 #include <basix/port.hpp>
00005 #include <basix/literal.hpp>
00006 #include <basix/compound.hpp>
00007 #include <basix/mmx_syntax.hpp>
00008 #include <basix/lisp_syntax.hpp>
00009 #include <basix/cpp_syntax.hpp>
00010 #include <basix/document.hpp>
00011 #include <basix/tuple.hpp>
00012 #include <basix/glue.hpp>
00013 
00014 #define int_literal(x) as_int (as_string (x))
00015 #define is_generic_literal is<literal>
00016 #define gen_literal_apply(f,v) gen (as<generic> (f), v)
00017 #define gen_literal_access(f,v) access (as<generic> (f), v)
00018 #define is_generic_compound is<compound>
00019 #define compound_arguments(x) cdr (as_vector (x))
00020 #define gen_compound_apply(f,v) gen (as<generic> (f), v)
00021 #define empty_vector() as<generic> (vec<generic> ())
00022 
00023 namespace mmx {
00024   static document
00025   GLUE_1 (const generic &arg_1) {
00026     return as_document (arg_1);
00027   }
00028   
00029   static document
00030   GLUE_2 (const document &arg_1) {
00031     return document (arg_1);
00032   }
00033   
00034   static generic
00035   GLUE_3 (const document &arg_1) {
00036     return as_generic (arg_1);
00037   }
00038   
00039   static document
00040   GLUE_4 (const string &arg_1) {
00041     return document (arg_1);
00042   }
00043   
00044   static document
00045   GLUE_5 (const string &arg_1, const tuple<document> &arg_2) {
00046     return make_texmacs (arg_1, as_vector (arg_2));
00047   }
00048   
00049   static document
00050   GLUE_6 (const literal &arg_1, const tuple<document> &arg_2) {
00051     return make_texmacs (arg_1, as_vector (arg_2));
00052   }
00053   
00054   static document
00055   GLUE_7 (const generic &arg_1) {
00056     return make_text (arg_1);
00057   }
00058   
00059   static document
00060   GLUE_8 (const document &arg_1) {
00061     return make_text (arg_1);
00062   }
00063   
00064   static document
00065   GLUE_9 (const generic &arg_1) {
00066     return make_math (arg_1);
00067   }
00068   
00069   static document
00070   GLUE_10 (const document &arg_1) {
00071     return make_math (arg_1);
00072   }
00073   
00074   static document
00075   GLUE_11 (const tuple<document> &arg_1) {
00076     return make_inline (as_vector (arg_1));
00077   }
00078   
00079   static document
00080   GLUE_12 (const tuple<document> &arg_1) {
00081     return make_block (as_vector (arg_1));
00082   }
00083   
00084   static document
00085   GLUE_13 (const tuple<document> &arg_1) {
00086     return make_row (as_vector (arg_1));
00087   }
00088   
00089   void
00090   glue_document () {
00091     static bool done = false;
00092     if (done) return;
00093     done = true;
00094     call_glue (string ("glue_expression"));
00095     define_type<document > (lit ("Document"));
00096     define ("document", GLUE_1);
00097     define ("document", GLUE_2);
00098     define ("as_generic", GLUE_3);
00099     define_converter ("upgrade", GLUE_4, PENALTY_INCLUSION);
00100     define ("$tm", GLUE_5);
00101     define ("$tm", GLUE_6);
00102     define ("$text", GLUE_7);
00103     define ("$text", GLUE_8);
00104     define ("$math", GLUE_9);
00105     define ("$math", GLUE_10);
00106     define ("$inline", GLUE_11);
00107     define ("$block", GLUE_12);
00108     define ("(.)", GLUE_13);
00109   }
00110 }