Index: sakura_core/view/colors/RKW2.cpp =================================================================== --- sakura_core/view/colors/RKW2.cpp (リビジョン 69511) +++ sakura_core/view/colors/RKW2.cpp (リビジョン 69513) @@ -10,8 +10,9 @@ #include "CBregexpDll2.h" #include "io/CFileLoad.h" #include "config/maxdata.h" -#include "window/CEditWnd.h" +#include "charset/CCodeBase.h" //RESULT_FAILURE #include "doc/CDocLine.h" +#include "window/CEditWnd.h" #include "view/colors/DivArray.h" #include "view/colors/JSON_reader.h" #include "view/colors/EColorIndexType.h" @@ -93,20 +94,20 @@ { std::wstring patternStr; std::vector colors; - int nextState; + int nextState, exitState; bool isState; Pattern() - : patternStr(), colors( 0 ), nextState( -1/*not specified*/ ), isState( false ), pBregexp_w( 0 ) + : patternStr(), colors( 0 ), nextState( -1/*not specified*/ ), exitState(0/*not specified*/), isState( false ), pBregexp_w( 0 ) {} - Pattern( const std::wstring& patternStr, const EColorIndexType color, const int nextState = -1/*not specified*/, const bool isState = false ) - : patternStr( patternStr ), colors( 1, color ), nextState( nextState ), isState( isState ), pBregexp_w( 0 ) + Pattern( const std::wstring& patternStr, const EColorIndexType color, const int nextState = -1/*not specified*/, int exitState = 0/*not specified*/, const bool isState = false ) + : patternStr( patternStr ), colors( 1, color ), nextState( nextState ), exitState( exitState ), isState( isState ), pBregexp_w( 0 ) {} - Pattern( const std::wstring& patternStr, const std::vector& colors, const int nextState = -1/*not specified*/, const bool isState = false ) - : patternStr( patternStr ), colors( colors ), nextState( nextState ), isState( isState ), pBregexp_w( 0 ) + Pattern( const std::wstring& patternStr, const std::vector& colors, const int nextState = -1/*not specified*/, int exitState = 0/*not specified*/, const bool isState = false ) + : patternStr( patternStr ), colors( colors ), nextState( nextState ), exitState( exitState ), isState( isState ), pBregexp_w( 0 ) {} Pattern( const Pattern& other ) - : patternStr( other.patternStr ), colors( other.colors ), nextState( other.nextState ), isState( other.isState ), pBregexp_w( 0 ) + : patternStr( other.patternStr ), colors( other.colors ), nextState( other.nextState ), exitState( other.exitState ), isState( other.isState ), pBregexp_w( 0 ) {} ~Pattern(); @@ -660,9 +661,9 @@ this->pattern.nextState = _wtoi( token.value.c_str() ); } } else if( this->objkey == L"exit" ) { - this->pattern.nextState = -2; + this->pattern.exitState = 1; } else if( this->objkey == L"exitall" ) { - this->pattern.nextState = -3; + this->pattern.exitState = -1; } else if( this->objkey == L"state" ) { this->pattern.isState = true; } @@ -962,24 +963,20 @@ } } - switch( bestPattern.nextState ) { - case -1: - // do nothing - break; - case -2: // exit - if( ! pLineMatch->patternStack.empty() ) { - pLineMatch->patternStack.pop_back(); + // next + if( 0 <= bestPattern.nextState && bestPattern.nextState < static_cast( pStates->size() ) ) { // 不正チェック。pStates構築時に一回だけ行う方が良い。 + pLineMatch->patternStack.push_back( &bestPattern ); + } else { + // exit (注: nextが同時に存在するときは nextした先での exitを待ってから exitする) + int exitState = (! pLineMatch->patternStack.empty()) ? bestPattern.exitState : 0/*不正なexitを無視する*/; + while (exitState != 0/*not specified*/) { + if (exitState == 1) { // exit + pLineMatch->patternStack.pop_back(); + } else if (exitState == -1) { // exitall + pLineMatch->patternStack.clear(); + } + exitState = (! pLineMatch->patternStack.empty()) ? pLineMatch->patternStack.back()->exitState : 0; } - break; - case -3: // exitall - pLineMatch->patternStack.clear(); - break; - default: // next state index - if( 0 <= bestPattern.nextState && bestPattern.nextState < static_cast( pStates->size() ) ) { // 不正チェック。pStates構築時に一回だけ行う方が良い。 - pLineMatch->patternStack.push_back( &bestPattern ); - } else { - // do nothing - } } } } Index: sakura_core/view/colors/JSON_checker.h =================================================================== --- sakura_core/view/colors/JSON_checker.h (リビジョン 69511) +++ sakura_core/view/colors/JSON_checker.h (リビジョン 69513) @@ -20,7 +20,7 @@ GO, /* start */ OK, /* ok */ OB, /* object */ - KE, /* key */ + KE, /* key */ CO, /* colon */ VA, /* value */ AR, /* array */ Index: sakura_core/view/colors/JSON_checker.cpp =================================================================== --- sakura_core/view/colors/JSON_checker.cpp (リビジョン 69511) +++ sakura_core/view/colors/JSON_checker.cpp (リビジョン 69513) @@ -112,7 +112,7 @@ Non-whitespace control characters are errors. */ C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, - C_REJECT, C_WHITE , C_WHITE , C_REJECT, C_REJECT, C_WHITE , C_REJECT, C_REJECT, + C_REJECT, C_SPACE , C_WHITE , C_REJECT, C_REJECT, C_WHITE , C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT, C_REJECT,