Compared files  

Left
C:\SDK\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\LexPerl.cxx
Last modified2004-09-28 13:17:26.001 +0200
Size28.4 Kb (982 Lines)
EncodingLatin 1 - ANSI (CP1252) default
Right
C:\SDK\wxWidgets-2.6.3\contrib\src\stc\scintilla\src\LexPerl.cxx
Last modified2006-03-16 13:07:08.000 +0100
Size40.3 Kb (1233 Lines)
EncodingLatin 1 - ANSI (CP1252) default


   Comparison Statistics  

Detailed Statistics

All Changes
 BlocksLines
Unchanged67858
Inserted35134
Deleted422
Ignored00
Changed27343



   Comparison Details  

1 skipped line
2U2U/** @file LexPerl.cxx
3U3U ** Lexer for subset of Perl.
4U4U **/
5C// Lexical analysis fixes by Kein-Hong Man <mkh@pl.jaring.my> 2003-2004 5C// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
6C// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org> 6C// Lexical analysis fixes by Kein-Hong Man <mkh@pl.jaring.my>
7U7U// The License.txt file describes the conditions under which this software may be distributed.
8U8U 
9U9U#include <stdlib.h>
10 skipped lines
20U20U#include "Scintilla.h"
21U21U#include "SciLexer.h"
22U22U 
23C#define PERLNUM_DECIMAL 1 23C#define PERLNUM_BINARY 1    // order is significant: 1-4 cannot have a dot
24C#define PERLNUM_NON_DEC 2 24C#define PERLNUM_HEX 2
25C#define PERLNUM_FLOAT 3 25C#define PERLNUM_OCTAL 3
26C#define PERLNUM_VECTOR 4 26C#define PERLNUM_FLOAT 4     // actually exponent part
  27C#define PERLNUM_DECIMAL 5   // 1-5 are numbers; 6-7 are strings
  28C#define PERLNUM_VECTOR 6
27C#define PERLNUM_V_VECTOR 5 29C#define PERLNUM_V_VECTOR 7
  30C#define PERLNUM_BAD 8
  31C 
  32C#define BACK_NONE 0         // lookback state for bareword disambiguation:
  33C#define BACK_OPERATOR 1     // whitespace/comments are insignificant
  34C#define BACK_KEYWORD 2      // operators/keywords are needed for disambiguation
28U35U 
29U36U#define HERE_DELIM_MAX 256
30U37U 
13 skipped lines
44U51U            ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
45U52U            ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
46U53U            ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
47C            ch == '>' || ch == ',' ||  54C            ch == '>' || ch == ',' ||
48U55U            ch == '?' || ch == '!' || ch == '.' || ch == '~')
49U56U        return true;
50U57U    // these chars are already tested before this call
1 skipped line
52U59U    return false;
53U60U}
54U61U 
55Cstatic int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { 62Cstatic bool isPerlKeyword(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
56U63U    char s[100];
57C    for (unsigned int i = 0; i < end - start + 1 && i < 30i++) { 64C    unsigned int i, len = end - start;
  65C    if (len > 30) { len = 30; }
58C        s[i] = styler[start + i]; 66C    for (i = 0; i < len; i++, start++) s[i] = styler[start];
59C        s[i + 1] = '\0'; 67C    s[i] = '\0';
60C    }  
61C    char chAttr = SCE_PL_IDENTIFIER;  
62C    if (keywords.InList(s)) 68C    return keywords.InList(s);
63C        chAttr = SCE_PL_WORD;  
64C    styler.ColourTo(end, chAttr);  
65C    return chAttr;  
66U69U}
67U70U 
68U71Ustatic inline bool isEndVar(char ch) {
7 skipped lines
76U79U}
77U80U 
78U81Ustatic inline char actualNumStyle(int numberStyle) {
79C    switch (numberStyle) {  
80C    case PERLNUM_VECTOR:  
81C    case PERLNUM_V_VECTOR: 82C    if (numberStyle == PERLNUM_VECTOR || numberStyle == PERLNUM_V_VECTOR) {
82C        return SCE_PL_STRING; 83C        return SCE_PL_STRING;
83C    case PERLNUM_DECIMAL:  
84C    case PERLNUM_NON_DEC: 84C    } else if (numberStyle == PERLNUM_BAD) {
85C    case PERLNUM_FLOAT: 85C        return SCE_PL_ERROR;
86C    default: 86C    }
87C        return SCE_PL_NUMBER; 87C    return SCE_PL_NUMBER;
88C    }  
89U88U}
90U89U 
91U90Ustatic bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
41 skipped lines
133U132U        char *Delimiter;// the Delimiter, 256: sizeof PL_tokenbuf
134U133U        HereDocCls() {
135U134U        State = 0;
  135A            Quote = 0;
  136A            Quoted = false;
136U137U        DelimiterLength = 0;
137U138U        Delimiter = new char[HERE_DELIM_MAX];
138U139U        Delimiter[0] = '\0';
57 skipped lines
196U197U    || state == SCE_PL_CHARACTER
197U198U    || state == SCE_PL_NUMBER
198U199U    || state == SCE_PL_IDENTIFIER
  200A    || state == SCE_PL_ERROR
199U201U    ) {
200U202U        while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
201U203U        startPos--;
1 skipped line
203U205U        state = SCE_PL_DEFAULT;
204U206U    }
205U207U 
  208A    // lookback at start of lexing to set proper state for backflag
  209A    // after this, they are updated when elements are lexed
  210A    int backflag = BACK_NONE;
  211A    unsigned int backPos = startPos;
  212A    if (backPos > 0) {
6 skipped lines
  219A            backflag = BACK_OPERATOR;
  220A        else if (sty == SCE_PL_WORD)
  221A            backflag = BACK_KEYWORD;
  222A    }
  223A 
206U224U    styler.StartAt(startPos);
207U225U    char chPrev = styler.SafeGetCharAt(startPos - 1);
208U226U    if (startPos == 0)
60 skipped lines
269U287U        if (isdigit(ch) || (isdigit(chNext) &&
270U288U        (ch == '.' || ch == 'v'))) {
271U289U        state = SCE_PL_NUMBER;
  290A                backflag = BACK_NONE;
272U291U        numState = PERLNUM_DECIMAL;
273U292U        dotCount = 0;
274U293U        if (ch == '0') {// hex,bin,octal
  294C        if (chNext == 'x') {
  295C        numState = PERLNUM_HEX;
  296C        } else if (chNext == 'b') {
  297C                        numState = PERLNUM_BINARY;
275C        if (chNext == 'x' || chNext == 'b' || isdigit(chNext)) { 298C                    } else if (isdigit(chNext)) {
276C        numState = PERLNUM_NON_DEC; 299C                        numState = PERLNUM_OCTAL;
  300C                    }
  301C                    if (numState != PERLNUM_DECIMAL) {
  302C        i++;
  303C        ch = chNext;
  304C        chNext = chNext2;
277C        } 305C                    }
278U306U        } else if (ch == 'v') {   // vector
279U307U        numState = PERLNUM_V_VECTOR;
280U308U        }
281U309U        } else if (iswordstart(ch)) {
  310C                // if immediately prefixed by '::', always a bareword
  311C                state = SCE_PL_WORD;
282C        if (chPrev == '>' && styler.SafeGetCharAt(i - 2) == '-') { 312C                if (chPrev == ':' && styler.SafeGetCharAt(i - 2) == ':') {
283C        state = SCE_PL_IDENTIFIER;  // part of "->" expr 313C                    state = SCE_PL_IDENTIFIER;
284C        if ((!iswordchar(chNext) && chNext != '\'') 314C                }
285C        || (chNext == '.' && chNext2 == '.')) { 315C                unsigned int kw = i + 1;
286C        // We need that if length of word == 1! 316C                // first check for possible quote-like delimiter
287C        styler.ColourTo(i, SCE_PL_IDENTIFIER);  
288C        state = SCE_PL_DEFAULT;  
289C        }  
290C        } else if (ch == 's' && !isNonQuote(chNext)) { 317C        if (ch == 's' && !isNonQuote(chNext)) {
291U318U        state = SCE_PL_REGSUBST;
292U319U        Quote.New(2);
293U320U        } else if (ch == 'm' && !isNonQuote(chNext)) {
8 skipped lines
302U329U        } else if (ch == 't' && chNext == 'r' && !isNonQuote(chNext2)) {
303U330U        state = SCE_PL_REGSUBST;
304U331U        Quote.New(2);
305C        i++; 332C                    kw++;
306C        chNext = chNext2;  
307U333U        } else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isNonQuote(chNext2)) {
308U334U        if      (chNext == 'q') state = SCE_PL_STRING_QQ;
309U335U        else if (chNext == 'x') state = SCE_PL_STRING_QX;
310U336U        else if (chNext == 'r') state = SCE_PL_STRING_QR;
311U337U        else if (chNext == 'w') state = SCE_PL_STRING_QW;
312R        i++;  
313R        chNext = chNext2;  
314U338U        Quote.New(1);
  339A                    kw++;
315U340U        } else if (ch == 'x' && (chNext == '=' || // repetition
316C           (chNext != '_' && !isalnum(chNext)) || 341C                           (chNext != '_' && !isalnum(chNext)) ||
317C           (isdigit(chPrev) && isdigit(chNext)))) { 342C                           (isdigit(chPrev) && isdigit(chNext)))) {
318C        styler.ColourTo(i, SCE_PL_OPERATOR); 343C                    state = SCE_PL_OPERATOR;
319C        } else { 344C                }
320C        state = SCE_PL_WORD; 345C                // if potentially a keyword, scan forward and grab word, then check
321C        if ((!iswordchar(chNext) && chNext != '\'') 346C                // if it's really one; if yes, disambiguation test is performed
322C        || (chNext == '.' && chNext2 == '.')) { 347C                // otherwise it is always a bareword and we skip a lot of scanning
323C        // We need that if length of word == 1! 348C                // note: keywords assumed to be limited to [_a-zA-Z] only
324C        // This test is copied from the SCE_PL_WORD handler. 349C                if (state == SCE_PL_WORD) {
  350C                    while (iswordstart(styler.SafeGetCharAt(kw))) kw++;
325C        classifyWordPerl(styler.GetStartSegment(), i, keywords, styler); 351C                    if (!isPerlKeyword(styler.GetStartSegment(), kw, keywords, styler)) {
326C        state = SCE_PL_DEFAULT; 352C                        state = SCE_PL_IDENTIFIER;
327C        } 353C                    }
  354C                }
  355C                // if already SCE_PL_IDENTIFIER, then no ambiguity, skip this
  356C                // for quote-like delimiters/keywords, attempt to disambiguate
  357C                // to select for bareword, change state -> SCE_PL_IDENTIFIER
  358C                if (state != SCE_PL_IDENTIFIER && i > 0) {
  359C                    unsigned int j = i;
  360C                    bool moreback = false;      // true if passed newline/comments
  361C                    bool brace = false;         // true if opening brace found
  362C                    char ch2;
  363C                    // first look backwards past whitespace/comments for EOLs
63 skipped lines
  427C                    ch = styler.SafeGetCharAt(i);
  428C                    chNext = styler.SafeGetCharAt(i + 1);
  429C                // a repetition operator 'x'
  430C                } else if (state == SCE_PL_OPERATOR) {
  431C                    styler.ColourTo(i, SCE_PL_OPERATOR);
  432C                    state = SCE_PL_DEFAULT;
  433C                // quote-like delimiter, skip one char if double-char delimiter
  434C                } else {
  435C                    i = kw - 1;
  436C                    chNext = styler.SafeGetCharAt(i + 1);
328C        } 437C                }
329U438U        } else if (ch == '#') {
330U439U        state = SCE_PL_COMMENTLINE;
331U440U        } else if (ch == '\"') {
332U441U        state = SCE_PL_STRING;
333U442U        Quote.New(1);
334U443U        Quote.Open(ch);
  444A                backflag = BACK_NONE;
335U445U        } else if (ch == '\'') {
336U446U        if (chPrev == '&') {
337U447U        // Archaic call
3 skipped lines
341U451U        Quote.New(1);
342U452U        Quote.Open(ch);
343U453U        }
  454A                backflag = BACK_NONE;
344U455U        } else if (ch == '`') {
345U456U        state = SCE_PL_BACKTICKS;
346U457U        Quote.New(1);
347U458U        Quote.Open(ch);
  459A                backflag = BACK_NONE;
348U460U        } else if (ch == '$') {
349U461U        if ((chNext == '{') || isspacechar(chNext)) {
350U462U        styler.ColourTo(i, SCE_PL_SCALAR);
9 skipped lines
360U472U        chNext = chNext2;
361U473U        }
362U474U        }
  475A                backflag = BACK_NONE;
363U476U        } else if (ch == '@') {
364U477U        if (isalpha(chNext) || chNext == '#' || chNext == '$'
365C            || chNext == '_' || chNext == '+') { 478C        || chNext == '_' || chNext == '+' || chNext == '-'{
366U479U        state = SCE_PL_ARRAY;
367U480U        } else if (chNext != '{' && chNext != '[') {
368U481U        styler.ColourTo(i, SCE_PL_ARRAY);
369R        i++;  
370R        ch = ' ';  
371U482U        } else {
372U483U        styler.ColourTo(i, SCE_PL_ARRAY);
373U484U        }
  485A                backflag = BACK_NONE;
374U486U        } else if (ch == '%') {
375C        if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') { 487C        if (isalpha(chNext) || chNext == '#' || chNext == '$'
  488C                    || chNext == '_' || chNext == '!' || chNext == '^'{
376U489U        state = SCE_PL_HASH;
  490A                    i++;
  491A                    ch = chNext;
  492A                    chNext = chNext2;
377U493U        } else if (chNext == '{') {
378U494U        styler.ColourTo(i, SCE_PL_HASH);
379U495U        } else {
380U496U        styler.ColourTo(i, SCE_PL_OPERATOR);
381U497U        }
  498A                backflag = BACK_NONE;
382U499U        } else if (ch == '*') {
  500C                char strch[2];
  501C                strch[0] = chNext;
  502C                strch[1] = '\0';
383C        if (isalpha(chNext) || chNext == '_' || chNext == '{') { 503C        if (isalpha(chNext) || chNext == '_' ||
  504C                    NULL != strstr("^/|,\\\";#%^:?<>)[]", strch)) {
384U505U        state = SCE_PL_SYMBOLTABLE;
  506A                    i++;
  507A                    ch = chNext;
  508A                    chNext = chNext2;
  509A        } else if (chNext == '{') {
  510A        styler.ColourTo(i, SCE_PL_SYMBOLTABLE);
385U511U        } else {
386U512U        if (chNext == '*') {// exponentiation
387U513U        i++;
2 skipped lines
390U516U        }
391U517U        styler.ColourTo(i, SCE_PL_OPERATOR);
392U518U        }
  519C                backflag = BACK_NONE;
393C        } else if (ch == '/') { 520C        } else if (ch == '/' || (ch == '<' && chNext == '<')) {
394U521U        // Explicit backward peeking to set a consistent preferRE for
395U522U        // any slash found, so no longer need to track preferRE state.
396U523U        // Find first previous significant lexed element and interpret.
  524A                // Test for HERE doc start '<<' shares this code, helps to
  525A                // determine if it should be an operator.
397U526U        bool preferRE = false;
  527A                bool isHereDoc = (ch == '<');
  528A                bool hereDocSpace = false;      // these are for corner case:
  529A                bool hereDocScalar = false;     // SCALAR [whitespace] '<<'
398U530U        unsigned int bk = (i > 0)? i - 1: 0;
399U531U        char bkch;
400U532U        styler.Flush();
  533A                if (styler.StyleAt(bk) == SCE_PL_DEFAULT)
  534A                    hereDocSpace = true;
401U535U        while ((bk > 0) && (styler.StyleAt(bk) == SCE_PL_DEFAULT ||
402U536U        styler.StyleAt(bk) == SCE_PL_COMMENTLINE)) {
403U537U        bk--;
90 skipped lines
494U628U        bk--;
495U629U        }
496U630U        break;
  631A                    case SCE_PL_SCALAR:     // for $var<< case
  632A                        hereDocScalar = true;
  633A                        break;
497U634U        // other styles uses the default, preferRE=false
498U635U        case SCE_PL_WORD:
499U636U        case SCE_PL_POD:
  637A        case SCE_PL_POD_VERB:
500U638U        case SCE_PL_HERE_Q:
501U639U        case SCE_PL_HERE_QQ:
502U640U        case SCE_PL_HERE_QX:
1 skipped line
504U642U        break;
505U643U        }
506U644U        }
  645C                if (isHereDoc) {    // handle HERE doc
  646C                    // if SCALAR whitespace '<<', *always* a HERE doc
507C        if (preferRE) { 647C                    if (preferRE || (hereDocSpace && hereDocScalar)) {
508C        state = SCE_PL_REGEX; 648C                        state = SCE_PL_HERE_DELIM;
509C        Quote.New(1); 649C                        HereDoc.State = 0;
510C        Quote.Open(ch);  
511C        } else { 650C                    } else {        // << operator
  651C        i++;
  652C        ch = chNext;
  653C        chNext = chNext2;
512C        styler.ColourTo(i, SCE_PL_OPERATOR); 654C                        styler.ColourTo(i, SCE_PL_OPERATOR);
513C        } 655C                    }
514C        } else if (ch == '<' && chNext == '<') { 656C                } else {            // handle regexp
  657C                    if (preferRE) {
515C        state = SCE_PL_HERE_DELIM; 658C                        state = SCE_PL_REGEX;
  659C                        Quote.New(1);
  660C                        Quote.Open(ch);
  661C                    } else {        // / operator
  662C                        styler.ColourTo(i, SCE_PL_OPERATOR);
  663C                    }
  664C                }
516C        HereDoc.State = 0; 665C                backflag = BACK_NONE;
517U666U        } else if (ch == '<') {
518U667U        // looks forward for matching > on same line
519U668U        unsigned int fw = i + 1;
520U669U        while (fw < lengthDoc) {
521U670U        char fwch = styler.SafeGetCharAt(fw);
  671C        if (fwch == ' ') {
  672C        if (styler.SafeGetCharAt(fw-1) != '\\' ||
  673C            styler.SafeGetCharAt(fw-2) != '\\')
  674C        break;
522C        if (isEOLChar(fwch) || isspacechar(fwch)) 675C        } else if (isEOLChar(fwch) || isspacechar(fwch)) {
523U676U        break;
524C        else if (fwch == '>') { 677C        else if (fwch == '>') {
525U678U        if ((fw - i) == 2 &&// '<=>' case
526U679U            styler.SafeGetCharAt(fw-1) == '=') {
527U680U        styler.ColourTo(fw, SCE_PL_OPERATOR);
7 skipped lines
535U688U        fw++;
536U689U        }
537U690U        styler.ColourTo(i, SCE_PL_OPERATOR);
  691A                backflag = BACK_NONE;
538U692U        } else if (ch == '='// POD
539U693U                   && isalpha(chNext)
540U694U                   && (isEOLChar(chPrev))) {
541U695U        state = SCE_PL_POD;
  696A                backflag = BACK_NONE;
542U697U        //sookedpos = 0;
543U698U        //sooked[sookedpos] = '\0';
544U699U        } else if (ch == '-'// file test operators
4 skipped lines
549U704U        i++;
550U705U        ch = chNext;
551U706U        chNext = chNext2;
  707A                backflag = BACK_NONE;
552U708U        } else if (isPerlOperator(ch)) {
553U709U        if (ch == '.' && chNext == '.') { // .. and ...
554U710U        i++;
3 skipped lines
558U714U        chNext = styler.SafeGetCharAt(i + 1);
559U715U        }
560U716U        styler.ColourTo(i, SCE_PL_OPERATOR);
  717A                backflag = BACK_OPERATOR;
  718A                backPos = i;
561U719U        } else {
562U720U        // keep colouring defaults to make restart easier
563U721U        styler.ColourTo(i, SCE_PL_DEFAULT);
3 skipped lines
567U725U        if (chNext == '.') {
568U726U        // double dot is always an operator
569U727U        goto numAtEnd;
570C        } else if (numState == PERLNUM_NON_DEC || numState == PERLNUM_FLOAT) { 728C        } else if (numState <= PERLNUM_FLOAT) {
571U729U        // non-decimal number or float exponent, consume next dot
572U730U        styler.ColourTo(i - 1, SCE_PL_NUMBER);
573U731U        styler.ColourTo(i, SCE_PL_OPERATOR);
20 skipped lines
594U752U        if (numState == PERLNUM_VECTOR || numState == PERLNUM_V_VECTOR) {
595U753U        if (isalpha(ch)) {
596U754U        if (dotCount == 0) { // change to word
597C        state = SCE_PL_WORD; 755C        state = SCE_PL_IDENTIFIER;
598U756U        } else { // vector then word
599U757U        goto numAtEnd;
600U758U        }
13 skipped lines
614U772U        if (!isdigit(ch)) { // float then word
615U773U        goto numAtEnd;
616U774U        }
  775C        } else if (numState == PERLNUM_OCTAL) {
  776C                    if (!isdigit(ch))
  777C                        goto numAtEnd;
  778C                    else if (ch > '7')
  779C                        numState = PERLNUM_BAD;
617C        } else {// (numState == PERLNUM_NON_DEC) 780C                } else if (numState == PERLNUM_BINARY) {
618C        // allow alphanum for bin,hex,oct for now 781C                    if (!isdigit(ch))
619C        } 782C                        goto numAtEnd;
  783C                    else if (ch > '1')
  784C                        numState = PERLNUM_BAD;
  785C                } else if (numState == PERLNUM_HEX) {
  786C                    int ch2 = toupper(ch);
  787C                    if (!isdigit(ch) && !(ch2 >= 'A' && ch2 <= 'F'))
  788C                        goto numAtEnd;
  789C        } else {//(numState == PERLNUM_BAD) {
  790C                    if (!isdigit(ch))
  791C                        goto numAtEnd;
  792C                }
620U793U        } else {
621U794U        // complete current number or vector
622U795U        numAtEnd:
1 skipped line
624U797U        state = SCE_PL_DEFAULT;
625U798U        goto restartLexer;
626U799U        }
627R        } else if (state == SCE_PL_WORD) {  
628R        if ((!iswordchar(chNext) && chNext != '\'')  
629R        || chNext == '.') {  
630R        // ".." is always an operator if preceded by a SCE_PL_WORD.  
631R        // "." never used in Perl variable names  
6 skipped lines
638R        classifyWordPerl(styler.GetStartSegment(), i, keywords, styler);  
639R        state = SCE_PL_DEFAULT;  
640R        ch = ' ';  
641R        }  
642R        }  
643U800U        } else if (state == SCE_PL_IDENTIFIER) {
644C        if ((!iswordchar(chNext) && chNext != '\'') 801C        if (!iswordstart(chNext) && chNext != '\'') {
645C        || chNext == '.') {  
646U802U        styler.ColourTo(i, SCE_PL_IDENTIFIER);
647U803U        state = SCE_PL_DEFAULT;
648U804U        ch = ' ';
36 skipped lines
685U841U        // Whitespace acceptable after <<[-] operator.
686U842U        //
687U843U        if (HereDoc.State == 0) { // '<<' encountered
  844A                    bool gotspace = false;
  845A                    unsigned int oldi = i;
  846A                    if (chNext == ' ' || chNext == '\t') {
  847A                        // skip whitespace; legal for quoted delimiters
  848A                        gotspace = true;
  849A                        do {
  850A                            i++;
  851A                            chNext = styler.SafeGetCharAt(i + 1);
  852A                        } while ((i + 1 < lengthDoc) && (chNext == ' ' || chNext == '\t'));
  853A                        chNext2 = styler.SafeGetCharAt(i + 2);
  854A                    }
688U855U        HereDoc.State = 1;
689U856U        HereDoc.Quote = chNext;
690U857U        HereDoc.Quoted = false;
691U858U        HereDoc.DelimiterLength = 0;
692U859U        HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
693C        if (chNext == '\'' || chNext == '"' || chNext == '`') { // a quoted here-doc delimiter 860C        if (chNext == '\'' || chNext == '"' || chNext == '`') {
  861C                        // a quoted here-doc delimiter
694U862U        i++;
695U863U        ch = chNext;
696U864U        chNext = chNext2;
697U865U        HereDoc.Quoted = true;
698R        } else if (isalpha(chNext) || chNext == '_') {  
699R        // an unquoted here-doc delimiter, no special handling  
700U866U        } else if (isspacechar(chNext) || isdigit(chNext) || chNext == '\\'
701C        || chNext == '=' || chNext == '$' || chNext == '@') { 867C        || chNext == '=' || chNext == '$' || chNext == '@'
  868C                        || ((isalpha(chNext) || chNext == '_') && gotspace)) {
702U869U        // left shift << or <<= operator cases
  870A                        // restore position if operator
  871A                        i = oldi;
703U872U        styler.ColourTo(i, SCE_PL_OPERATOR);
704U873U        state = SCE_PL_DEFAULT;
705U874U        HereDoc.State = 0;
  875A                        goto restartLexer;
706U876U        } else {
  877A        // an unquoted here-doc delimiter, no special handling
  878A                        // (cannot be prefixed by spaces/tabs), or
707U879U        // symbols terminates; deprecated zero-length delimiter
708U880U        }
709U881U 
710U882U        } else if (HereDoc.State == 1) { // collect the delimiter
  883A                    backflag = BACK_NONE;
711U884U        if (HereDoc.Quoted) { // a quoted here-doc delimiter
712U885U        if (ch == HereDoc.Quote) { // closing quote => end of delimiter
713U886U        styler.ColourTo(i, state);
32 skipped lines
746U919U        if (isEOLChar(ch)) {
747U920U        styler.ColourTo(i - 1, state);
748U921U        state = SCE_PL_DEFAULT;
  922A                        backflag = BACK_NONE;
749U923U        HereDoc.State = 0;
750U924U        goto restartLexer;
751U925U        }
752U926U        chNext = styler.SafeGetCharAt(i + 1);
753U927U        }
754C        } else if (state == SCE_PL_POD) { 928C        } else if (state == SCE_PL_POD
  929C        || state == SCE_PL_POD_VERB) {
  930C        if (isEOLChar(chPrev)) {
755C        if (ch == '=' && isEOLChar(chPrev)) { 931C        if (ch == ' ' || ch == '\t') {
  932C        styler.ColourTo(i - 1, state);
  933C        state = SCE_PL_POD_VERB;
  934C        } else {
  935C        styler.ColourTo(i - 1, state);
  936C        state = SCE_PL_POD;
  937C        if (ch == '=') {
756C        if (isMatch(styler, lengthDoc, i, "=cut")) { 938C        if (isMatch(styler, lengthDoc, i, "=cut")) {
757C        styler.ColourTo(i - 1 + 4, state); 939C        styler.ColourTo(i - 1 + 4, state);
758C        i += 4; 940C        i += 4;
759C        state = SCE_PL_DEFAULT; 941C        state = SCE_PL_DEFAULT;
760C        ch = styler.SafeGetCharAt(i); 942C        ch = styler.SafeGetCharAt(i);
761C        //chNext = styler.SafeGetCharAt(i + 1); 943C        //chNext = styler.SafeGetCharAt(i + 1);
762C        goto restartLexer; 944C        goto restartLexer;
  945C        }
  946C        }
763U947U        }
764U948U        }
765U949U        } else if (state == SCE_PL_SCALAR // variable names
6 skipped lines
772U956U        chNext = chNext2;
773U957U        }
774U958U        else if (isEndVar(ch)) {
775C        if ((state == SCE_PL_SCALAR || state == SCE_PL_ARRAY)  
776C            && i == (styler.GetStartSegment() + 1)) { 959C        if (i == (styler.GetStartSegment() + 1)) {
777U960U        // Special variable: $(, $_ etc.
778U961U        styler.ColourTo(i, state);
779U962U        state = SCE_PL_DEFAULT;
137 skipped lines
917U1100U    styler.ColourTo(lengthDoc - 1, state);
918U1101U}
919U1102U 
  1103Astatic bool IsCommentLine(int line, Accessor &styler) {
  1104A    int pos = styler.LineStart(line);
  1105A    int eol_pos = styler.LineStart(line + 1) - 1;
  1106A    for (int i = pos; i < eol_pos; i++) {
  1107A        char ch = styler[i];
4 skipped lines
  1112A        return false;
  1113A    }
  1114A    return false;
  1115A}
  1116A 
920U1117Ustatic void FoldPerlDoc(unsigned int startPos, int length, int, WordList *[],
921U1118U                            Accessor &styler) {
922U1119U    bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
923U1120U    bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
  1121A    // Custom folding of POD and packages
  1122A    bool foldPOD = styler.GetPropertyInt("fold.perl.pod", 1) != 0;
  1123A    bool foldPackage = styler.GetPropertyInt("fold.perl.package", 1) != 0;
924U1124U    unsigned int endPos = startPos + length;
925U1125U    int visibleChars = 0;
926U1126U    int lineCurrent = styler.GetLine(startPos);
  1127C    int levelPrev = SC_FOLDLEVELBASE;
  1128C    if (lineCurrent > 0)
927C    int levelPrev = styler.LevelAt(lineCurrent& SC_FOLDLEVELNUMBERMASK; 1129C        levelPrev = styler.LevelAt(lineCurrent - 1) >> 16;
928U1130U    int levelCurrent = levelPrev;
929U1131U    char chNext = styler[startPos];
  1132A    char chPrev = styler.SafeGetCharAt(startPos - 1);
930U1133U    int styleNext = styler.StyleAt(startPos);
  1134A    // Used at end of line to determine if the line was a package definition
  1135A    bool isPackageLine = false;
  1136A    bool isPodHeading = false;
931U1137U    for (unsigned int i = startPos; i < endPos; i++) {
932U1138U        char ch = chNext;
933U1139U        chNext = styler.SafeGetCharAt(i + 1);
934U1140U        int style = styleNext;
935U1141U        styleNext = styler.StyleAt(i + 1);
936U1142U        bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
937C        if (foldComment && (style == SCE_PL_COMMENTLINE)) { 1143C        bool atLineStart = isEOLChar(chPrev) || i == 0;
  1144C        // Comment folding
938C        if ((ch == '/') && (chNext == '/')) { 1145C        if (foldComment && atEOL && IsCommentLine(lineCurrent, styler))
939C        char chNext2 = styler.SafeGetCharAt(i + 2); 1146C        {
940C        if (chNext2 == '{') { 1147C            if (!IsCommentLine(lineCurrent - 1, styler)
  1148C                && IsCommentLine(lineCurrent + 1, styler))
941C        levelCurrent++; 1149C                levelCurrent++;
942C        } else if (chNext2 == '}') { 1150C            else if (IsCommentLine(lineCurrent - 1, styler)
  1151C                     && !IsCommentLine(lineCurrent+1, styler))
943C        levelCurrent--; 1152C                levelCurrent--;
944C        }  
945C        }  
946C        } 1153C        }
947U1154U        if (style == SCE_C_OPERATOR) {
948U1155U        if (ch == '{') {
949U1156U        levelCurrent++;
1 skipped line
951U1158U        levelCurrent--;
952U1159U        }
953U1160U        }
  1161A        // Custom POD folding
  1162A        if (foldPOD && atLineStart) {
  1163A        int stylePrevCh = (i) ? styler.StyleAt(i - 1):SCE_PL_DEFAULT;
  1164A        if (style == SCE_PL_POD) {
  1165A        if (stylePrevCh != SCE_PL_POD && stylePrevCh != SCE_PL_POD_VERB)
20 skipped lines
  1186A        if (style == SCE_PL_WORD && styler.Match(i, "package")) {
  1187A        isPackageLine = true;
  1188A        }
  1189A        }
  1190A 
954U1191U        if (atEOL) {
955U1192U        int lev = levelPrev;
  1193A        if (isPodHeading) {
  1194A                lev = levelPrev - 1;
  1195A                lev |= SC_FOLDLEVELHEADERFLAG;
  1196A                isPodHeading = false;
  1197A        }
3 skipped lines
  1201A        lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG;
  1202A        levelCurrent = SC_FOLDLEVELBASE + 1;
  1203A        isPackageLine = false;
  1204A        }
  1205A            lev |= levelCurrent << 16;
956U1206U        if (visibleChars == 0 && foldCompact)
957U1207U        lev |= SC_FOLDLEVELWHITEFLAG;
958U1208U        if ((levelCurrent > levelPrev) && (visibleChars > 0))
7 skipped lines
966U1216U        }
967U1217U        if (!isspacechar(ch))
968U1218U        visibleChars++;
  1219A        chPrev = ch;
969U1220U    }
970U1221U    // Fill in the real level of the next line, keeping the current flags as they will be filled in later
971U1222U    int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
11 skipped lines

   Text comparison Options  

Match character case: yes.
Match line endings: no.
Match spaces

At start of lines: yes,
In middle of lines: yes,
At end of lines: yes.
Blank lines as empty lines: no.
Activate comparison algorithm
At word level: yes,
At character level: no.


   Legend  

UExample of unchanged line
CExample of modified line
AExample of added line
RExample of removed line
IExample of ignored line
Modified text
Added text
Removed text

This report has been generated by Ellié Computing Merge on 2006-09-07 16:23:40.001 +0200.
© 2005-2006 Ellié Computing http://www.elliecomputing.com. All rights reserved.