Back to index

texmacs  1.0.7.15
Defines | Functions
mathemagix_language.cpp File Reference
#include "analyze.hpp"
#include "impl_language.hpp"
#include "scheme.hpp"

Go to the source code of this file.

Defines

#define COLOR_MARKUP   "#500d04"

Functions

static void parse_number (string s, int &pos)
static void parse_string (string s, int &pos)
static void parse_alpha (string s, int &pos)
static void mathemagix_color_setup_constants (hashmap< string, string > &t)
static void mathemagix_color_setup_keywords (hashmap< string, string > &t)
static void mathemagix_color_setup_otherlexeme (hashmap< string, string > &t)
static bool belongs_to_identifier (char c)
static bool is_number (char c)
static void parse_identifier (hashmap< string, string > &t, string s, int &pos, bool postfix)
static void parse_identifier_or_markup (hashmap< string, string > &t, string s, int &pos, bool postfix, bool &is_markup)
static void parse_blanks (string s, int &pos)
static void parse_keyword (hashmap< string, string > &t, string s, int &pos)
static void parse_modifier (hashmap< string, string > &t, string s, int &pos)
static void parse_class (hashmap< string, string > &t, string s, int &pos)
static void parse_postfix (hashmap< string, string > &t, string s, int &pos)
static void parse_constant (hashmap< string, string > &t, string s, int &pos)
static void parse_other_lexeme (hashmap< string, string > &t, string s, int &pos)
static void parse_no_declare_type (string s, int &pos)
static void parse_declare_type (string s, int &pos)
static void parse_comment (string s, int &pos)
static void parse_end_comment (string s, int &pos)
static void parse_parenthesized (string s, int &pos)
static void parse_backquote (string s, int &pos)
static void parse_declare_function (string s, int &pos)
static void parse_declare_macro (string s, int &pos)

Define Documentation

#define COLOR_MARKUP   "#500d04"

Definition at line 15 of file mathemagix_language.cpp.


Function Documentation

static bool belongs_to_identifier ( char  c) [inline, static]

Definition at line 228 of file mathemagix_language.cpp.

                               {
  return ((c<='9' && c>='0') ||
         (c<='Z' && c>='A') ||
        (c<='z' && c>='a') ||
          c=='_' || c=='$'  || c=='?');
}

Here is the caller graph for this function:

static bool is_number ( char  c) [inline, static]

Definition at line 236 of file mathemagix_language.cpp.

                   {
  return (c>='0' && c<='9');
}
static void mathemagix_color_setup_constants ( hashmap< string, string > &  t) [static]

Definition at line 70 of file mathemagix_language.cpp.

                                                               {
  string c= "#2060c0";
  t ("cpp_flags")= c;
  t ("cpp_libs")= c;
  t ("cpp_preamble")= c;
  t ("cpp_macro")= c;
  t ("cpp_include")= c;
  t ("true")= c;
  t ("false")= c;
  t ("mmout")= c;
  t ("mmin")= c;
  t ("mmerr")= c;
  t ("blank")= c;
  t ("stroke")= c;
  t ("indent")= c;
  t ("unindent")= c;
  t ("lf")= c;
  t ("hrule")= c;
  t ("flush_now")= c;
  t ("nil")= c;
}

Here is the caller graph for this function:

static void mathemagix_color_setup_keywords ( hashmap< string, string > &  t) [static]

Definition at line 93 of file mathemagix_language.cpp.

                                                               {
  string c= "#8020c0"; string d= "modifier"; string e= "class";
  t ("abstract")= c;
  t ("alias")= c;
  t ("and")= c;
  t ("assume")= d;
  t ("begin")= c;
  t ("break")= c;
  t ("case")= c;
  t ("cast")= c;
  t ("catch")= c;
  t ("category")= e;
  t ("class")= e;
  t ("concrete")= c;
  t ("constant")= c;
  t ("constructor")= c;
  t ("continue")= c;
  t ("convert")= c;
  t ("debugger")= c;
  t ("destructor")= c;
  t ("direct")= c;
  t ("div")= c;
  t ("do")= c;
  t ("downto")= c;
  t ("downgrade")= c;
  t ("else")= c;
  t ("evolutive")= c;
  t ("exists")= d;
  t ("explode")= c;
  t ("export")= d;
  t ("extend")= c;
  t ("extern")= c;
  t ("for")= c;
  t ("forall")= d;
  t ("foreach")= c;
  t ("foreign")= c;
  t ("from")= c;
  t ("fuse")= c;
  t ("generate")= c;
  t ("has")= c;
  t ("help")= c;
  t ("hidden")= c;
  t ("holds")= c;
  t ("if")= c;
  t ("import")= c;
  t ("in")= c;
  t ("include")= c;
  t ("indirect")= c;
  t ("infix")= c;
  t ("inherit")= c;
  t ("inline")= d;
  t ("inplace")= c;
  t ("interactive")= c;
  t ("intern")= c;
  t ("join")= c;
  t ("keyword")= c;
  t ("literal")= c;
  t ("lambda")= c;
  t ("literal_integer")= c;
  t ("literal_floating")= c;
  t ("literal_string")= c;
  t ("literal_constant")= c;
  t ("locked")= c;
  t ("loop")= c;
  t ("macro")= c;
  t ("map")= c;
  t ("melt")= c;
  t ("method")= c;
  t ("mod")= c;
  t ("module")= e;
  t ("mutable")= c;
  t ("operator")= c;
  t ("or")= c;
  t ("packed")= c;
  t ("penalty")= c;
  t ("postfix")= "postfix";
  t ("prefer")= c;
  t ("prefix")= c;
  t ("private")= c;
  t ("protected")= c;
  t ("public")= c;
  t ("outline")= c;
  t ("quit")= c;
  t ("quo")= c;
  t ("raise")= c;
  t ("rem")= c ;
  t ("require")= c;
  t ("return")= c ;
  t ("sequel")= c;
  t ("split")= c;
  t ("step")= c;
  t ("supports?")= c;
  t ("then")= c;
  t ("this")= c;
  t ("to")= c;
  t ("try")= c;
  t ("type")= c;
  t ("unpacked")= c;
  t ("until")= c;
  t ("upgrade")= c;
  t ("use")= c;
  t ("value")= c;
  t ("while")= c;
  t ("with")= c;
  t ("xor")= c;
}

Here is the caller graph for this function:

static void mathemagix_color_setup_otherlexeme ( hashmap< string, string > &  t) [static]

Definition at line 201 of file mathemagix_language.cpp.

                                                                {
  string c= "black";
  t ("==<gtr>")= c; 
  t ("==")= c;
  t (":=")= c;
  t ("+=")= c;
  t ("-=")= c; 
  t ("*=")= c;
  t ("/=")= c;
  t (":=<gtr>")= c;
  t (":-<gtr>")= c;
  t ("yield")= c;   
  t (",")= c;
  t (";")= c;
  t (")")= c;
  t ("[")= c;
  t ("]")= c;
  t ("{")= c;
  t ("}")= c;
  t ("<less><less>")= c;
  t ("<less><less>*")= c;
  t ("<less><less>%")= c;
  t ("<gtr><gtr>")= c;
  t ("|")= c;
}

Here is the caller graph for this function:

static void parse_alpha ( string  s,
int &  pos 
) [static]

