pike.git / lib / modules / Parser.pmod / Pike.pmod

version» Context lines:

pike.git/lib/modules/Parser.pmod/Pike.pmod:1:   //   // This file needs to support old pikes that e.g. don't understand   // "#pike". Some of them fail when they see an unknown cpp directive.   //   // #pike __REAL_VERSION__   // - // $Id: Pike.pmod,v 1.28 2003/01/18 02:13:19 nilsson Exp $ + // $Id: Pike.pmod,v 1.29 2003/01/18 17:55:55 nilsson Exp $      //! This module parses and tokanizes Pike source code.      inherit "C.pmod";      #define UNKNOWN_TOKEN \    error("Unknown pike token: %O\n", data[pos..pos+20])      static mapping(string : int) backquoteops =   (["/":1,
pike.git/lib/modules/Parser.pmod/Pike.pmod:36:   //! tokens. If the optional argument @[state] is provided the split   //! function is able to pause and resume splitting inside #"" and   //! /**/ tokens. The @[state] argument should be an initially empty   //! mapping, in which split will store its state between successive   //! calls.   array(string) split(string data, void|mapping state)   {    int line=1;    array(string) ret=({});    int pos; +  if(data=="") return ({"\n"});    data += "\n\0"; // End sentinel.       if(state && state->in_token) {    switch(state->remains[0..1]) {       case "/*": -  +  if(sizeof(state->remains)>2 && state->remains[-1]=='*' +  && data[0]=='/') { +  ret += ({ state->remains + "/" }); +  pos++; +  m_delete(state, "remains"); +  break; +  }    pos = search(data, "*/");    if(pos==-1) {    state->in_token = 1;    state->remains += data[..sizeof(data)-2];    return ret;    }    ret += ({ state->remains + data[..pos] });    m_delete(state, "remains");    pos+=2;    break;
pike.git/lib/modules/Parser.pmod/Pike.pmod:63:    case "#\"":    int q,s;    pos=-1;    while(1) {    q = search(data,"\"",pos+1);    s = search(data,"\\",pos+1);       if( q==-1 ||    (s==sizeof(data)-2 && s<q) ) {    state->in_token = 1; -  state->remains += data[..sizeof(data)-2]; +  state->remains += data[..sizeof(data)-3];    return ret;    }       if(s==-1 || s>q) {    pos = q+1;    break;    }       pos=s+1;    }
pike.git/lib/modules/Parser.pmod/Pike.pmod:104:    if(data[pos]=='\"') {    int q,s;    while(1) {    q = search(data,"\"",pos+1);    s = search(data,"\\",pos+1);       if( q==-1 ||    (s==sizeof(data)-2 && s<q) ) {    if(state) {    state->in_token = 1; -  state->remains = data[pos-1..sizeof(data)-2]; +  state->remains = data[pos-1..sizeof(data)-3];    return ret;    }    error("Failed to find end of multiline string.\n");    }       if(s==-1 || s>q) {    pos = q+1;    break;    }   
pike.git/lib/modules/Parser.pmod/Pike.pmod:265:    switch(data[pos..pos+1])    {    case "//":    pos=search(data,"\n",pos);    break;       case "/*":    pos=search(data,"*/",pos);    if(pos==-1) {    if(state) { -  state->remains = data[start..sizeof(data)-2]; +  state->remains = data[start..sizeof(data)-3];    state->in_token = 1;    return ret;    }    error("Failed to find end of comment.\n");    }    pos+=2;    break;       case "<<": case ">>":    if(data[pos+2]=='=') pos++;