Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes
mathemagix_language_rep Struct Reference

#include <impl_language.hpp>

Inheritance diagram for mathemagix_language_rep:
Inheritance graph
[legend]
Collaboration diagram for mathemagix_language_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 mathemagix_language_rep (string name)
text_property advance (tree t, int &pos)
array< int > get_hyphens (string s)
void hyphenate (string s, int after, string &left, string &right)
string get_color (tree t, int start, int end)
virtual string get_group (string s)
virtual array< stringget_members (string s)
virtual void highlight (tree t)

Public Attributes

hashmap< string, stringcolored
string lan_name
int hl_lan
string res_name

Detailed Description

Definition at line 41 of file impl_language.hpp.


Constructor & Destructor Documentation

Definition at line 21 of file mathemagix_language.cpp.

                                                            :
  language_rep (name), colored ("")
{ 
  eval ("(use-modules (utils misc tm-keywords))");
  list<string> l= as_list_string (eval ("(map symbol->string highlight-any)"));
  while (!is_nil (l)) {
    colored (l->item)= "blue";
    l= l->next;
  }
}

Here is the call graph for this function:


Member Function Documentation

text_property mathemagix_language_rep::advance ( tree  t,
int &  pos 
) [virtual]

Implements language_rep.

Definition at line 33 of file mathemagix_language.cpp.

                                                  {
  string s= t->label;
  if (pos==N(s)) return &tp_normal_rep;
  char c= s[pos];
  if (c == ' ') {
    pos++; return &tp_space_rep; }
  if (c >= '0' && c <= '9') {
    parse_number (s, pos); return &tp_normal_rep; }
  if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
      (c == '_') || (c == '$')) {
    parse_alpha (s, pos); return &tp_normal_rep; }
  tm_char_forwards (s, pos);
  return &tp_normal_rep;
}

Here is the call graph for this function:

string mathemagix_language_rep::get_color ( tree  t,
int  start,
int  end 
) [virtual]

Reimplemented from language_rep.

