Back to index

texmacs  1.0.7.15
Typedefs | Functions
convert.hpp File Reference
#include "analyze.hpp"
#include "hashmap.hpp"

Go to the source code of this file.

Typedefs

typedef tree scheme_tree

Functions

bool is_snippet (tree doc)
string get_texmacs_path ()
void set_file_focus (url u)
url get_file_focus ()
string suffix_to_format (string suffix)
string format_to_suffix (string format)
string get_format (string s, string suffix)
tree generic_to_tree (string s, string format)
string tree_to_generic (tree doc, string format)
tree texmacs_to_tree (string s)
tree texmacs_document_to_tree (string s)
string tree_to_texmacs (tree t)
tree extract (tree doc, string attr)
tree extract_document (tree doc)
tree change_doc_attr (tree doc, string attr, tree val)
hashmap< string, int > get_codes (string version)
tree string_to_tree (string s, string version)
tree upgrade (tree t, string version)
string scheme_tree_to_string (scheme_tree t)
string scheme_tree_to_block (scheme_tree t)
scheme_tree tree_to_scheme_tree (tree t)
string tree_to_scheme (tree t)
scheme_tree string_to_scheme_tree (string s)
scheme_tree block_to_scheme_tree (string s)
tree scheme_tree_to_tree (scheme_tree t)
tree scheme_tree_to_tree (scheme_tree t, string version)
tree scheme_to_tree (string s)
tree scheme_document_to_tree (string s)
string tree_to_verbatim (tree t, bool wrap=false, string enc="default")
tree verbatim_to_tree (string s, bool wrap=false, string enc="default")
tree verbatim_document_to_tree (string s, bool w=false, string e="default")
tree parse_latex (string s, bool change=false)
tree parse_latex_document (string s, bool change=false)
tree latex_to_tree (tree t)
tree latex_document_to_tree (string s)
tree latex_class_document_to_tree (string s)
tree parse_xml (string s)
tree parse_html (string s)
tree tmml_upgrade (scheme_tree t)
tree upgrade_mathml (tree t)
tree parse_bib (string s)

Typedef Documentation

typedef tree scheme_tree

Definition at line 16 of file convert.hpp.


Function Documentation