Definition at line 267 of file mathemagix_language.cpp.

                                 {
  static hashmap<string,string> empty;
  parse_identifier (empty, s, pos, false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_backquote ( string  s,
int &  pos 
) [static]

Definition at line 440 of file mathemagix_language.cpp.

                                      {
  if (pos>=N(s)) return;
  if (s[pos]=='\047') pos++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_blanks ( string  s,
int &  pos 
) [static]

Definition at line 273 of file mathemagix_language.cpp.

                                  {
  while (pos<N(s) && (s[pos]==' ' || s[pos]=='\t')) pos++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_class ( hashmap< string, string > &  t,
string  s,
int &  pos 
) [static]

Definition at line 320 of file mathemagix_language.cpp.

                                                            {
  int i= pos;
  if (pos>=N(s)) return;
  if (is_number (s[i])) return;
  while ((i<N(s)) && belongs_to_identifier (s[i])) i++;
  string r= s (pos, i);
  if (t->contains (r) && t(r)=="class") { pos=i; return; }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_comment ( string  s,
int &  pos 
) [static]

Definition at line 395 of file mathemagix_language.cpp.

                                   {
  if (pos>=N(s)) return;
  if (s[pos]!='/') return;
  if (pos+1<N(s) && s[pos+1]=='/') {pos=N(s);return;}
  if (pos+1<N(s) && s[pos+1]=='{') {
    pos= pos+2;
    while ((pos<N(s) && s[pos]!='}') || (pos+1<N(s) && s[pos+1]!='/')) pos++;
    pos= min(pos+2,N(s));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_constant ( hashmap< string, string > &  t,
string  s,
int &  pos 
) [static]

Definition at line 341 of file mathemagix_language.cpp.

                                                               {
  int i=pos;
  if (pos>=N(s)) return;
  if (is_number (s[i])) return;
  while ((i<N(s)) && belongs_to_identifier (s[i])) i++;
  string r= s (pos, i);
  if (t->contains (r) && t(r)=="#2060c0") { pos=i; return; }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_declare_function ( string  s,
int &  pos 
) [static]

Definition at line 446 of file mathemagix_language.cpp.

                                            {
  if (pos+1>=N(s)) return;
  if (s[pos]==':' && s[pos+1]=='=') { pos=pos+2; return; }
  if (s[pos]=='=' && s[pos+1]=='=') { pos=pos+2; return; }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_declare_macro ( string  s,
int &  pos 
) [static]

Definition at line 453 of file mathemagix_language.cpp.

                                         {
  if (test(s,pos,"==<gtr>")) { pos=pos+7; return; }
  if (test(s,pos,":=<gtr>")) { pos=pos+7; return; }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_declare_type ( string  s,
int &  pos 
) [static]

Definition at line 385 of file mathemagix_language.cpp.

                                        {
  if (pos>=N(s)) return;
  if (s[pos]!=':') return;
  if (pos+1<N(s) && s[pos+1]=='=') return;
  pos++;
  if (!test (s, pos, "<gtr>")) return;
  pos+=5;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_end_comment ( string  s,
int &  pos 
) [static]

Definition at line 407 of file mathemagix_language.cpp.

                                       {
  if (pos+1<N(s) && s[pos]=='}' && s[pos+1]=='/') pos=pos+2; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_identifier ( hashmap< string, string > &  t,
string  s,
int &  pos,
bool  postfix 
) [static]

Definition at line 241 of file mathemagix_language.cpp.

                                                  {
  int i=pos;
  if (pos>=N(s)) return;
  if (is_number (s[i])) return;
  if (postfix && s[i]=='.') i++;
  while (i<N(s) && belongs_to_identifier (s[i])) i++;
  if (!(t->contains (s (pos, i)))) pos= i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_identifier_or_markup ( hashmap< string, string > &  t,
string  s,
int &  pos,
bool  postfix,
bool &  is_markup 
) [static]

Definition at line 252 of file mathemagix_language.cpp.

                                                                   {
  int i=pos;
  is_markup= false;
  if (pos>=N(s)) return;
  if (is_number (s[i])) return;
  if (postfix && s[i]=='.') i++;
  while (i<N(s) && belongs_to_identifier (s[i])) {
    if (s[i]=='$') is_markup= true;
    i++;
  }
  if (!(t->contains (s (pos, i)))) pos= i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_keyword ( hashmap< string, string > &  t,
string  s,
int &  pos 
) [static]

Definition at line 300 of file mathemagix_language.cpp.

                                                              {
  int i= pos;
  if (pos>=N(s)) return;
  if (is_number (s[i])) return;
  while ((i<N(s)) && belongs_to_identifier (s[i])) i++;
  string r= s (pos, i);
  if (t->contains (r) && t(r)=="#8020c0") { pos=i; return; }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_modifier ( hashmap< string, string > &  t,
string  s,
int &  pos 
) [static]

Definition at line 310 of file mathemagix_language.cpp.

                                                               {
  int i= pos;
  if (pos>=N(s)) return;
  if (is_number (s[i])) return;
  while ((i<N(s)) && belongs_to_identifier (s[i])) i++;
  string r= s (pos, i);
  if (t->contains (r) && t(r)=="modifier") { pos=i; return; }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_no_declare_type ( string  s,
int &  pos 
) [static]

Definition at line 380 of file mathemagix_language.cpp.

                                           {
  if (pos+1<N(s) && s[pos]==':' && s[pos+1]==':') pos=pos+2;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_number ( string  s,
int &  pos 
) [static]

Definition at line 361 of file mathemagix_language.cpp.

                                  {
  int i= pos;
  if (pos>=N(s)) return;
  if (s[i] == '.') return;
  while (i<N(s) && 
        (is_number (s[i]) ||
         (s[i] == '.' && (i+1<N(s)) &&
          (is_number (s[i+1]) ||
           s[i+1] == 'e' || s[i+1] == 'E')))) i++;
  if (i == pos) return;
  if (i<N(s) && (s[i] == 'e' || s[i] == 'E')) {
    i++;
    if (i<N(s) && s[i] == '-') i++;
    while (i<N(s) && (is_number (s[i]))) i++;
  }
  pos= i;
}

Here is the call graph for this function:

static void parse_other_lexeme ( hashmap< string, string > &  t,
string  s,
int &  pos 
) [static]

Definition at line 351 of file mathemagix_language.cpp.

                                                                   {
  int i;
  for (i=12; i>=1; i--) {
    string r=s(pos,pos+i);
    if (t->contains(r) && t(r)=="black") {
      pos=pos+i; return; }
  }
}

Here is the caller graph for this function:

static void parse_parenthesized ( string  s,
int &  pos 
) [static]

Definition at line 413 of file mathemagix_language.cpp.

                                         {
  int i=pos;
  if (pos>=N(s)) return;
  if (s[i]!='(') return;
  int nbpar=0;
  while(i<N(s)) {
    switch (s[i]) {
    case '(':
      nbpar++;break;
    case ')':if (nbpar>0) nbpar--;
      if (nbpar==0) {i++;pos=i;return;}
      break;
    case '/':
      if (i+1<N(s) && 
         (s[i+1]=='\042' || s[i+1]=='{' || s[i+1]=='/')) {
       pos= i; return; }
      break;
    case '\042':
      pos=i;
      return;
    }
    i++;
  }
  pos=i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_postfix ( hashmap< string, string > &  t,
string  s,
int &  pos 
) [static]

Definition at line 331 of file mathemagix_language.cpp.

                                                              {
  int i= pos;
  if (pos>=N(s)) return;
  if (is_number (s[i])) return;
  while ((i<N(s)) && belongs_to_identifier (s[i])) i++;
  string r= s (pos, i);
  if (t->contains (r) && t(r)=="postfix") { pos=i; return; }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_string ( string  s,
int &  pos 
) [static]

Definition at line 278 of file mathemagix_language.cpp.

                                  {
  if (pos>=N(s)) return;
  switch (s[pos])  {
  case '\042':
    do pos++;
    while((pos<N(s)) &&
         ((s[pos-1]=='\\' && s[pos]=='\042') || s[pos]!='\042'));
    if (s[pos]=='\042') pos++;
    return;
  case '/':
    if (pos+1<N(s) && s[pos+1]=='\042') {
      pos=pos+2;
      do {
       if (pos+1<N(s) && s[pos]=='\042' && s[pos+1]=='/') {
         pos=pos+2; return; }
       pos++;
      } while (pos<N(s));
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: