Roxen.git / server / base_server / highlight_pike.pike

version» Context lines:

Roxen.git/server/base_server/highlight_pike.pike:1:   // This file is part of Roxen Webserver.   // Copyright © 1996 - 2000, Roxen IS. - // $Id: highlight_pike.pike,v 1.3 2000/02/20 17:41:33 nilsson Exp $ + // $Id: highlight_pike.pike,v 1.4 2001/03/12 14:09:20 nilsson Exp $      string quote(string s)   {    return replace(s,({ "<", ">", "&", }),({"&lt;", "&gt;", "&amp;" }));   }      string highlight_string(string s,mapping m)   {    if(m->dark) -  return "<i><font color=darkred>"+quote(s)+"</font></i>"; +  return "<i><font color='darkred'>"+quote(s)+"</font></i>";    else -  return "<i><font color=skyblue>"+quote(s)+"</font></i>"; +  return "<i><font color='skyblue'>"+quote(s)+"</font></i>";   }      string highlight_comment(string s, mapping m)   {    if(m->dark) -  return ("<font color=red>"+quote(s)+"</font>"); -  return ("<font color=yellow>"+quote(s)+"</font>"); +  return ("<font color='red'>"+quote(s)+"</font>"); +  return ("<font color='yellow'>"+quote(s)+"</font>");   }      string highlight_keyword(string s, mapping m)   { -  if(m->dark) return ("<b><font color=darkblue>"+quote(s)+"</font></b>"); -  return ("<b><font color=lightblue>"+quote(s)+"</font></b>"); +  if(m->dark) return ("<b><font color='darkblue'>"+quote(s)+"</font></b>"); +  return ("<b><font color='lightblue'>"+quote(s)+"</font></b>");   }      string highlight_type(string s, mapping m)   { -  if(m->dark) return ("<b><font color=darkgreen>"+quote(s)+"</font></b>"); -  return ("<b><font color=lightgreen>"+quote(s)+"</font></b>"); +  if(m->dark) return ("<b><font color='darkgreen'>"+quote(s)+"</font></b>"); +  return ("<b><font color='lightgreen'>"+quote(s)+"</font></b>");   }      string highlight_pre(string s, mapping m)   {    if(m->dark) return ("<font color=brown>"+quote(s)+"</font>"); -  return ("<font color=pink>"+quote(s)+"</font>"); +  return ("<font color='pink'>"+quote(s)+"</font>");   }      string highlight_declarator(string s, mapping m)   { -  if(m->dark) return ("<b><font color=darkbrown>"+quote(s)+"</font></b>"); -  return ("<b><font color=#ffeeaa>"+quote(s)+"</font></b>"); +  if(m->dark) return ("<b><font color='darkbrown'>"+quote(s)+"</font></b>"); +  return ("<b><font color='#ffeeaa'>"+quote(s)+"</font></b>");   }         string highlight_case(string s, mapping m)   { -  if(m->dark) return ("<font color=black>"+quote(s)+"</font>"); -  return ("<font color=aquamarine>"+quote(s)+"</font>"); +  if(m->dark) return ("<font color='black'>"+quote(s)+"</font>"); +  return ("<font color='aquamarine'>"+quote(s)+"</font>");   }      constant keywords=({"foreach","break","constant","catch","gauge","class","continue","do","else","for","foreach","if","import","inherit","inline","lambda","nomask","private","protected","public","return","static","final", "switch","throw","while",});      constant types=({"mapping","function","multiset","array","object","program","float","int","mixed","string","void"});            array (string) find_decl(string in)   {
Roxen.git/server/base_server/highlight_pike.pike:109:   {    string s,pre,post,decl;    int min=10000000000,i;    string mt;    foreach(types, s)    if(((i=search(in, s))!=-1) && i<min)    {    if(i) switch(in[i-1])    {    default: - // werror("Invalid type thingie: '"+in[i..i]+"'\n"); + // report_debug("Invalid type thingie: '"+in[i..i]+"'\n");    continue;    case ' ':    case '\n':    case '\r':    case '\t':    case '(':    case ')':    }    min = i;    mt = s;
Roxen.git/server/base_server/highlight_pike.pike:134:    if(sscanf(in, "%s"+s+"%s", pre, post)==2)    {    string op = post;    string p="";    sscanf(post, "%[ \t\n\r]%s", p, post);       p += find_complex_type(post);       p = op[..strlen(p)-1];    post = op[strlen(p)..]; - // werror("Found type: '%s' (left: %s)\n", s+p, post-"\n"); + // report_debug("Found type: '%s' (left: %s)\n", s+p, post-"\n");    return ({ pre, s+p, @find_decl(post) });    }   }      array (string) find_keyword(string in)   {    string s,pre,post;    foreach(keywords, s) if(sscanf(in, "%s"+s+"%s", pre, post)==2)    if(!strlen(pre) || pre[-1]==' ' || pre[-1]=='\t' || pre[-1]==':' ||    pre[-1]=='}' || pre[-1]==')' || pre[-1]==';' || pre[-1]=='\n')
Roxen.git/server/base_server/highlight_pike.pike:223:    ({ find_keyword, ({ 0, highlight_keyword }),}),    ({ find_case, ({ 0, highlight_case, 0, highlight_case, }),}),   });      #define push(X) res += X      string highlight_line(string l, mapping m)   {    array p,r;    string res = ""; - // werror(l+"\n"); + // report_debug(l+"\n");    foreach(highlight_patterns, p)    {    if(r=p[0](l))    { - // werror("Match %O (%s, %s)\n", p[-1][-1],(r[..sizeof(p[1])-1]*""), + // report_debug("Match %O (%s, %s)\n", p[-1][-1],(r[..sizeof(p[1])-1]*""),   // (r[sizeof(p[1])..]*""));    for(int i=0; i<sizeof(p[1]) && i<sizeof(r); i++)    if(functionp(p[1][i]))    push(p[1][i](r[i],m));    else    push(highlight_line(r[i],m));    for(int i=sizeof(p[1]); i<sizeof(r); i++)    push(highlight_line(r[i],m));    return res;    }