Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes
cpp_language_rep Struct Reference

#include <impl_language.hpp>

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

List of all members.

Public Member Functions

 cpp_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 50 of file impl_language.hpp.


Constructor & Destructor Documentation

Definition at line 62 of file cpp_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 cpp_language_rep::advance ( tree  t,
int &  pos 
) [virtual]

Implements language_rep.

Definition at line 74 of file cpp_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 == '_')) {
    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 cpp_language_rep::get_color ( tree  t,
int  start,
int  end 
) [virtual]

Reimplemented from language_rep.

Definition at line 481 of file cpp_language.cpp.

                                                       {
  static bool setup_done= false;
  if (!setup_done) {
    cpp_color_setup_constants (colored);
    cpp_color_setup_keywords (colored);
    cpp_color_setup_otherlexeme (colored);
    setup_done= true;
  }
  static string none= "";
  if (start >= end) return none;
  string s= t->label;
  if (in_comment(s,start,t)) return "brown";
  int pos= 0;
  int opos=0;
  string type;
  if (in_preprocessing(s, t)){
  do {
    do {
    opos= pos;
    type=none;
    parse_blanks (s, pos);
    if (opos < pos) break;
    parse_diese(s, pos);
    if (opos < pos) {type="preprocessing"; break;}
    parse_preprocessing (s, pos);
    if (opos < pos) {type= "preprocessing"; break; }
    pos++;
       }
  while (false);}
  while (pos <= start);
  if (type == "preprocessing") return "#20a000";
  return "#004000";
  }
  pos= 0;
  do {
    type= none;
    do {
      opos= pos;
      parse_blanks (s, pos);
      if (opos < pos) break;
      parse_string (s, pos);
      if (opos < pos) {
       type= "string";
       break;
      }
      parse_comment_single_line (s, pos);
      if (opos < pos) {
       type= "comment";
       break;
      }
      parse_keyword (colored, s, pos);
      if (opos < pos) {
       type= "keyword";
       break;
      }
      parse_other_lexeme (colored, s, pos);  //not left parenthesis
      if (opos < pos) {
       type= "other_lexeme";
       break;
      }
      parse_constant (colored, s, pos);
      if (opos < pos) {
       type= "constant";
       break;
      }
      parse_number (s, pos);
      if (opos < pos) {
       type= "number";
       break;
      }
      parse_identifier (colored, s, pos);
      if (opos < pos) {
       type="identifier";
       break;
      }
      pos= opos;
      pos++;
    }
    while (false);
  }
  while (pos <= start);
  if (type=="string") return "#a06040";
  if (type=="comment") return "brown";
  if (type=="keyword") return "#8020c0";
  if (type=="constant") return "#2060c0";
  if (type=="number") return "#2060c0";
  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";
}
array< int > cpp_language_rep::get_hyphens ( string  s) [virtual]

Implements language_rep.

Definition at line 90 of file cpp_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 cpp_language_rep::hyphenate ( string  s,
int  after,
string left,
string right 
) [virtual]

Implements language_rep.

Definition at line 103 of file cpp_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 51 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: