OSDN Git Service

autoit.cpp - Macros >> User 1 ..... Variable >> User 2 (#749) (2)
[winmerge-jp/winmerge-jp.git] / Externals / crystaledit / editlib / parsers / autoit.cpp
index 7863df0..85e2fab 100644 (file)
@@ -1,7 +1,7 @@
 ///////////////////////////////////////////////////////////////////////////
 //  File:    autoit.cpp
-//  Version: 1.1.0.4
-//  Updated: 19-Jul-1998
+//  Version: 1.1.0.6
+//  Updated: 26-Apr-2021
 //
 //  Copyright:  Ferdinand Prantl, portions by Stcherbatchenko Andrei
 //  E-mail:     prantl@ff.cuni.cz
@@ -488,7 +488,7 @@ IsAutoItKeyword (const TCHAR *pszChars, int nLength)
   return ISXKEYWORDI (s_apszAutoItKeywordList, pszChars, nLength);
 }
 
-inline void
+static inline void
 DefineIdentiferBlock(const TCHAR *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I)
 {
   if (IsAutoItKeyword (pszChars + nIdentBegin, I - nIdentBegin))
@@ -553,7 +553,15 @@ CrystalLineParser::ParseLineAutoIt (unsigned dwCookie, const TCHAR *pszChars, in
             }
           else if (dwCookie & (COOKIE_CHAR | COOKIE_STRING))
             {
-              DEFINE_BLOCK (nPos, COLORINDEX_STRING);
+              DEFINE_BLOCK(nPos, COLORINDEX_STRING);
+            }
+          else if (dwCookie & (COOKIE_USER1 ))
+            {
+              DEFINE_BLOCK(nPos, COLORINDEX_USER1);
+            }
+          else if (dwCookie & (COOKIE_VARIABLE))
+            {
+              DEFINE_BLOCK(nPos, COLORINDEX_USER2);
             }
           else if (dwCookie & COOKIE_PREPROCESSOR)
             {
@@ -590,6 +598,17 @@ out:
           break;
         }
 
+      //  String constant '....'
+      if (dwCookie & COOKIE_CHAR)
+        {
+          if (pszChars[I] == '\'')
+            {
+              dwCookie &= ~COOKIE_CHAR;
+              bRedefineBlock = true;
+            }
+          continue;
+        }
+
       //  String constant "...."
       if (dwCookie & COOKIE_STRING)
         {
@@ -606,12 +625,13 @@ out:
         {
           if (bFirstChar && pszChars[I] == '#' &&
               ((I +  3 <= nLength && memcmp(&pszChars[I], _T("#ce"),            3 * sizeof(TCHAR)) == 0) ||
+               (I +  3 <= nLength && memcmp(&pszChars[I], _T("#CE"),            3 * sizeof(TCHAR)) == 0) ||
                (I + 13 <= nLength && memcmp(&pszChars[I], _T("#comments-end"), 13 * sizeof(TCHAR)) == 0)))
             {
               dwCookie &= ~COOKIE_EXT_COMMENT;
               bRedefineBlock = true;
               bFirstChar = false;
-              I += pszChars[I + 2] == 'e' ? 2 : 12;
+              I += ((pszChars[I + 2] == 'e') || (pszChars[I + 2] == 'E')) ? 2 : 12;
             }
           if (!xisspace (pszChars[I]))
             bFirstChar = false;
@@ -630,6 +650,46 @@ out:
         {
           continue;
         }
+      // Variable begins
+      
+      // Variable begins
+      if (pszChars[I] == '@')
+        {
+          DEFINE_BLOCK(I, COLORINDEX_USER1);
+          dwCookie |= COOKIE_USER1;
+          continue;
+        }
+
+      // Variable ends
+      if (dwCookie & COOKIE_USER1)
+        {
+          if (!xisalnum(pszChars[I]))
+            {
+              dwCookie &= ~COOKIE_USER1;
+              bRedefineBlock = true;
+              bDecIndex = true;
+            }
+          continue;
+        }
+      
+      if (pszChars[I] == '$')
+        {
+          DEFINE_BLOCK(I, COLORINDEX_USER2);
+          dwCookie |= COOKIE_VARIABLE;
+          continue;
+        }
+
+      // Variable ends
+      if (dwCookie & COOKIE_VARIABLE)
+        {
+          if (!xisalnum(pszChars[I]))
+            {
+              dwCookie &= ~COOKIE_VARIABLE;
+              bRedefineBlock = true;
+              bDecIndex = true;
+            }
+          continue;
+        }
 
       //  Normal text
       if (pszChars[I] == '"')
@@ -639,11 +699,20 @@ out:
           continue;
         }
 
+      //  Normal text
+      if (pszChars[I] == '\'')
+        {
+          DEFINE_BLOCK (I, COLORINDEX_STRING);
+          dwCookie |= COOKIE_CHAR;
+          continue;
+        }
+
       if (bFirstChar)
         {
           if (pszChars[I] == '#')
             {
               if ((I +  3 <= nLength && memcmp(&pszChars[I], _T("#cs"),              3 * sizeof(TCHAR)) == 0) ||
+                  (I +  3 <= nLength && memcmp(&pszChars[I], _T("#CS"),              3 * sizeof(TCHAR)) == 0) ||
                   (I + 15 <= nLength && memcmp(&pszChars[I], _T("#comments-start"), 15 * sizeof(TCHAR)) == 0))
                 {
                   DEFINE_BLOCK (I, COLORINDEX_COMMENT);