Definition at line 109 of file from_scheme.cpp.

                                {
  scheme_tree p (TUPLE);
  int i=0;
  while ((i<N(s)) && (is_spc (s[i]) || s[i]==')')) i++;
  while (i<N(s)) {
    p << string_to_scheme_tree (s, i);
    while ((i<N(s)) && (is_spc (s[i]) || s[i]==')')) i++;
  }
  return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree change_doc_attr ( tree  doc,
string  attr,
tree  val 
)

Definition at line 498 of file fromtm.cpp.

                                                  {
  int i, n= arity (doc);
  tree r (doc, n);
  bool done= false;
  for (i=0; i<n; i++)
    if (is_compound (doc[i], attr, 1)) {
      r[i]= tree (L(doc[i]), val);
      done= true;
    }
    else r[i]= doc[i];
  if (!done) r << compound (attr, val);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree extract ( tree  doc,
string  attr 
)

Definition at line 422 of file fromtm.cpp.

                                {
  int i, n= arity (doc);
  for (i=0; i<n; i++)
    if (is_compound (doc[i], attr, 1) ||
       is_expand (doc[i], attr, 1) ||
       is_apply (doc[i], attr, 1))
      {
       tree r= doc[i][N(doc[i])-1];
       if ((attr == "body") && (!is_document (r))) return tree (DOCUMENT, r);
       if (attr == "style") {
         if (r == "none") return tree (TUPLE);
         if (r == "") return tree (TUPLE);
         if (r == "style") return tree (TUPLE);
         if (is_atomic (r)) return tree (TUPLE, r);
         if (!is_func (r, TUPLE)) return tree (TUPLE);
       }
       return r;
      }

  if (attr == "TeXmacs") return "";
  if (attr == "body") return tree (DOCUMENT, "");
  if (attr == "project") return "";
  if (attr == "style") return tree (TUPLE);
  if (attr == "initial") return tree (COLLECTION);
  if (attr == "final") return tree (COLLECTION);
  if (attr == "references") return tree (COLLECTION);
  if (attr == "auxiliary") return tree (COLLECTION);
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 453 of file fromtm.cpp.

                            {
  if (is_func (doc, ERROR)) return doc;
  tree body= extract (doc, "body");
  tree init= extract (doc, "initial");
  if (is_func (init, COLLECTION)) {
    tree w (WITH);
    int i, n= N(init);
    for (i=0; i<n; i++)
      if (is_func (init[i], ASSOCIATE, 2)) {
       tree l= init[i][0];
       tree r= init[i][1];
       if ((l == PAGE_MEDIUM) ||
           (l == PAGE_PRINTED) ||
           (l == PAGE_TYPE) ||
           (l == PAGE_ORIENTATION) ||
           (l == PAGE_WIDTH_MARGIN) ||
           (l == PAGE_SCREEN_MARGIN) ||
           (l == PAGE_NR) ||
           (l == PAGE_WIDTH) ||
           (l == PAGE_HEIGHT) ||
           (l == PAGE_ODD) ||
           (l == PAGE_EVEN) ||
           (l == PAGE_RIGHT) ||
           (l == PAGE_ODD_SHIFT) ||
           (l == PAGE_EVEN_SHIFT) ||
           (l == PAGE_TOP) ||
           (l == PAGE_BOT) ||
           (l == PAGE_SCREEN_WIDTH) ||
           (l == PAGE_SCREEN_HEIGHT) ||
           (l == PAGE_SCREEN_LEFT) ||
           (l == PAGE_SCREEN_RIGHT) ||
           (l == PAGE_SCREEN_TOP) ||
           (l == PAGE_SCREEN_BOT) ||
           (l == PAGE_SHOW_HF)) continue;
       w << l << r;
      }
    if (N(w)>0) {
      w << body;
      body= w;
    }
  }
  return body;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 52 of file generic.cpp.

                             {
  return as_string (call ("format-default-suffix", fm));
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree generic_to_tree ( string  s,
string  format 
)

Definition at line 62 of file generic.cpp.

                                      {
  return as_tree (call ("generic->texmacs", s, fm));
}

Here is the call graph for this function:

Here is the caller graph for this function:

hashmap<string,int> get_codes ( string  version)

Definition at line 41 of file upgradetm.cpp.

                           {
  hashmap<string,int> H (UNKNOWN);
  H->join (STD_CODE);

  if (version_inf ("1.0.7.6", version)) return H;

  rename_feature (H, "group", "rigid");
  rename_feature (H, "postscript", "image");

  if (version_inf ("1.0.6.9", version)) return H;

  rename_feature (H, "frozen", "freeze");

  if (version_inf ("1.0.6.2", version)) return H;

  new_feature (H, "expand-as");
  new_feature (H, "locus");
  new_feature (H, "id");
  new_feature (H, "hard-id");
  new_feature (H, "link");
  new_feature (H, "url");
  new_feature (H, "script");

  if (version_inf ("1.0.4.1", version)) return H;

  new_feature (H, "copy");
  new_feature (H, "cm-length");
  new_feature (H, "mm-length");
  new_feature (H, "in-length");
  new_feature (H, "pt-length");
  new_feature (H, "bp-length");
  new_feature (H, "dd-length");
  new_feature (H, "pc-length");
  new_feature (H, "cc-length");
  new_feature (H, "fs-length");
  new_feature (H, "fbs-length");
  new_feature (H, "em-length");
  new_feature (H, "ln-length");
  new_feature (H, "sep-length");
  new_feature (H, "yfrac-length");
  new_feature (H, "ex-length");
  new_feature (H, "fn-length");
  new_feature (H, "fns-length");
  new_feature (H, "bls-length");
  new_feature (H, "spc-length");
  new_feature (H, "xspc-length");
  new_feature (H, "par-length");
  new_feature (H, "pag-length");
  new_feature (H, "tmpt-length");
  new_feature (H, "px-length");
  new_feature (H, "tmlen");

  if (version_inf ("1.0.3.12", version)) return H;

  new_feature (H, "unquote*");

  if (version_inf ("1.0.3.4", version)) return H;

  new_feature (H, "for-each");
  new_feature (H, "quasi");
  rename_feature (H, "hold", "quasiquote");
  rename_feature (H, "release", "unquote");

  if (version_inf ("1.0.3.3", version)) return H;

  new_feature (H, "quote-value");
  new_feature (H, "quote-arg");
  new_feature (H, "mark");
  new_feature (H, "use-package");
  new_feature (H, "style-only");
  new_feature (H, "style-only*");
  new_feature (H, "rewrite-inactive");
  new_feature (H, "inline-tag");
  new_feature (H, "open-tag");
  new_feature (H, "middle-tag");
  new_feature (H, "close-tag");

  if (version_inf ("1.0.2.8", version)) return H;

  rename_feature (H, "raw_data", "raw-data");
  rename_feature (H, "sub_table", "subtable");
  rename_feature (H, "drd_props", "drd-props");
  rename_feature (H, "get_label", "get-label");
  rename_feature (H, "get_arity", "get-arity");
  rename_feature (H, "map_args", "map-args");
  rename_feature (H, "eval_args", "eval-args");
  rename_feature (H, "find_file", "find-file");
  rename_feature (H, "is_tuple", "is-tuple");
  rename_feature (H, "look_up", "look-up");
  rename_feature (H, "var_if", "if*");
  rename_feature (H, "var_inactive", "inactive*");
  rename_feature (H, "var_active", "active*");
  rename_feature (H, "text_at", "text-at");
  rename_feature (H, "var_spline", "spline*");
  rename_feature (H, "old_matrix", "old-matrix");
  rename_feature (H, "old_table", "old-table");
  rename_feature (H, "old_mosaic", "old-mosaic");
  rename_feature (H, "old_mosaic_item", "old-mosaic-item");
  rename_feature (H, "var_expand", "expand*");
  rename_feature (H, "hide_expand", "hide-expand");

  rename_feature (H, "with_limits", "with-limits");
  rename_feature (H, "line_break", "line-break");
  rename_feature (H, "new_line", "new-line");
  rename_feature (H, "line_separator", "line-sep");
  rename_feature (H, "next_line", "next-line");
  rename_feature (H, "no_line_break", "no-break");
  rename_feature (H, "no_first_indentation", "no-indent");
  rename_feature (H, "enable_first_indentation", "yes-indent");
  rename_feature (H, "no_indentation_after", "no-indent*");
  rename_feature (H, "enable_indentation_after", "yes-indent*");
  rename_feature (H, "page_break_before", "page-break*");
  rename_feature (H, "page_break", "page-break");
  rename_feature (H, "no_page_break_before", "no-page-break*");
  rename_feature (H, "no_page_break_after", "no-page-break");
  rename_feature (H, "new_page_before", "new-page*");
  rename_feature (H, "new_page", "new-page");
  rename_feature (H, "new_double_page_before", "new-dpage*");
  rename_feature (H, "new_double_page", "new-dpage");

  if (version_inf ("1.0.2.5", version)) return H;

  new_feature (H, "compound");
  new_feature (H, "xmacro");
  new_feature (H, "get_label");
  new_feature (H, "get_arity");
  new_feature (H, "map_args");
  new_feature (H, "eval_args");
  new_feature (H, "drd_props");

  if (version_inf ("1.0.2.0", version)) return H;

  new_feature (H, "with_limits");
  new_feature (H, "line_break");
  new_feature (H, "new_line");
  new_feature (H, "line_separator");
  new_feature (H, "next_line");
  new_feature (H, "no_line_break");
  new_feature (H, "no_first_indentation");
  new_feature (H, "enable_first_indentation");
  new_feature (H, "no_indentation_after");
  new_feature (H, "enable_indentation_after");
  new_feature (H, "page_break_before");
  new_feature (H, "page_break");
  new_feature (H, "no_page_break_before");
  new_feature (H, "no_page_break_after");
  new_feature (H, "new_page_before");
  new_feature (H, "new_page");
  new_feature (H, "new_double_page_before");
  new_feature (H, "new_double_page");

  if (version_inf ("1.0.1.25", version)) return H;

  new_feature (H, "active");
  new_feature (H, "var_inactive");
  new_feature (H, "var_active");
  new_feature (H, "attr");

  if (version_inf ("1.0.0.20", version)) return H;

  new_feature (H, "text_at");

  if (version_inf ("1.0.0.19", version)) return H;

  new_feature (H, "find_file");

  if (version_inf ("1.0.0.14", version)) return H;

  rename_feature (H, "paragraph", "para");

  if (version_inf ("1.0.0.5", version)) return H;

  new_feature (H, "var_if");
  new_feature (H, "hide_expand");

  if (version_inf ("1.0.0.2", version)) return H;

  new_feature (H, "superpose");
  new_feature (H, "spline");
  new_feature (H, "var_spline");
  new_feature (H, "cspline");
  new_feature (H, "fill");

  if (version_inf ("0.3.5.2", version)) return H;

  new_feature (H, "raw_data");
  new_feature (H, "include");

  if (version_inf ("0.3.5.1", version)) return H;

  new_feature (H, "var_expand");

  if (version_inf ("0.3.4.12", version)) return H;

  new_feature (H, "range");
  new_feature (H, "is_tuple");
  new_feature (H, "look_up");

  if (version_inf ("0.3.4.11", version)) return H;

  new_feature (H, "float");
  new_feature (H, "datoms");
  new_feature (H, "dlines");
  new_feature (H, "dpages");
  new_feature (H, "pageref");

  if (version_inf ("0.3.4.7", version)) return H;

  rename_feature (H, "matrix", "old_matrix");
  rename_feature (H, "table", "old_table");
  rename_feature (H, "mosaic", "old_mosaic");
  rename_feature (H, "mosaic_item", "old_mosaic_item");

  if (version_inf ("0.3.4.6", version)) return H;

  new_feature (H, "tformat");
  new_feature (H, "twith");
  new_feature (H, "cwith");
  new_feature (H, "tmarker");
  new_feature (H, "row");
  new_feature (H, "cell");
  new_feature (H, "sub_table");

  if (version_inf ("0.3.4.0", version)) return H;

  new_feature (H, "tag");
  new_feature (H, "syntax");

  if (version_inf_eq ("0.3.3.15", version)) return H;

  new_feature (H, "uninit");
  new_feature (H, "error");
  new_feature (H, "surround");
  new_feature (H, "hold");
  new_feature (H, "release");
  new_feature (H, "arg");

  if (version_inf_eq ("0.3.3.0", version)) return H;

  new_feature (H, "with");
  new_feature (H, "macro");
  new_feature (H, "eval");
  new_feature (H, "value");
  new_feature (H, "or");
  new_feature (H, "xor");
  new_feature (H, "and");
  new_feature (H, "not");
  new_feature (H, "over");
  new_feature (H, "divide");
  new_feature (H, "modulo");
  new_feature (H, "length");
  new_feature (H, "date");
  new_feature (H, "equal");
  new_feature (H, "unequal");
  new_feature (H, "less");
  new_feature (H, "lesseq");
  new_feature (H, "greater");
  new_feature (H, "greatereq");
  new_feature (H, "if");
  new_feature (H, "case");
  new_feature (H, "for");
  new_feature (H, "while");
  new_feature (H, "extern");
  new_feature (H, "authorize");

  if (version_inf_eq ("0.3.1.8", version)) return H;

  rename_feature (H, "mosaic item", "mosaic_item");
  rename_feature (H, "<>", "symbol");
  rename_feature (H, ";", "backup");
  rename_feature (H, "'", "quote");
  rename_feature (H, ":=", "assign");
  rename_feature (H, "\\", "apply");
  rename_feature (H, "()", "tuple");
  rename_feature (H, "{,}", "collection");
  rename_feature (H, "->", "associate");
  rename_feature (H, "+", "plus");
  rename_feature (H, "-", "minus");
  rename_feature (H, "x", "times");
  rename_feature (H, "*", "merge");
  rename_feature (H, "nr", "number");
  H ("style")= H ["()"];

  return H;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 37 of file generic.cpp.

                  {
  return current_file_focus;
}

Here is the caller graph for this function:

string get_format ( string  s,
string  suffix 
)

Definition at line 57 of file generic.cpp.

                                     {
  return as_string (call ("format-determine", s, suffix));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 29 of file generic.cpp.

                    {
  string tmpath= get_env ("TEXMACS_PATH");
  while ((N(tmpath)>0) && (tmpath [N(tmpath) - 1] == '/'))
    tmpath= tmpath (0, N(tmpath)-1);
  return tmpath;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_snippet ( tree  doc)

Definition at line 19 of file generic.cpp.

                      {
  if (!is_document (doc)) return true;
  int i, n= N(doc);
  for (i=0; i<n; i++)
    if (is_compound (doc[i], "TeXmacs", 1))
      return false;
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 94 of file fromcls.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1878 of file fromtex.cpp.

                                  {
  command_type ->extend ();
  command_arity->extend ();
  command_def  ->extend ();
  tree t= parse_latex_document (s, true);
  tree r= latex_to_tree (t);
  command_type ->shorten ();
  command_arity->shorten ();
  command_def  ->shorten ();
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1806 of file fromtex.cpp.

                        {
  string style, lan= "";
  bool is_document= is_compound (t1, "!file", 1);
  if (is_document) t1= t1[0];
  if (is_compound (t1, "!language", 2)) {
    lan= t1[1]->label;
    t1 = t1[0];
  }
  textm_appendices= false;
  textm_unicode   = false;
  textm_natbib    = false;
  command_type ("!em") = "false";
  //cout << "\n\nt1= " << t1 << "\n\n";
  tree t2= is_document? filter_preamble (t1): t1;
  //cout << "\n\nt2= " << t2 << "\n\n";
  tree t3= parsed_latex_to_tree (t2);
  //cout << "\n\nt3= " << t3 << "\n\n";
  tree t4= finalize_document (t3);
  // cout << "\n\nt4= " << t4 << "\n\n";
  tree t5= is_document? finalize_preamble (t4, style): t4;
  // cout << "\n\nt5= " << t5 << "\n\n";
  tree t6= handle_improper_matches (t5);
  //cout << "\n\nt6= " << t6 << "\n\n";
  if ((!is_document) && is_func (t6, DOCUMENT, 1)) t6= t6[0];
  tree t7= upgrade_tex (t6);
  //cout << "\n\nt7= " << t7 << "\n\n";
  tree t8= finalize_floats (t7);
  // cout << "\n\nt8= " << t8 << "\n\n";
  tree t9= finalize_misc (t8);
  // cout << "\n\nt9= " << t9 << "\n\n";
  tree t10= finalize_textm (t9);
  // cout << "\n\nt10= " << t10 << "\n\n";
  tree t11= drd_correct (std_drd, t10);
  // cout << "\n\nt11= " << t11 << "\n\n";

  if (!exists (url ("$TEXMACS_STYLE_PATH", style * ".ts")))
    style= "generic";
  tree initial (COLLECTION), mods (WITH);
  if (textm_unicode) {
    string name= "modern";
    if (lan == "chinese") name= "fireflysung";
    //if (lan == "japanese") name= "ipa";
    //if (lan == "korean") name= "unbatang";
    if (lan == "taiwanese") name= "fireflysung";
    initial << tree (ASSOCIATE, FONT, name);
    mods << tree (FONT) << tree (name);
  }
  if (lan != "") {
    initial << tree (ASSOCIATE, LANGUAGE, lan);
    mods << tree (LANGUAGE) << tree (lan);
  }

  tree t12= t11;
  if (is_document) t12= simplify_correct (t11);
  else if (N (mods) > 0) { t12= mods; t12 << t11; }
  // cout << "\n\nt12= " << t12 << "\n\n";
  tree t13= latex_correct (t12);
  // cout << "\n\nt13= " << t13 << "\n\n";

  if (is_document) {
    tree the_body   = compound ("body", t13);
    tree the_style  = compound ("style", style);
    tree the_initial= compound ("initial", initial);
    if (textm_natbib)
      the_style= compound ("style", tuple (style, "cite-author-year"));
    if (N (initial) == 0) return tree (DOCUMENT, the_style, the_body);
    else return tree (DOCUMENT, the_style, the_body, the_initial);
  }
  else return t13;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 369 of file parsebib.cpp.

                     {
  int pos= 0;
  tree r (DOCUMENT);
  bib_current_tag= "";
  bib_list (s, pos, r);
  if (N(s) == 0 || N(r) == 0) return tree ();
  if (pos < 0) {
    cerr << "TeXmacs] Error: failed to load BibTeX file.\n";
    return tree ();
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 802 of file parsexml.cpp.

                      {
  xml_html_parser parser;
  parser.html= true;
  tree t= parser.parse (s);
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree parse_latex ( string  s,
bool  change = false 
)

Definition at line 1115 of file parsetex.cpp.

                                    {
  s= dos_to_better (s);
  string lan= "";
  if (japanese_tex (s)) lan= "japanese";
  else if (korean_tex (s)) lan= "korean";
  else if (taiwanese_tex (s)) lan= "taiwanese";
  else if (chinese_tex (s)) lan= "chinese";
  bool unicode= (lan == "chinese" || lan == "japanese" ||
               lan == "korean" || lan == "taiwanese");
  latex_parser ltx (unicode);
  tree r= accented_to_Cork (ltx.parse (s, change));
  if (lan == "") return r;
  return compound ("!language", r, lan);
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree parse_latex_document ( string  s,
bool  change = false 
)

Definition at line 1131 of file parsetex.cpp.

                                             {
  return compound ("!file", parse_latex (s, change));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 794 of file parsexml.cpp.

                     {
  xml_html_parser parser;
  parser.html= false;
  tree t= parser.parse (s);
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file from_scheme.cpp.

                                   {
  tree error (ERROR, "bad format or data");
  if (starts (s, "(document (apply \"TeXmacs\" ") ||
      starts (s, "(document (expand \"TeXmacs\" ") ||
      starts (s, "(document (TeXmacs "))
  {
    int i, begin=27;
    if (starts (s, "(document (expand \"TeXmacs\" ")) begin= 28;
    if (starts (s, "(document (TeXmacs ")) begin= 19;
    for (i=begin; i<N(s); i++)
      if (s[i] == ')') break;
    string version= s (begin, i);
    tree t  = string_to_scheme_tree (s);
    return scheme_tree_to_tree (t, version);
  }
  return error;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file from_scheme.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 92 of file to_scheme.cpp.

                                     {
  string out;
  int i, n= N(p);
  for (i=0; i<n; i++)
    out << scheme_tree_to_string (p[i]) << "\n";
  return out;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 85 of file to_scheme.cpp.

                                      {
  string out;
  scheme_tree_to_string (out, p);
  return out;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 164 of file from_scheme.cpp.

                                    {
  return scheme_tree_to_tree (t, STD_CODE, true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 153 of file from_scheme.cpp.

                                                    {
  version= scm_unquote (version);
  tree doc, error (ERROR, "bad format or data");
  if (version_inf (version, "1.0.2.4"))
    doc= scheme_tree_to_tree (t, get_codes (version), false);
  else doc= scheme_tree_to_tree (t);
  if (!is_document (doc)) return error;
  return upgrade (doc, version);
}

Here is the call graph for this function:

void set_file_focus ( url  u)

Definition at line 42 of file generic.cpp.

Here is the caller graph for this function:

Definition at line 102 of file from_scheme.cpp.

                                 {
  s= replace (s, "\015", "");
  int i=0;
  return string_to_scheme_tree (s, i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree string_to_tree ( string  s,
string  version 
)

Definition at line 380 of file upgradetm.cpp.

                                          {
  int pos=0;
  return un_paragraph (string_to_tree (s, pos, get_codes (version)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 47 of file generic.cpp.

                                 {
  return as_string (call ("format-from-suffix", suffix));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 361 of file fromtm.cpp.

                                    {
  tree error (ERROR, "bad format or data");
  if (starts (s, "edit") ||
      starts (s, "TeXmacs") ||
      starts (s, "\\(\\)(TeXmacs"))
  {
    string version= "0.0.0.0";
    tree t= string_to_tree (s, version);
    if (is_tuple (t) && (N(t)>0)) t= t (1, N(t));
    int n= arity (t);

    tree doc (DOCUMENT);
    doc << compound ("TeXmacs", version);
    if (n<3) return error;
    else if (n<4)
      doc << compound ("body", t[2])
         << compound ("style", t[0])
         << compound ("initial", t[1]);
    else if (n<7)
      doc << compound ("body", t[0])
         << compound ("style", t[1])
         << compound ("initial", t[2])
         << compound ("references", t[3]);
    else
      doc << compound ("body", t[0])
         << compound ("project", t[1])
         << compound ("style", t[2])
         << compound ("initial", t[3])
         << compound ("final", t[4])
         << compound ("references", t[5])
         << compound ("auxiliary", t[6]);
    return upgrade (doc, version);
  }

  if (starts (s, "<TeXmacs|")) {
    int i;
    for (i=9; i<N(s); i++)
      if (s[i] == '>') break;
    string version= s (9, i);
    tree doc= texmacs_to_tree (s, version);
    if (is_compound (doc, "TeXmacs", 1) ||
       is_expand (doc, "TeXmacs", 1) ||
       is_apply (doc, "TeXmacs", 1))
      doc= tree (DOCUMENT, doc);
    if (!is_document (doc)) return error;
    if (N(doc) == 0 || !is_compound (doc[0], "TeXmacs", 1)) {
      tree d (DOCUMENT);
      d << compound ("TeXmacs", version);
      d << A(doc);
      doc= d;
    }
    return upgrade (doc, version);
  }
  return error;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 335 of file fromtm.cpp.

                           {
  tm_reader tmr (s);
  return tmr.read (true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 15 of file fromxml.cpp.

                        {
  if ((!is_tuple (doc, "document")) || (N(doc)<2))
    return tree (ERROR, "bad format or data");
  string version= "1.0.1.24";
  if (is_tuple (doc[1], "TeXmacs", 1) && is_atomic (doc[1][1]))
    version= doc[1][1]->label;
  return scheme_tree_to_tree (doc, version);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string tree_to_generic ( tree  doc,
string  format 
)

Definition at line 67 of file generic.cpp.

                                      {
  return as_string (call ("texmacs->generic", doc, fm));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 130 of file to_scheme.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 105 of file to_scheme.cpp.

                             {
  if (is_atomic (t)) return scm_quote (t->label);
  else if (is_func (t, EXPAND) && is_atomic (t[0])) {
    int i, n= N(t);
    tree u (TUPLE, n);
    u[0]= copy (t[0]);
    for (i=1; i<n; i++)
      u[i]= tree_to_scheme_tree (t[i]);
    return u;    
  }
  else {
    int i, n= N(t);
    tree u (TUPLE, n+1);
    u[0]= copy (as_string (L(t)));
    for (i=0; i<n; i++)
      u[i+1]= tree_to_scheme_tree (t[i]);
    return u;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 320 of file totm.cpp.

                         {
  if (!is_snippet (t)) {
    int i, n= N(t);
    tree r (t, n);
    for (i=0; i<n; i++)
      if (is_compound (t[i], "style", 1)) {
       tree style= t[i][0];
       if (is_func (style, TUPLE, 1)) style= style[0];
       r[i]= copy (t[i]);
       r[i][0]= style;
      }
      else r[i]= t[i];
    t= r;
  }

  tm_writer tmw;
  tmw.write (t);
  tmw.flush ();
  return tmw.buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string tree_to_verbatim ( tree  t,
bool  wrap = false,
string  enc = "default" 
)

Definition at line 227 of file verbatim.cpp.

                                                 {
  if (enc == "default") enc= "utf-8";
  string buf= as_verbatim (t, wrap);
  if (enc == "utf-8") buf= var_cork_to_utf8 (buf);
  else if (enc == "iso-8859-1") buf= tm_decode (buf);
#ifdef OS_WIN32
  return unix_to_dos (buf);
#else
  return buf;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree upgrade ( tree  t,
string  version 
)

Definition at line 3499 of file upgradetm.cpp.

                                 {
  if (version_inf (version, "0.3.1.9")) {
    path p;
    t= upgrade_textual (t, p);
  }
  if (version_inf (version, "0.3.3.1"))
    t= upgrade_apply_expand_value (t);
  if (version_inf (version, "0.3.3.20"))
    t= upgrade_new_environments (t);
  if (version_inf (version, "0.3.3.24"))
    t= upgrade_items (t);
  if (version_inf (version, "0.3.4.4"))
    t= upgrade_resize (t);
  if (version_inf_eq (version, "0.3.4.7"))
    t= upgrade_table (t);
  if (version_inf_eq (version, "0.3.4.8"))
    t= upgrade_split (t, false);
  if (version_inf_eq (version, "0.3.5.6"))
    t= upgrade_project (t);
  if (version_inf_eq (version, "0.3.5.10"))
    t= upgrade_title (t);
  if (version_inf_eq (version, "1.0.0.1"))
    t= upgrade_cas (t);
  if (version_inf_eq (version, "1.0.0.8"))
    t= simplify_correct (upgrade_mod_symbols (t));
  if (version_inf_eq (version, "1.0.0.11"))
    t= upgrade_menus_in_help (t);
  if (version_inf_eq (version, "1.0.0.13"))
    t= upgrade_capitalize_menus (t);
  if (version_inf_eq (version, "1.0.0.19"))
    t= upgrade_traverse_branch (t);
  if (version_inf_eq (version, "1.0.1.20"))
    t= upgrade_session (t);
  if (version_inf_eq (version, "1.0.2.0"))
    t= upgrade_formatting (t);
  if (version_inf_eq (version, "1.0.2.3"))
    t= upgrade_expand (t, EXPAND);
  if (version_inf_eq (version, "1.0.2.4"))
    t= upgrade_expand (t, HIDE_EXPAND);
  if (version_inf_eq (version, "1.0.2.5")) {
    t= upgrade_expand (t, VAR_EXPAND);
    t= upgrade_xexpand (t);
  }
  if (version_inf_eq (version, "1.0.2.6")) {
    t= upgrade_function (t);
    t= upgrade_apply (t);
  }
  if (version_inf_eq (version, "1.0.2.8"))
    t= upgrade_env_vars (t);
  if (version_inf_eq (version, "1.0.3.3"))
    t= upgrade_use_package (t);
  if (version_inf_eq (version, "1.0.3.4"))
    t= upgrade_style_rename (t);
  if (version_inf_eq (version, "1.0.3.4"))
    t= upgrade_item_punct (t);
  if (version_inf_eq (version, "1.0.3.7"))
    t= upgrade_page_pars (t);
  if (version_inf_eq (version, "1.0.4")) {
    t= substitute (t, tree (VALUE, "hrule"), compound ("hrule"));
    t= upgrade_doc_info (t);
  }
  if (version_inf_eq (version, "1.0.4.6"))
    t= upgrade_bibliography (t);
  if (version_inf_eq (version, "1.0.5.4"))
    t= upgrade_switch (t);
  if (version_inf_eq (version, "1.0.5.7"))
    t= upgrade_fill (t);
  if (version_inf_eq (version, "1.0.5.8"))
    t= upgrade_graphics (t);
  if (version_inf_eq (version, "1.0.5.11"))
    t= upgrade_textat (t);
  if (version_inf_eq (version, "1.0.6.1"))
    t= upgrade_cell_alignment (t);
  if (version_inf_eq (version, "1.0.6.2"))
    t= rename_primitive (t, "hyper-link", "hlink");
  if (version_inf_eq (version, "1.0.6.2"))
    t= upgrade_label_assignment (t);
  if (version_inf_eq (version, "1.0.6.10"))
    t= upgrade_scheme_doc (t);
  if (version_inf_eq (version, "1.0.6.14"))
    t= upgrade_mmx (t);
  if (version_inf_eq (version, "1.0.7.1"))
    t= upgrade_session (t, "scheme", "default");
  if (version_inf_eq (version, "1.0.7.6"))
    t= upgrade_presentation (t);
  if (version_inf_eq (version, "1.0.7.6") && is_non_style_document (t))
    t= upgrade_math (t);
  if (version_inf_eq (version, "1.0.7.7"))
    t= upgrade_resize_clipped (t);
  if (version_inf_eq (version, "1.0.7.7"))
    t= upgrade_image (t);
  if (version_inf_eq (version, "1.0.7.7"))
    t= upgrade_root_switch (t);
  if (version_inf_eq (version, "1.0.7.8"))
    t= upgrade_hyphenation (t);
  if (DEBUG_CORRECT)
    if (is_non_style_document (t))
      math_status_cumul (t);
  if (version_inf_eq (version, "1.0.7.8") && is_non_style_document (t)) {
    t= with_correct (t);
    t= superfluous_with_correct (t);
    t= upgrade_brackets (t);
  }
  if (version_inf_eq (version, "1.0.7.9")) {
    t= move_brackets (t);
    if (is_non_style_document (t))
      t= upgrade_algorithm (t, false);
    t= upgrade_math_ops (t);
  }
  if (version_inf_eq (version, "1.0.7.10"))
    t= downgrade_big (t);
  if (version_inf_eq (version, "1.0.7.13"))
    t= upgrade_gr_attributes (t);
  if (version_inf_eq (version, "1.0.7.14"))
    t= upgrade_cursor (t);

  if (is_non_style_document (t))
    t= automatic_correct (t, version);
  return t;
}

Here is the caller graph for this function:

Definition at line 3492 of file upgradetm.cpp.

                        {
  t= upgrade_brackets (t, "math");
  t= downgrade_big (t);
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree verbatim_document_to_tree ( string  s,
bool  w = false,
string  e = "default" 
)

Definition at line 329 of file verbatim.cpp.

                                                            {
  if (enc == "default") enc= "utf-8";
  tree t    = verbatim_to_tree (s, wrap, enc);
  tree init = tree (COLLECTION,
                  tree (ASSOCIATE, LANGUAGE, "verbatim"),
                  tree (ASSOCIATE, FONT_FAMILY, "tt"),
                  tree (ASSOCIATE, PAR_FIRST, "0cm"));
  return tree (DOCUMENT, compound ("body", t), compound ("initial", init));
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree verbatim_to_tree ( string  s,
bool  wrap = false,
string  enc = "default" 
)

Definition at line 305 of file verbatim.cpp.

                                                   {
  if (enc == "default") enc= "utf-8";
  s= mac_to_unix (dos_to_unix (s));
  if (wrap) {
    string r;
    int i, n= N(s);
    for (i=0; i<n; ) {
      if (s[i] == '\n' || s[i] == ' ' || s[i] == '\t') {
       int lf= 0;
       while (i<n && (s[i] == '\n' || s[i] == ' ' || s[i] == '\t')) {
         if (s[i] == '\n') lf++;
         i++;
       }
       if (lf <= 1) r << " ";
       else r << "\n";
      }
      else r << s[i++];
    }
    s= r;
  }
  return verbatim_to_tree (s, enc);
}

Here is the call graph for this function:

Here is the caller graph for this function: