Changeset 434

Show
Ignore:
Timestamp:
09/27/08 18:02:39 (2 months ago)
Author:
SnakE
Message:

SciLexer?: fix ._ in ident._ident being highlighted as a number

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/scilexer/LexD.cxx

    r433 r434  
    356356}; 
    357357 
     358StatePtr NewMaybeKeyword(std::string beg); 
     359 
    358360struct MaybeFloat : State 
    359361{ 
     362    MaybeFloat(Colourizer dot) : dot(dot) {} 
    360363    virtual int getStyle() const {return SCE_D_OPERATOR;} 
    361364    StatePtr onChar(int ch, Colourizer colourizer) 
    362365    { 
    363         if (IsDecimal(ch, false) || ch == '_') 
    364             return NewDecimalNumber(NumberPart::fractional); 
    365         // simply a dot 
    366         colourizer.colourExcl(SCE_D_OPERATOR); 
    367         return NewDefaultState()->onChar(ch, colourizer); 
    368     } 
     366        if (IsDecimal(ch, false)) 
     367            return NewDecimalNumber(NumberPart::fractional);    // phew, it was a number after all. 
     368        if (ch == '_') 
     369        { 
     370            // it still may be an identifier after a dot 
     371            underscore += ch; 
     372            return StatePtr(new MaybeFloat(*this)); 
     373        } 
     374        // dot was a dot, and the rest is either an ident or a keyword 
     375        dot.colourIncl(SCE_D_OPERATOR); 
     376        return NewMaybeKeyword(underscore)->onChar(ch, colourizer); 
     377    } 
     378private: 
     379    Colourizer dot; 
     380    std::string underscore; 
    369381}; 
    370382 
     
    755767struct MaybeKeyword : State 
    756768{ 
     769    MaybeKeyword(std::string beg = std::string()) : keyword(beg) {} 
    757770    virtual int getStyle() const {return SCE_D_IDENT;} 
    758771    virtual StatePtr onChar(int ch, Colourizer colourizer) 
     
    785798}; 
    786799 
     800StatePtr NewMaybeKeyword(std::string beg) 
     801{ 
     802    return StatePtr(new MaybeKeyword(beg)); 
     803} 
    787804// 
    788805// Chars 
     
    10931110            return StatePtr(new NumberOpen); 
    10941111        if (ch == '.') 
    1095             return StatePtr(new MaybeFloat); 
     1112            return StatePtr(new MaybeFloat(colourizer)); 
    10961113 
    10971114        if (ch == '\'')