Definition at line 459 of file mathemagix_language.cpp.

                                                              {
  static bool setup_done= false;
  if (!setup_done) {
    mathemagix_color_setup_constants (colored);
    mathemagix_color_setup_keywords (colored);
    mathemagix_color_setup_otherlexeme (colored);
    setup_done= true;
  }

  static string none= "";
  if (start >= end) return none;
  string s= t->label;
  int pos=0;int opos;
  bool backquote= false;
  bool after_backquote;
  bool postfix= false;
  bool possible_function= true;
  bool possible_type= false;
  bool possible_class= false;
  bool possible_future_type= false;
  bool possible_future_function= true;
  bool possible_future_class= false;
  string type;
  bool is_markup;
  do {
    do {
      opos=pos;
      parse_string (s, pos);
      if (opos<pos) break;
      parse_comment (s, pos);
      if (opos<pos) break;
      parse_end_comment (s, pos);
      if (opos<pos) { 
       if (pos>start) {return "brown";} 
       else break;
      }
      pos++;
    }
    while(false);
  }
  while(pos<N(s));
  pos=0;
  do {
    type= none;
    do {
      after_backquote= backquote;
      possible_function= possible_future_function;
      possible_type= possible_future_type;
      possible_class= possible_future_class;
      opos= pos;
      parse_blanks (s, pos);
      if (opos<pos) break;
      parse_string (s, pos);
      if (opos<pos) {
       type= "string";
       backquote= false;
       postfix= false;
       possible_future_function= false;
       possible_future_type= false;
       possible_future_class= false;
       possible_type= false;
       break;
      }
      parse_comment (s, pos);
      if (opos<pos) {
       type= "comment";
       backquote= false;
       postfix= false;
       possible_future_type= false;
       possible_type= false;
       break;
      }
      parse_modifier (colored, s, pos);
      if (opos<pos) {
       type="keyword";
       backquote= false;
       postfix= false;
       possible_future_type= false;
       possible_type= false;
       possible_function= false;
       break;
         }
      parse_postfix (colored, s, pos);
      if (opos<pos) {
       type="keyword";
       backquote= false;
       postfix= true;
       possible_future_type= false;
       possible_future_class= false;
       possible_type= false;
       possible_function= false;
       possible_future_class= false;
       break;
      }
      parse_class (colored, s, pos);
      if (opos<pos) {
       type= "keyword";
       backquote=false;
       postfix=false;
       possible_future_type= false;
       possible_type= false;
       possible_future_class=true;
       possible_future_function= false;
       break;
      }
      parse_keyword (colored, s, pos);
      if (opos<pos) {
       type= "keyword";
       backquote= false;
       postfix= false;
       possible_future_type= false;
       possible_type= false;
       possible_function= false;
       possible_future_function= false;
       possible_future_class= false;
       break;
      }
      parse_other_lexeme (colored, s, pos);  //not left parenthesis
      if (opos<pos) {
       type= "other_lexeme";
       backquote= false;
       postfix= false;
       possible_function= false;
       possible_future_function= true;
       possible_future_type= false;
       possible_future_class= false;
       possible_type= false;
       break;
      }
      parse_constant (colored, s, pos);
      if (opos<pos) {
       type= "constant";
       backquote= false;
       postfix= false;
       possible_future_function= false;
       possible_future_class= false;
       break;
      }
      parse_number (s, pos);
      if (opos<pos) {
       type= "number";
       backquote= false;
       postfix= false;
       possible_future_function= false;
       possible_future_class= false;
       break;
      }
      parse_no_declare_type (s, pos); // :: 
      if (opos<pos) {
       type= "no_declare_type";
       possible_type= false;
       possible_future_type= false;
       possible_function= false;
       possible_future_function= false;
       possible_future_class= false;
       break;
      }  
      parse_backquote (s, pos);
      if (opos<pos) {
       backquote= true;
       postfix= false;
       possible_future_function= false;
       possible_future_class= false;
       break;
      }
      parse_declare_type (s, pos); // : and :>
      if (opos<pos) {
       type= "declare_type";
       backquote= false;
       postfix= false;
       if (!after_backquote) possible_future_type=true; 
       possible_function= false;
       possible_future_function= false;
       possible_future_class= false;
       break;
      }
      parse_identifier_or_markup (colored, s, pos, postfix, is_markup);
      if (opos<pos) {
       if (is_markup) {type= "identifier_markup";} else type= "identifier";
       backquote= false;
       postfix= false;
       possible_future_function=false;
       possible_future_class= false;
       break;
      }
      parse_parenthesized (s, pos);
      // stops after well parenthesized ) or before  // or /{ or " or /"
      if (opos<pos && pos<=start) {
       type="left_parenthesis";
       backquote= false;
       postfix= false;
       possible_function= false;
       possible_future_function= true;
       possible_future_class= false;
       break;
      }
      if (opos<pos && possible_type==true)
       return "dark green";
      if (opos<pos && after_backquote)  
       return none;
      backquote= false;
      postfix= false;
      pos= opos;
      pos++;
    }
    while (false);
  }
  while (pos<=start);
  if (possible_type) return "dark green";
  if (type=="string") return "#a06040";
  if (type=="comment") return "brown";
  if (type=="keyword" && !after_backquote) return "#8020c0";
  if (type=="other_lexeme") return none;
  if (type=="constant") return "#2060c0";
  if (type=="number") return "#2060c0";
  if (type=="no_declare_type") return none;
  if (type=="declare_type") return none;
  if (type=="left_parenthesis") return none;
  if (type=="identifier" && possible_function==false && possible_class==false) 
    return none;
  if (type=="identifier_markup" && possible_function==false
      && possible_class==false) 
    return COLOR_MARKUP;
  if ( (type=="identifier" || type=="identifier_markup") && possible_function) {
    possible_function= false;
    do {
      do {
       opos=pos;
       parse_blanks (s, pos);
       if (opos<pos) break;
       parse_identifier (colored, s, pos,false);
       if (opos<pos) { possible_function= true; break; }
       parse_number (s, pos);
       if (opos<pos) { possible_function= true; break; }
       parse_constant (colored, s, pos);
       if (opos<pos) { possible_function= true; break; }
       parse_comment (s, pos);
       if (opos<pos) break;
       parse_parenthesized (s, pos);
       if (opos<pos) { possible_function= true; break; }
      }
      while (false);
    }
    while (opos!=pos);
    if (!possible_function) {
      if (type=="identifier") {return none;} else return COLOR_MARKUP;
    }
    do {
      do {
       opos=pos;
       parse_blanks (s, pos);
       if (opos<pos) break;
       parse_identifier (colored, s, pos,false);
       if (opos<pos) break;
       parse_number(s,pos);
       if (opos<pos) break;
       parse_constant (colored, s, pos);
       if (opos<pos) break;
       parse_comment(s,pos);
       if (opos<pos) break;
       parse_parenthesized (s, pos);
       if (opos<pos) break;
       parse_no_declare_type (s, pos);
       if (opos<pos) break;
       parse_declare_type (s, pos);
       if (opos<pos) break;
       parse_declare_macro(s,pos);
       if (opos<pos) return "#00d000";
       parse_declare_function (s, pos);
       if (opos<pos) return "#0000e0";
       if (type=="identifier") {return none;} else return COLOR_MARKUP;
      }
      while (false);
    }
    while (pos<N(s));
  }
  if ( (type=="identifier" || type=="identifier_markup") && possible_class) {
  do {
    do {
      opos=pos;
      parse_blanks (s, pos);
      if (opos<pos) break;
      parse_identifier (colored, s, pos,false);
      if (opos<pos) break;
      parse_number(s,pos);
      if (opos<pos) break;
      parse_constant (colored, s, pos);
      if (opos<pos) break;
      parse_comment(s,pos);
      if (opos<pos) break;
      parse_parenthesized (s, pos);
      if (opos<pos) break;
      parse_no_declare_type (s, pos);
      if (opos<pos) break;
      parse_declare_type (s, pos);
      if (opos<pos) break;
      parse_declare_function (s, pos);
      if (opos<pos) return "#0000e0";
      if (type=="identifier") {return none;} else return COLOR_MARKUP;
    }
    while (false);
  }
  while (pos<N(s));
  }
  if (type=="identifier_markup") {return COLOR_MARKUP;} else return none;
}

Here is the call graph for this function:

string language_rep::get_group ( string  s) [virtual, inherited]

Reimplemented in math_language_rep.

Definition at line 150 of file language.cpp.

                                 {
  (void) s;
  return "default";
}

Implements language_rep.

Definition at line 49 of file mathemagix_language.cpp.

                                              {
  int i;
  array<int> penalty (N(s)+1);
  penalty[0]= HYPH_INVALID;
  for (i=1; i<N(s); i++)
    if (s[i-1] == '-' && is_alpha (s[i]))
      penalty[i]= HYPH_STD;
    else penalty[i]= HYPH_INVALID;
  penalty[i]= HYPH_INVALID;
  return penalty;
}

Here is the call graph for this function:

array< string > language_rep::get_members ( string  s) [virtual, inherited]

Reimplemented in math_language_rep.

Definition at line 156 of file language.cpp.

                                   {
  (void) s;
  return array<string> ();
}
void language_rep::highlight ( tree  t) [virtual, inherited]

Definition at line 162 of file language.cpp.

                               {
  if (hl_lan != 0 && !has_highlight (t, hl_lan))
    packrat_highlight (res_name, "Main", t);
}

Here is the call graph for this function:

void mathemagix_language_rep::hyphenate ( string  s,
int  after,
string left,
string right 
) [virtual]

Implements language_rep.

Definition at line 62 of file mathemagix_language.cpp.

{ 
  left = s(0, after);
  right= s(after, N(s));
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 42 of file impl_language.hpp.

int language_rep::hl_lan [inherited]

Definition at line 113 of file language.hpp.

Definition at line 112 of file language.hpp.

string rep< language >::res_name [inherited]

Definition at line 17 of file resource.hpp.


The documentation for this struct was generated from the following files: