Преглед на файлове

Add Lua-style long brackets and long comments to CMake language

Teach the CMake language parser to recognize Lua-style "long bracket"
arguments.  These start with two '[' separated by zero or more '='
characters e.g. "[[" or "[=[" or "[==[".  They end with two ']'
separated by the same number of '=' as the opening bracket.  There is no
nesting of brackets of the same level (number of '=').  No escapes,
variable expansion, or other processing is performed on the content
between such brackets so they always represent exactly one argument.

Also teach CMake to parse and ignore "long comment" syntax.  A long
comment starts with "#" immediately followed by an opening long bracket.
It ends at the matching close long bracket.

Teach the RunCMake.Syntax test to cover long bracket and long comment
cases.
Brad King преди 12 години
родител
ревизия
daa0f6f98d
променени са 75 файла, в които са добавени 629 реда и са изтрити 185 реда
  1. 49 31
      Source/cmListFileCache.cxx
  2. 2 1
      Source/cmListFileCache.h
  3. 261 108
      Source/cmListFileLexer.c
  4. 3 0
      Source/cmListFileLexer.h
  5. 89 6
      Source/cmListFileLexer.in.l
  6. 6 0
      Source/cmMakefile.cxx
  7. 1 0
      Tests/RunCMake/Syntax/.gitattributes
  8. 1 0
      Tests/RunCMake/Syntax/Bracket0-stderr.txt
  9. 1 0
      Tests/RunCMake/Syntax/Bracket0.cmake
  10. 1 0
      Tests/RunCMake/Syntax/Bracket1-stderr.txt
  11. 2 0
      Tests/RunCMake/Syntax/Bracket1.cmake
  12. 2 0
      Tests/RunCMake/Syntax/Bracket2-stdout.txt
  13. 2 0
      Tests/RunCMake/Syntax/Bracket2.cmake
  14. 1 0
      Tests/RunCMake/Syntax/BracketBackslash-result.txt
  15. 6 0
      Tests/RunCMake/Syntax/BracketBackslash-stderr.txt
  16. 2 0
      Tests/RunCMake/Syntax/BracketBackslash.cmake
  17. 1 0
      Tests/RunCMake/Syntax/BracketCRLF-stderr.txt
  18. 8 0
      Tests/RunCMake/Syntax/BracketCRLF.cmake
  19. 1 0
      Tests/RunCMake/Syntax/BracketComment0-stdout.txt
  20. 5 0
      Tests/RunCMake/Syntax/BracketComment0.cmake
  21. 1 0
      Tests/RunCMake/Syntax/BracketComment1-result.txt
  22. 4 0
      Tests/RunCMake/Syntax/BracketComment1-stderr.txt
  23. 3 0
      Tests/RunCMake/Syntax/BracketComment1.cmake
  24. 1 0
      Tests/RunCMake/Syntax/BracketComment2-result.txt
  25. 4 0
      Tests/RunCMake/Syntax/BracketComment2-stderr.txt
  26. 3 0
      Tests/RunCMake/Syntax/BracketComment2.cmake
  27. 1 0
      Tests/RunCMake/Syntax/BracketComment3-stdout.txt
  28. 4 0
      Tests/RunCMake/Syntax/BracketComment3.cmake
  29. 1 0
      Tests/RunCMake/Syntax/BracketComment4-result.txt
  30. 7 0
      Tests/RunCMake/Syntax/BracketComment4-stderr.txt
  31. 3 0
      Tests/RunCMake/Syntax/BracketComment4.cmake
  32. 1 0
      Tests/RunCMake/Syntax/BracketComment5-stdout.txt
  33. 6 0
      Tests/RunCMake/Syntax/BracketComment5.cmake
  34. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace0-result.txt
  35. 6 0
      Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt
  36. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace0.cmake
  37. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace1-result.txt
  38. 6 0
      Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt
  39. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace1.cmake
  40. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace2-result.txt
  41. 6 0
      Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt
  42. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace2.cmake
  43. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace3-result.txt
  44. 6 0
      Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt
  45. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace3.cmake
  46. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace4-result.txt
  47. 6 0
      Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt
  48. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace4.cmake
  49. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace5-result.txt
  50. 6 0
      Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt
  51. 1 0
      Tests/RunCMake/Syntax/BracketNoSpace5.cmake
  52. 0 35
      Tests/RunCMake/Syntax/BracketWarn-stderr.txt
  53. 0 1
      Tests/RunCMake/Syntax/BracketWarn-stdout.txt
  54. 0 1
      Tests/RunCMake/Syntax/BracketWarn.cmake
  55. 1 0
      Tests/RunCMake/Syntax/CommandError2-result.txt
  56. 7 0
      Tests/RunCMake/Syntax/CommandError2-stderr.txt
  57. 1 0
      Tests/RunCMake/Syntax/CommandError2.cmake
  58. 3 0
      Tests/RunCMake/Syntax/ParenNoSpace0-stdout.txt
  59. 3 0
      Tests/RunCMake/Syntax/ParenNoSpace0.cmake
  60. 1 0
      Tests/RunCMake/Syntax/ParenNoSpace1-result.txt
  61. 22 0
      Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt
  62. 3 0
      Tests/RunCMake/Syntax/ParenNoSpace1.cmake
  63. 0 0
      Tests/RunCMake/Syntax/ParenNoSpace2-stderr.txt
  64. 1 0
      Tests/RunCMake/Syntax/ParenNoSpace2-stdout.txt
  65. 1 0
      Tests/RunCMake/Syntax/ParenNoSpace2.cmake
  66. 24 2
      Tests/RunCMake/Syntax/RunCMakeTest.cmake
  67. 1 0
      Tests/RunCMake/Syntax/UnterminatedBracket0-result.txt
  68. 8 0
      Tests/RunCMake/Syntax/UnterminatedBracket0-stderr.txt
  69. 1 0
      Tests/RunCMake/Syntax/UnterminatedBracket0.cmake
  70. 1 0
      Tests/RunCMake/Syntax/UnterminatedBracket1-result.txt
  71. 8 0
      Tests/RunCMake/Syntax/UnterminatedBracket1-stderr.txt
  72. 1 0
      Tests/RunCMake/Syntax/UnterminatedBracket1.cmake
  73. 1 0
      Tests/RunCMake/Syntax/UnterminatedBracketComment-result.txt
  74. 8 0
      Tests/RunCMake/Syntax/UnterminatedBracketComment-stderr.txt
  75. 2 0
      Tests/RunCMake/Syntax/UnterminatedBracketComment.cmake

+ 49 - 31
Source/cmListFileCache.cxx

@@ -29,14 +29,14 @@ struct cmListFileParser
   ~cmListFileParser();
   ~cmListFileParser();
   bool ParseFile();
   bool ParseFile();
   bool ParseFunction(const char* name, long line);
   bool ParseFunction(const char* name, long line);
-  void AddArgument(cmListFileLexer_Token* token,
+  bool AddArgument(cmListFileLexer_Token* token,
                    cmListFileArgument::Delimiter delim);
                    cmListFileArgument::Delimiter delim);
   cmListFile* ListFile;
   cmListFile* ListFile;
   cmMakefile* Makefile;
   cmMakefile* Makefile;
   const char* FileName;
   const char* FileName;
   cmListFileLexer* Lexer;
   cmListFileLexer* Lexer;
   cmListFileFunction Function;
   cmListFileFunction Function;
-  enum { SeparationOkay, SeparationWarning } Separation;
+  enum { SeparationOkay, SeparationWarning, SeparationError} Separation;
 };
 };
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
@@ -90,6 +90,10 @@ bool cmListFileParser::ParseFile()
       {
       {
       haveNewline = true;
       haveNewline = true;
       }
       }
+    else if(token->type == cmListFileLexer_Token_CommentBracket)
+      {
+      haveNewline = false;
+      }
     else if(token->type == cmListFileLexer_Token_Identifier)
     else if(token->type == cmListFileLexer_Token_Identifier)
       {
       {
       if(haveNewline)
       if(haveNewline)
@@ -301,7 +305,10 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
       {
       {
       parenDepth++;
       parenDepth++;
       this->Separation = SeparationOkay;
       this->Separation = SeparationOkay;
-      this->AddArgument(token, cmListFileArgument::Unquoted);
+      if(!this->AddArgument(token, cmListFileArgument::Unquoted))
+        {
+        return false;
+        }
       }
       }
     else if(token->type == cmListFileLexer_Token_ParenRight)
     else if(token->type == cmListFileLexer_Token_ParenRight)
       {
       {
@@ -311,20 +318,41 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
         }
         }
       parenDepth--;
       parenDepth--;
       this->Separation = SeparationOkay;
       this->Separation = SeparationOkay;
-      this->AddArgument(token, cmListFileArgument::Unquoted);
+      if(!this->AddArgument(token, cmListFileArgument::Unquoted))
+        {
+        return false;
+        }
       this->Separation = SeparationWarning;
       this->Separation = SeparationWarning;
       }
       }
     else if(token->type == cmListFileLexer_Token_Identifier ||
     else if(token->type == cmListFileLexer_Token_Identifier ||
             token->type == cmListFileLexer_Token_ArgumentUnquoted)
             token->type == cmListFileLexer_Token_ArgumentUnquoted)
       {
       {
-      this->AddArgument(token, cmListFileArgument::Unquoted);
+      if(!this->AddArgument(token, cmListFileArgument::Unquoted))
+        {
+        return false;
+        }
       this->Separation = SeparationWarning;
       this->Separation = SeparationWarning;
       }
       }
     else if(token->type == cmListFileLexer_Token_ArgumentQuoted)
     else if(token->type == cmListFileLexer_Token_ArgumentQuoted)
       {
       {
-      this->AddArgument(token, cmListFileArgument::Quoted);
+      if(!this->AddArgument(token, cmListFileArgument::Quoted))
+        {
+        return false;
+        }
       this->Separation = SeparationWarning;
       this->Separation = SeparationWarning;
       }
       }
+    else if(token->type == cmListFileLexer_Token_ArgumentBracket)
+      {
+      if(!this->AddArgument(token, cmListFileArgument::Bracket))
+        {
+        return false;
+        }
+      this->Separation = SeparationError;
+      }
+    else if(token->type == cmListFileLexer_Token_CommentBracket)
+      {
+      this->Separation = SeparationError;
+      }
     else
     else
       {
       {
       // Error.
       // Error.
@@ -351,42 +379,32 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-void cmListFileParser::AddArgument(cmListFileLexer_Token* token,
+bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
                                    cmListFileArgument::Delimiter delim)
                                    cmListFileArgument::Delimiter delim)
 {
 {
   cmListFileArgument a(token->text, delim, this->FileName, token->line);
   cmListFileArgument a(token->text, delim, this->FileName, token->line);
   this->Function.Arguments.push_back(a);
   this->Function.Arguments.push_back(a);
-  if(delim == cmListFileArgument::Unquoted)
-    {
-    // Warn about a future behavior change.
-    const char* c = a.Value.c_str();
-    if(*c++ == '[')
-      {
-      while(*c == '=')
-        { ++c; }
-      if(*c == '[')
-        {
-        cmOStringStream m;
-        m << "Syntax Warning in cmake code at\n"
-          << "  " << this->FileName << ":" << token->line << ":"
-          << token->column << "\n"
-          << "A future version of CMake may treat unquoted argument:\n"
-          << "  " << a.Value << "\n"
-          << "as an opening long bracket.  Double-quote the argument.";
-        this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
-        }
-      }
-    }
   if(this->Separation == SeparationOkay)
   if(this->Separation == SeparationOkay)
     {
     {
-    return;
+    return true;
     }
     }
+  bool isError = (this->Separation == SeparationError ||
+                  delim == cmListFileArgument::Bracket);
   cmOStringStream m;
   cmOStringStream m;
-  m << "Syntax Warning in cmake code at\n"
+  m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n"
     << "  " << this->FileName << ":" << token->line << ":"
     << "  " << this->FileName << ":" << token->line << ":"
     << token->column << "\n"
     << token->column << "\n"
     << "Argument not separated from preceding token by whitespace.";
     << "Argument not separated from preceding token by whitespace.";
-  this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
+  if(isError)
+    {
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str().c_str());
+    return false;
+    }
+  else
+    {
+    this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
+    return true;
+    }
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------

+ 2 - 1
Source/cmListFileCache.h

@@ -28,7 +28,8 @@ struct cmListFileArgument
   enum Delimiter
   enum Delimiter
     {
     {
     Unquoted,
     Unquoted,
-    Quoted
+    Quoted,
+    Bracket
     };
     };
   cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
   cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
   cmListFileArgument(const cmListFileArgument& r):
   cmListFileArgument(const cmListFileArgument& r):

+ 261 - 108
Source/cmListFileLexer.c

@@ -369,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
         *yy_cp = '\0'; \
         *yy_cp = '\0'; \
         yyg->yy_c_buf_p = yy_cp;
         yyg->yy_c_buf_p = yy_cp;
 
 
-#define YY_NUM_RULES 16
-#define YY_END_OF_BUFFER 17
+#define YY_NUM_RULES 23
+#define YY_END_OF_BUFFER 24
 /* This struct is not used in this scanner,
 /* This struct is not used in this scanner,
    but its presence is necessary. */
    but its presence is necessary. */
 struct yy_trans_info
 struct yy_trans_info
@@ -378,13 +378,16 @@ struct yy_trans_info
         flex_int32_t yy_verify;
         flex_int32_t yy_verify;
         flex_int32_t yy_nxt;
         flex_int32_t yy_nxt;
         };
         };
-static yyconst flex_int16_t yy_accept[45] =
+static yyconst flex_int16_t yy_accept[77] =
     {   0,
     {   0,
-        0,    0,    0,    0,   17,    6,   14,    1,    8,    2,
-        6,    3,    4,    5,   15,    9,   11,   12,   13,    6,
-        0,    6,    0,   14,    2,    0,    5,    6,    9,    0,
-       10,    0,    7,    0,    0,    0,    7,    0,    7,    0,
-        0,    0,    0,    0
+        0,    0,    0,    0,    0,    0,    0,    0,    4,    4,
+       24,   13,   21,    1,   15,    3,   13,    5,    6,    7,
+       22,   22,   16,   18,   19,   20,   10,   11,    8,   12,
+        9,    4,   13,    0,   13,    0,   21,    0,    0,    7,
+       13,    0,   13,    0,    2,    0,   13,   16,    0,   17,
+       10,    8,    4,    0,   14,    0,    0,    0,    0,   14,
+        0,    0,   14,    0,    0,    0,    2,   14,    0,    0,
+        0,    0,    0,    0,    0,    0
     } ;
     } ;
 
 
 static yyconst flex_int32_t yy_ec[256] =
 static yyconst flex_int32_t yy_ec[256] =
@@ -395,14 +398,14 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    2,    1,    5,    6,    7,    1,    1,    1,    8,
         1,    2,    1,    5,    6,    7,    1,    1,    1,    8,
         9,    1,    1,    1,    1,    1,    1,   10,   10,   10,
         9,    1,    1,    1,    1,    1,    1,   10,   10,   10,
        10,   10,   10,   10,   10,   10,   10,    1,    1,    1,
        10,   10,   10,   10,   10,   10,   10,    1,    1,    1,
-        1,    1,    1,    1,   11,   11,   11,   11,   11,   11,
-       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
-       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
-        1,   12,    1,    1,   11,    1,   11,   11,   11,   11,
-
-       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
-       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
-       11,   11,    1,    1,    1,    1,    1,    1,    1,    1,
+       11,    1,    1,    1,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+       13,   14,   15,    1,   12,    1,   12,   12,   12,   12,
+
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -419,72 +422,111 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1
         1,    1,    1,    1,    1
     } ;
     } ;
 
 
-static yyconst flex_int32_t yy_meta[13] =
+static yyconst flex_int32_t yy_meta[16] =
     {   0,
     {   0,
-        1,    2,    3,    2,    4,    1,    1,    1,    5,    5,
-        5,    1
+        1,    1,    2,    3,    4,    3,    1,    3,    5,    6,
+        1,    6,    1,    1,    7
     } ;
     } ;
 
 
-static yyconst flex_int16_t yy_base[56] =
+static yyconst flex_int16_t yy_base[95] =
     {   0,
     {   0,
-        0,    0,   10,   20,   38,   32,    0,  109,  109,    0,
-       28,  109,  109,   35,    0,   23,  109,  109,   44,    0,
-       49,   26,    0,    0,    0,   22,    0,    0,   18,   24,
-      109,    0,   61,   20,    0,   18,    0,   17,   16,    0,
-       12,   11,   10,  109,   73,   16,   78,   83,   88,   93,
-       12,   98,   11,  103,    9
+        0,    0,   13,   25,   14,   16,   17,   18,   90,   88,
+       88,   39,   20,  237,  237,   74,   78,  237,  237,   13,
+       54,    0,   71,  237,  237,   31,    0,  237,   73,  237,
+      237,    0,    0,   65,   75,    0,   33,   30,   72,    0,
+        0,   75,   70,    0,   74,    0,    0,   62,   70,  237,
+        0,   63,    0,   85,   99,   65,  111,   62,   34,    0,
+       54,  116,    0,   54,  127,   51,  237,   50,    0,   48,
+       47,   39,   33,   29,   17,  237,  136,  143,  150,  157,
+      164,  171,  178,  184,  191,  198,  201,  207,  214,  217,
+      219,  225,  228,  230
+
     } ;
     } ;
 
 
-static yyconst flex_int16_t yy_def[56] =
+static yyconst flex_int16_t yy_def[95] =
     {   0,
     {   0,
-       44,    1,   45,   45,   44,   44,   46,   44,   44,   47,
-        6,   44,   44,    6,   48,   49,   44,   44,   49,    6,
-       44,    6,   50,   46,   47,   51,   14,    6,   49,   49,
-       44,   21,   44,   21,   52,   53,   33,   51,   33,   54,
-       55,   53,   55,    0,   44,   44,   44,   44,   44,   44,
-       44,   44,   44,   44,   44
+       76,    1,   77,   77,   78,   78,   79,   79,   80,   80,
+       76,   76,   76,   76,   76,   76,   12,   76,   76,   12,
+       76,   81,   82,   76,   76,   82,   83,   76,   76,   76,
+       76,   84,   12,   85,   12,   86,   76,   76,   87,   20,
+       12,   88,   12,   21,   76,   89,   12,   82,   82,   76,
+       83,   76,   84,   85,   76,   54,   85,   90,   76,   55,
+       87,   88,   55,   62,   88,   91,   76,   55,   92,   93,
+       90,   94,   91,   93,   94,    0,   76,   76,   76,   76,
+       76,   76,   76,   76,   76,   76,   76,   76,   76,   76,
+       76,   76,   76,   76
+
     } ;
     } ;
 
 
-static yyconst flex_int16_t yy_nxt[122] =
+static yyconst flex_int16_t yy_nxt[253] =
     {   0,
     {   0,
-        6,    7,    8,    7,    9,   10,   11,   12,   13,    6,
-       14,   15,   17,   43,   18,   42,   38,   24,   32,   33,
-       32,   19,   17,   36,   18,   37,   33,   41,   29,   30,
-       37,   19,   20,   36,   30,   26,   21,   44,   22,   44,
-       44,   20,   20,   23,   27,   27,   31,   44,   29,   32,
-       32,   44,   44,   33,   44,   34,   44,   44,   32,   32,
-       35,   33,   44,   44,   44,   21,   44,   39,   44,   44,
-       33,   33,   40,   16,   16,   16,   16,   16,   25,   25,
-       44,   25,   25,   28,   28,   44,   28,   28,   29,   29,
-       44,   44,   29,   20,   20,   44,   20,   20,   32,   32,
-
-       44,   32,   32,   33,   33,   44,   33,   33,    5,   44,
-       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
-       44
+       12,   13,   14,   13,   15,   16,   17,   18,   19,   12,
+       12,   20,   21,   22,   12,   24,   28,   25,   28,   28,
+       28,   37,   40,   37,   40,   62,   26,   24,   29,   25,
+       29,   31,   31,   50,   37,   48,   37,   54,   26,   33,
+       59,   63,   45,   34,   59,   35,   45,   62,   33,   33,
+       33,   33,   36,   33,   41,   55,   54,   58,   42,   63,
+       43,   72,   60,   41,   44,   41,   45,   46,   41,   55,
+       55,   56,   70,   52,   48,   49,   67,   66,   57,   63,
+       60,   64,   58,   52,   49,   39,   38,   76,   65,   55,
+       14,   56,   14,   76,   76,   76,   76,   76,   57,   55,
+
+       76,   76,   76,   34,   76,   68,   76,   76,   55,   55,
+       55,   55,   69,   55,   54,   76,   54,   76,   54,   54,
+       63,   76,   64,   76,   76,   76,   76,   76,   76,   65,
+       62,   76,   62,   76,   62,   62,   23,   23,   23,   23,
+       23,   23,   23,   27,   27,   27,   27,   27,   27,   27,
+       30,   30,   30,   30,   30,   30,   30,   32,   32,   32,
+       32,   32,   32,   32,   47,   76,   47,   47,   47,   47,
+       47,   48,   76,   48,   76,   48,   48,   48,   51,   76,
+       51,   51,   51,   51,   53,   76,   53,   53,   53,   53,
+       53,   54,   76,   76,   54,   76,   54,   54,   33,   76,
+
+       33,   33,   33,   33,   33,   61,   61,   62,   76,   76,
+       62,   76,   62,   62,   41,   76,   41,   41,   41,   41,
+       41,   71,   71,   73,   73,   55,   76,   55,   55,   55,
+       55,   55,   74,   74,   75,   75,   11,   76,   76,   76,
+       76,   76,   76,   76,   76,   76,   76,   76,   76,   76,
+       76,   76
     } ;
     } ;
 
 
-static yyconst flex_int16_t yy_chk[122] =
+static yyconst flex_int16_t yy_chk[253] =
     {   0,
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    3,   55,    3,   53,   51,   46,   43,   42,
-       41,    3,    4,   39,    4,   38,   36,   34,   30,   29,
-       26,    4,    6,   22,   16,   11,    6,    5,    6,    0,
-        0,    6,    6,    6,   14,   14,   19,    0,   19,   21,
-       21,    0,    0,   21,    0,   21,    0,    0,   21,   21,
-       21,   33,    0,    0,    0,   33,    0,   33,    0,    0,
-       33,   33,   33,   45,   45,   45,   45,   45,   47,   47,
-        0,   47,   47,   48,   48,    0,   48,   48,   49,   49,
-        0,    0,   49,   50,   50,    0,   50,   50,   52,   52,
-
-        0,   52,   52,   54,   54,    0,   54,   54,   44,   44,
-       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
-       44
+        1,    1,    1,    1,    1,    3,    5,    3,    6,    7,
+        8,   13,   20,   13,   20,   75,    3,    4,    5,    4,
+        6,    7,    8,   26,   37,   26,   37,   74,    4,   12,
+       38,   73,   38,   12,   59,   12,   59,   72,   12,   12,
+       12,   12,   12,   12,   21,   71,   70,   68,   21,   66,
+       21,   64,   61,   21,   21,   21,   21,   21,   21,   34,
+       58,   34,   56,   52,   49,   48,   45,   43,   34,   42,
+       39,   42,   35,   29,   23,   17,   16,   11,   42,   54,
+       10,   54,    9,    0,    0,    0,    0,    0,   54,   55,
+
+        0,    0,    0,   55,    0,   55,    0,    0,   55,   55,
+       55,   55,   55,   55,   57,    0,   57,    0,   57,   57,
+       62,    0,   62,    0,    0,    0,    0,    0,    0,   62,
+       65,    0,   65,    0,   65,   65,   77,   77,   77,   77,
+       77,   77,   77,   78,   78,   78,   78,   78,   78,   78,
+       79,   79,   79,   79,   79,   79,   79,   80,   80,   80,
+       80,   80,   80,   80,   81,    0,   81,   81,   81,   81,
+       81,   82,    0,   82,    0,   82,   82,   82,   83,    0,
+       83,   83,   83,   83,   84,    0,   84,   84,   84,   84,
+       84,   85,    0,    0,   85,    0,   85,   85,   86,    0,
+
+       86,   86,   86,   86,   86,   87,   87,   88,    0,    0,
+       88,    0,   88,   88,   89,    0,   89,   89,   89,   89,
+       89,   90,   90,   91,   91,   92,    0,   92,   92,   92,
+       92,   92,   93,   93,   94,   94,   76,   76,   76,   76,
+       76,   76,   76,   76,   76,   76,   76,   76,   76,   76,
+       76,   76
     } ;
     } ;
 
 
 /* Table of booleans, true if rule could match eol. */
 /* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[17] =
+static yyconst flex_int32_t yy_rule_can_match_eol[24] =
     {   0,
     {   0,
-1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,     };
+1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0,
+    0, 0, 0, 0,     };
 
 
 /* The intent behind this definition is that it'll catch
 /* The intent behind this definition is that it'll catch
  * any uses of REJECT which flex missed.
  * any uses of REJECT which flex missed.
@@ -538,6 +580,8 @@ Modify cmListFileLexer.c:
 struct cmListFileLexer_s
 struct cmListFileLexer_s
 {
 {
   cmListFileLexer_Token token;
   cmListFileLexer_Token token;
+  int bracket;
+  int comment;
   int line;
   int line;
   int column;
   int column;
   int size;
   int size;
@@ -565,10 +609,16 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
 
 
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
 
 
-#line 571 "cmListFileLexer.c"
+
+
+
+#line 618 "cmListFileLexer.c"
 
 
 #define INITIAL 0
 #define INITIAL 0
 #define STRING 1
 #define STRING 1
+#define BRACKET 2
+#define BRACKETEND 3
+#define COMMENT 4
 
 
 #ifndef YY_NO_UNISTD_H
 #ifndef YY_NO_UNISTD_H
 /* Special case for "unistd.h", since it is non-ANSI. We include it way
 /* Special case for "unistd.h", since it is non-ANSI. We include it way
@@ -794,10 +844,10 @@ YY_DECL
         int yy_act;
         int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 
-#line 83 "cmListFileLexer.in.l"
+#line 88 "cmListFileLexer.in.l"
 
 
 
 
-#line 805 "cmListFileLexer.c"
+#line 855 "cmListFileLexer.c"
 
 
         if ( !yyg->yy_init )
         if ( !yyg->yy_init )
                 {
                 {
@@ -850,13 +900,13 @@ yy_match:
                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                                 {
                                 {
                                 yy_current_state = (int) yy_def[yy_current_state];
                                 yy_current_state = (int) yy_def[yy_current_state];
-                                if ( yy_current_state >= 45 )
+                                if ( yy_current_state >= 77 )
                                         yy_c = yy_meta[(unsigned int) yy_c];
                                         yy_c = yy_meta[(unsigned int) yy_c];
                                 }
                                 }
                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
                         ++yy_cp;
                         ++yy_cp;
                         }
                         }
-                while ( yy_base[yy_current_state] != 109 );
+                while ( yy_base[yy_current_state] != 237 );
 
 
 yy_find_action:
 yy_find_action:
                 yy_act = yy_accept[yy_current_state];
                 yy_act = yy_accept[yy_current_state];
@@ -895,69 +945,168 @@ do_action:      /* This label is used only to access EOF actions. */
 case 1:
 case 1:
 /* rule 1 can match eol */
 /* rule 1 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 85 "cmListFileLexer.in.l"
+#line 90 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_Newline;
   lexer->token.type = cmListFileLexer_Token_Newline;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   ++lexer->line;
   ++lexer->line;
   lexer->column = 1;
   lexer->column = 1;
+  BEGIN(INITIAL);
   return 1;
   return 1;
 }
 }
 case 2:
 case 2:
+/* rule 2 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 93 "cmListFileLexer.in.l"
+#line 99 "cmListFileLexer.in.l"
 {
 {
-  lexer->column += yyleng;
+  const char* bracket = yytext;
+  lexer->comment = yytext[0] == '#';
+  if(lexer->comment)
+    {
+    lexer->token.type = cmListFileLexer_Token_CommentBracket;
+    bracket += 1;
+    }
+  else
+    {
+    lexer->token.type = cmListFileLexer_Token_ArgumentBracket;
+    }
+  cmListFileLexerSetToken(lexer, "", 0);
+  lexer->bracket = (int)(strchr(bracket+1, '[') - bracket);
+  if(yytext[yyleng-1] == '\n')
+    {
+    ++lexer->line;
+    lexer->column = 1;
+    }
+  else
+    {
+    lexer->column += yyleng;
+    }
+  BEGIN(BRACKET);
 }
 }
         YY_BREAK
         YY_BREAK
 case 3:
 case 3:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 97 "cmListFileLexer.in.l"
+#line 125 "cmListFileLexer.in.l"
+{
+  lexer->column += yyleng;
+  BEGIN(COMMENT);
+}
+        YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 130 "cmListFileLexer.in.l"
+{
+  lexer->column += yyleng;
+}
+        YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 134 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_ParenLeft;
   lexer->token.type = cmListFileLexer_Token_ParenLeft;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
   return 1;
   return 1;
 }
 }
-case 4:
+case 6:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 104 "cmListFileLexer.in.l"
+#line 141 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_ParenRight;
   lexer->token.type = cmListFileLexer_Token_ParenRight;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
   return 1;
   return 1;
 }
 }
-case 5:
+case 7:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 111 "cmListFileLexer.in.l"
+#line 148 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_Identifier;
   lexer->token.type = cmListFileLexer_Token_Identifier;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
   return 1;
   return 1;
 }
 }
-case 6:
+case 8:
+YY_RULE_SETUP
+#line 155 "cmListFileLexer.in.l"
+{
+  /* Handle ]]====]=======]*/
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  lexer->column += yyleng;
+  if(yyleng == lexer->bracket)
+    {
+    BEGIN(BRACKETEND);
+    }
+}
+        YY_BREAK
+case 9:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 118 "cmListFileLexer.in.l"
+#line 165 "cmListFileLexer.in.l"
+{
+  lexer->column += yyleng;
+  /* Erase the partial bracket from the token.  */
+  lexer->token.length -= lexer->bracket;
+  lexer->token.text[lexer->token.length] = 0;
+  BEGIN(INITIAL);
+  return 1;
+}
+case 10:
+YY_RULE_SETUP
+#line 174 "cmListFileLexer.in.l"
+{
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  lexer->column += yyleng;
+}
+        YY_BREAK
+case 11:
+/* rule 11 can match eol */
+YY_RULE_SETUP
+#line 179 "cmListFileLexer.in.l"
+{
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  ++lexer->line;
+  lexer->column = 1;
+  BEGIN(BRACKET);
+}
+        YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 186 "cmListFileLexer.in.l"
+{
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  lexer->column += yyleng;
+  BEGIN(BRACKET);
+}
+        YY_BREAK
+case YY_STATE_EOF(BRACKET):
+case YY_STATE_EOF(BRACKETEND):
+#line 192 "cmListFileLexer.in.l"
+{
+  lexer->token.type = cmListFileLexer_Token_BadBracket;
+  BEGIN(INITIAL);
+  return 1;
+}
+case 13:
+YY_RULE_SETUP
+#line 198 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
   return 1;
   return 1;
 }
 }
-case 7:
+case 14:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 125 "cmListFileLexer.in.l"
+#line 205 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
   return 1;
   return 1;
 }
 }
-case 8:
+case 15:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 132 "cmListFileLexer.in.l"
+#line 212 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
   lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
   cmListFileLexerSetToken(lexer, "", 0);
   cmListFileLexerSetToken(lexer, "", 0);
@@ -965,69 +1114,69 @@ YY_RULE_SETUP
   BEGIN(STRING);
   BEGIN(STRING);
 }
 }
         YY_BREAK
         YY_BREAK
-case 9:
+case 16:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 139 "cmListFileLexer.in.l"
+#line 219 "cmListFileLexer.in.l"
 {
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
 }
 }
         YY_BREAK
         YY_BREAK
-case 10:
-/* rule 10 can match eol */
+case 17:
+/* rule 17 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 144 "cmListFileLexer.in.l"
+#line 224 "cmListFileLexer.in.l"
 {
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   cmListFileLexerAppend(lexer, yytext, yyleng);
   ++lexer->line;
   ++lexer->line;
   lexer->column = 1;
   lexer->column = 1;
 }
 }
         YY_BREAK
         YY_BREAK
-case 11:
-/* rule 11 can match eol */
+case 18:
+/* rule 18 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 150 "cmListFileLexer.in.l"
+#line 230 "cmListFileLexer.in.l"
 {
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   cmListFileLexerAppend(lexer, yytext, yyleng);
   ++lexer->line;
   ++lexer->line;
   lexer->column = 1;
   lexer->column = 1;
 }
 }
         YY_BREAK
         YY_BREAK
-case 12:
+case 19:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 156 "cmListFileLexer.in.l"
+#line 236 "cmListFileLexer.in.l"
 {
 {
   lexer->column += yyleng;
   lexer->column += yyleng;
   BEGIN(INITIAL);
   BEGIN(INITIAL);
   return 1;
   return 1;
 }
 }
-case 13:
+case 20:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 162 "cmListFileLexer.in.l"
+#line 242 "cmListFileLexer.in.l"
 {
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
 }
 }
         YY_BREAK
         YY_BREAK
 case YY_STATE_EOF(STRING):
 case YY_STATE_EOF(STRING):
-#line 167 "cmListFileLexer.in.l"
+#line 247 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_BadString;
   lexer->token.type = cmListFileLexer_Token_BadString;
   BEGIN(INITIAL);
   BEGIN(INITIAL);
   return 1;
   return 1;
 }
 }
-case 14:
+case 21:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 173 "cmListFileLexer.in.l"
+#line 253 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_Space;
   lexer->token.type = cmListFileLexer_Token_Space;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
   return 1;
   return 1;
 }
 }
-case 15:
+case 22:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 180 "cmListFileLexer.in.l"
+#line 260 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_BadCharacter;
   lexer->token.type = cmListFileLexer_Token_BadCharacter;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1035,18 +1184,19 @@ YY_RULE_SETUP
   return 1;
   return 1;
 }
 }
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(INITIAL):
-#line 187 "cmListFileLexer.in.l"
+case YY_STATE_EOF(COMMENT):
+#line 267 "cmListFileLexer.in.l"
 {
 {
   lexer->token.type = cmListFileLexer_Token_None;
   lexer->token.type = cmListFileLexer_Token_None;
   cmListFileLexerSetToken(lexer, 0, 0);
   cmListFileLexerSetToken(lexer, 0, 0);
   return 0;
   return 0;
 }
 }
-case 16:
+case 23:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 193 "cmListFileLexer.in.l"
+#line 273 "cmListFileLexer.in.l"
 ECHO;
 ECHO;
         YY_BREAK
         YY_BREAK
-#line 1065 "cmListFileLexer.c"
+#line 1217 "cmListFileLexer.c"
 
 
         case YY_END_OF_BUFFER:
         case YY_END_OF_BUFFER:
                 {
                 {
@@ -1338,7 +1488,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                         {
                         {
                         yy_current_state = (int) yy_def[yy_current_state];
                         yy_current_state = (int) yy_def[yy_current_state];
-                        if ( yy_current_state >= 45 )
+                        if ( yy_current_state >= 77 )
                                 yy_c = yy_meta[(unsigned int) yy_c];
                                 yy_c = yy_meta[(unsigned int) yy_c];
                         }
                         }
                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1367,11 +1517,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                 {
                 {
                 yy_current_state = (int) yy_def[yy_current_state];
                 yy_current_state = (int) yy_def[yy_current_state];
-                if ( yy_current_state >= 45 )
+                if ( yy_current_state >= 77 )
                         yy_c = yy_meta[(unsigned int) yy_c];
                         yy_c = yy_meta[(unsigned int) yy_c];
                 }
                 }
         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-        yy_is_jam = (yy_current_state == 44);
+        yy_is_jam = (yy_current_state == 76);
 
 
         return yy_is_jam ? 0 : yy_current_state;
         return yy_is_jam ? 0 : yy_current_state;
 }
 }
@@ -2167,7 +2317,7 @@ void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner)
 
 
 #define YYTABLES_NAME "yytables"
 #define YYTABLES_NAME "yytables"
 
 
-#line 193 "cmListFileLexer.in.l"
+#line 273 "cmListFileLexer.in.l"
 
 
 
 
 
 
@@ -2492,7 +2642,10 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
     case cmListFileLexer_Token_ParenRight: return "right paren";
     case cmListFileLexer_Token_ParenRight: return "right paren";
     case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument";
     case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument";
     case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument";
     case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument";
+    case cmListFileLexer_Token_ArgumentBracket: return "bracket argument";
+    case cmListFileLexer_Token_CommentBracket: return "bracket comment";
     case cmListFileLexer_Token_BadCharacter: return "bad character";
     case cmListFileLexer_Token_BadCharacter: return "bad character";
+    case cmListFileLexer_Token_BadBracket: return "unterminated bracket";
     case cmListFileLexer_Token_BadString: return "unterminated string";
     case cmListFileLexer_Token_BadString: return "unterminated string";
     }
     }
   return "unknown token";
   return "unknown token";

+ 3 - 0
Source/cmListFileLexer.h

@@ -22,7 +22,10 @@ typedef enum cmListFileLexer_Type_e
   cmListFileLexer_Token_ParenRight,
   cmListFileLexer_Token_ParenRight,
   cmListFileLexer_Token_ArgumentUnquoted,
   cmListFileLexer_Token_ArgumentUnquoted,
   cmListFileLexer_Token_ArgumentQuoted,
   cmListFileLexer_Token_ArgumentQuoted,
+  cmListFileLexer_Token_ArgumentBracket,
+  cmListFileLexer_Token_CommentBracket,
   cmListFileLexer_Token_BadCharacter,
   cmListFileLexer_Token_BadCharacter,
+  cmListFileLexer_Token_BadBracket,
   cmListFileLexer_Token_BadString
   cmListFileLexer_Token_BadString
 } cmListFileLexer_Type;
 } cmListFileLexer_Type;
 
 

+ 89 - 6
Source/cmListFileLexer.in.l

@@ -42,6 +42,8 @@ Modify cmListFileLexer.c:
 struct cmListFileLexer_s
 struct cmListFileLexer_s
 {
 {
   cmListFileLexer_Token token;
   cmListFileLexer_Token token;
+  int bracket;
+  int comment;
   int line;
   int line;
   int column;
   int column;
   int size;
   int size;
@@ -75,22 +77,57 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
 %option noyywrap
 %option noyywrap
 %pointer
 %pointer
 %x STRING
 %x STRING
+%x BRACKET
+%x BRACKETEND
+%x COMMENT
 
 
 MAKEVAR \$\([A-Za-z0-9_]*\)
 MAKEVAR \$\([A-Za-z0-9_]*\)
-UNQUOTED ([^ \t\r\n\(\)#\\\"]|\\.)
-LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\"
+UNQUOTED ([^ \t\r\n\(\)#\\\"[=]|\\.)
+LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
 
 
 %%
 %%
 
 
-\n {
+<INITIAL,COMMENT>\n {
   lexer->token.type = cmListFileLexer_Token_Newline;
   lexer->token.type = cmListFileLexer_Token_Newline;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   ++lexer->line;
   ++lexer->line;
   lexer->column = 1;
   lexer->column = 1;
+  BEGIN(INITIAL);
   return 1;
   return 1;
 }
 }
 
 
-#.* {
+#?\[=*\[\n? {
+  const char* bracket = yytext;
+  lexer->comment = yytext[0] == '#';
+  if(lexer->comment)
+    {
+    lexer->token.type = cmListFileLexer_Token_CommentBracket;
+    bracket += 1;
+    }
+  else
+    {
+    lexer->token.type = cmListFileLexer_Token_ArgumentBracket;
+    }
+  cmListFileLexerSetToken(lexer, "", 0);
+  lexer->bracket = (int)(strchr(bracket+1, '[') - bracket);
+  if(yytext[yyleng-1] == '\n')
+    {
+    ++lexer->line;
+    lexer->column = 1;
+    }
+  else
+    {
+    lexer->column += yyleng;
+    }
+  BEGIN(BRACKET);
+}
+
+# {
+  lexer->column += yyleng;
+  BEGIN(COMMENT);
+}
+
+<COMMENT>.* {
   lexer->column += yyleng;
   lexer->column += yyleng;
 }
 }
 
 
@@ -115,14 +152,57 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\"
   return 1;
   return 1;
 }
 }
 
 
-({UNQUOTED})({UNQUOTED})* {
+<BRACKET>\]=* {
+  /* Handle ]]====]=======]*/
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  lexer->column += yyleng;
+  if(yyleng == lexer->bracket)
+    {
+    BEGIN(BRACKETEND);
+    }
+}
+
+<BRACKETEND>\] {
+  lexer->column += yyleng;
+  /* Erase the partial bracket from the token.  */
+  lexer->token.length -= lexer->bracket;
+  lexer->token.text[lexer->token.length] = 0;
+  BEGIN(INITIAL);
+  return 1;
+}
+
+<BRACKET>([^]\n])+ {
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  lexer->column += yyleng;
+}
+
+<BRACKET,BRACKETEND>\n {
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  ++lexer->line;
+  lexer->column = 1;
+  BEGIN(BRACKET);
+}
+
+<BRACKET,BRACKETEND>. {
+  cmListFileLexerAppend(lexer, yytext, yyleng);
+  lexer->column += yyleng;
+  BEGIN(BRACKET);
+}
+
+<BRACKET,BRACKETEND><<EOF>> {
+  lexer->token.type = cmListFileLexer_Token_BadBracket;
+  BEGIN(INITIAL);
+  return 1;
+}
+
+({UNQUOTED}|=|\[=*{UNQUOTED})({UNQUOTED}|[[=])* {
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
   return 1;
   return 1;
 }
 }
 
 
-({MAKEVAR}|{UNQUOTED})({LEGACY})* {
+({MAKEVAR}|{UNQUOTED}|=|\[=*{LEGACY})({LEGACY}|[[=])* {
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   cmListFileLexerSetToken(lexer, yytext, yyleng);
   lexer->column += yyleng;
   lexer->column += yyleng;
@@ -513,7 +593,10 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
     case cmListFileLexer_Token_ParenRight: return "right paren";
     case cmListFileLexer_Token_ParenRight: return "right paren";
     case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument";
     case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument";
     case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument";
     case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument";
+    case cmListFileLexer_Token_ArgumentBracket: return "bracket argument";
+    case cmListFileLexer_Token_CommentBracket: return "bracket comment";
     case cmListFileLexer_Token_BadCharacter: return "bad character";
     case cmListFileLexer_Token_BadCharacter: return "bad character";
+    case cmListFileLexer_Token_BadBracket: return "unterminated bracket";
     case cmListFileLexer_Token_BadString: return "unterminated string";
     case cmListFileLexer_Token_BadString: return "unterminated string";
     }
     }
   return "unknown token";
   return "unknown token";

+ 6 - 0
Source/cmMakefile.cxx

@@ -2867,6 +2867,12 @@ bool cmMakefile::ExpandArguments(
   outArgs.reserve(inArgs.size());
   outArgs.reserve(inArgs.size());
   for(i = inArgs.begin(); i != inArgs.end(); ++i)
   for(i = inArgs.begin(); i != inArgs.end(); ++i)
     {
     {
+    // No expansion in a bracket argument.
+    if(i->Delim == cmListFileArgument::Bracket)
+      {
+      outArgs.push_back(i->Value);
+      continue;
+      }
     // Expand the variables in the argument.
     // Expand the variables in the argument.
     value = i->Value;
     value = i->Value;
     this->ExpandVariablesInString(value, false, false, false,
     this->ExpandVariablesInString(value, false, false, false,

+ 1 - 0
Tests/RunCMake/Syntax/.gitattributes

@@ -1,2 +1,3 @@
 CommandTabs.cmake   whitespace=-tab-in-indent
 CommandTabs.cmake   whitespace=-tab-in-indent
 StringCRLF.cmake    whitespace=cr-at-eol      -crlf
 StringCRLF.cmake    whitespace=cr-at-eol      -crlf
+BracketCRLF.cmake   whitespace=cr-at-eol      -crlf

+ 1 - 0
Tests/RunCMake/Syntax/Bracket0-stderr.txt

@@ -0,0 +1 @@
+^1 \${var} \\n 4$

+ 1 - 0
Tests/RunCMake/Syntax/Bracket0.cmake

@@ -0,0 +1 @@
+message([[1 ${var} \n 4]])

+ 1 - 0
Tests/RunCMake/Syntax/Bracket1-stderr.txt

@@ -0,0 +1 @@
+^1 \${var} \\n 4\]==$

+ 2 - 0
Tests/RunCMake/Syntax/Bracket1.cmake

@@ -0,0 +1,2 @@
+message([==[1 ]==] [=[
+${var} \n 4]==]=])

+ 2 - 0
Tests/RunCMake/Syntax/Bracket2-stdout.txt

@@ -0,0 +1,2 @@
+-- Bracket Argument 1
+-- Bracket Argument 2

+ 2 - 0
Tests/RunCMake/Syntax/Bracket2.cmake

@@ -0,0 +1,2 @@
+message(STATUS [[Bracket Argument 1]] #[[Bracket Comment 1]])
+message(STATUS #[[Bracket Comment 2]] [[Bracket Argument 2]])

+ 1 - 0
Tests/RunCMake/Syntax/BracketBackslash-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/BracketBackslash-stderr.txt

@@ -0,0 +1,6 @@
+CMake Error at BracketBackslash.cmake:1 \(message\):
+  a\\
+
+  b
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$

+ 2 - 0
Tests/RunCMake/Syntax/BracketBackslash.cmake

@@ -0,0 +1,2 @@
+message(FATAL_ERROR [==[a\
+b]==])

+ 1 - 0
Tests/RunCMake/Syntax/BracketCRLF-stderr.txt

@@ -0,0 +1 @@
+CRLF->LF worked

+ 8 - 0
Tests/RunCMake/Syntax/BracketCRLF.cmake

@@ -0,0 +1,8 @@
+if([[
+]] STREQUAL "" AND
+[[a
+b]] STREQUAL "a\nb")
+  message("CRLF->LF worked")
+else()
+  message(FATAL_ERROR "CRLF->LF failed")
+endif()

+ 1 - 0
Tests/RunCMake/Syntax/BracketComment0-stdout.txt

@@ -0,0 +1 @@
+-- The above FATAL_ERROR did not occur.

+ 5 - 0
Tests/RunCMake/Syntax/BracketComment0.cmake

@@ -0,0 +1,5 @@
+#[=[
+#]]
+message(FATAL_ERROR "This is commented out.")
+#]==]=]
+message(STATUS "The above FATAL_ERROR did not occur.")

+ 1 - 0
Tests/RunCMake/Syntax/BracketComment1-result.txt

@@ -0,0 +1 @@
+1

+ 4 - 0
Tests/RunCMake/Syntax/BracketComment1-stderr.txt

@@ -0,0 +1,4 @@
+CMake Error at BracketComment1.cmake:2 \(message\):
+  This is not commented out.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)

+ 3 - 0
Tests/RunCMake/Syntax/BracketComment1.cmake

@@ -0,0 +1,3 @@
+##[[
+message(FATAL_ERROR "This is not commented out.")
+#]]

+ 1 - 0
Tests/RunCMake/Syntax/BracketComment2-result.txt

@@ -0,0 +1 @@
+1

+ 4 - 0
Tests/RunCMake/Syntax/BracketComment2-stderr.txt

@@ -0,0 +1,4 @@
+CMake Error at BracketComment2.cmake:2 \(message\):
+  This is not commented out.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)

+ 3 - 0
Tests/RunCMake/Syntax/BracketComment2.cmake

@@ -0,0 +1,3 @@
+# [[
+message(FATAL_ERROR "This is not commented out.")
+#]]

+ 1 - 0
Tests/RunCMake/Syntax/BracketComment3-stdout.txt

@@ -0,0 +1 @@
+-- The above FATAL_ERROR did not occur.

+ 4 - 0
Tests/RunCMake/Syntax/BracketComment3.cmake

@@ -0,0 +1,4 @@
+#[[Text on opening line
+message(FATAL_ERROR "This is commented out.")
+#]=]]
+message(STATUS "The above FATAL_ERROR did not occur.")

+ 1 - 0
Tests/RunCMake/Syntax/BracketComment4-result.txt

@@ -0,0 +1 @@
+1

+ 7 - 0
Tests/RunCMake/Syntax/BracketComment4-stderr.txt

@@ -0,0 +1,7 @@
+CMake Error: Error in cmake code at
+.*/Tests/RunCMake/Syntax/BracketComment4.cmake:3:
+Parse error.  Expected a newline, got identifier with text "message".
+CMake Error at CMakeLists.txt:3 \(include\):
+  include could not find load file:
+
+    BracketComment4.cmake

+ 3 - 0
Tests/RunCMake/Syntax/BracketComment4.cmake

@@ -0,0 +1,3 @@
+#[[
+message(FATAL_ERROR "This is commented out.")
+#]] message(STATUS "This command not allowed here")

+ 1 - 0
Tests/RunCMake/Syntax/BracketComment5-stdout.txt

@@ -0,0 +1 @@
+-- The above FATAL_ERROR did not occur.

+ 6 - 0
Tests/RunCMake/Syntax/BracketComment5.cmake

@@ -0,0 +1,6 @@
+#[[
+message(FATAL_ERROR "This is commented out.")
+#]] #[[
+message(FATAL_ERROR "This is commented out.")
+#]] #message(FATAL_ERROR "This is commented out.")
+message(STATUS "The above FATAL_ERROR did not occur.")

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace0-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt

@@ -0,0 +1,6 @@
+CMake Error at CMakeLists.txt:3 \(include\):
+  Syntax Error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/BracketNoSpace0.cmake:1:27
+
+  Argument not separated from preceding token by whitespace.

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace0.cmake

@@ -0,0 +1 @@
+message(STATUS [[bracket]]unquoted)

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace1-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt

@@ -0,0 +1,6 @@
+CMake Error at CMakeLists.txt:3 \(include\):
+  Syntax Error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/BracketNoSpace1.cmake:1:24
+
+  Argument not separated from preceding token by whitespace.

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace1.cmake

@@ -0,0 +1 @@
+message(STATUS "string"[[bracket]])

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace2-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt

@@ -0,0 +1,6 @@
+CMake Error at CMakeLists.txt:3 \(include\):
+  Syntax Error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/BracketNoSpace2.cmake:1:44
+
+  Argument not separated from preceding token by whitespace.

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace2.cmake

@@ -0,0 +1 @@
+message(STATUS "string"#[[bracket comment]][[bracket]])

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace3-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt

@@ -0,0 +1,6 @@
+CMake Error at CMakeLists.txt:3 \(include\):
+  Syntax Error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/BracketNoSpace3.cmake:1:45
+
+  Argument not separated from preceding token by whitespace.

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace3.cmake

@@ -0,0 +1 @@
+message(STATUS "string" #[[bracket comment]][[bracket]])

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace4-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt

@@ -0,0 +1,6 @@
+CMake Error at CMakeLists.txt:3 \(include\):
+  Syntax Error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/BracketNoSpace4.cmake:1:44
+
+  Argument not separated from preceding token by whitespace.

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace4.cmake

@@ -0,0 +1 @@
+message(STATUS "string"#[[bracket comment]]"string")

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace5-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt

@@ -0,0 +1,6 @@
+CMake Error at CMakeLists.txt:3 \(include\):
+  Syntax Error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/BracketNoSpace5.cmake:1:45
+
+  Argument not separated from preceding token by whitespace.

+ 1 - 0
Tests/RunCMake/Syntax/BracketNoSpace5.cmake

@@ -0,0 +1 @@
+message(STATUS "string" #[[bracket comment]]"string")

+ 0 - 35
Tests/RunCMake/Syntax/BracketWarn-stderr.txt

@@ -1,35 +0,0 @@
-CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
-  Syntax Warning in cmake code at
-
-    .*/Tests/RunCMake/Syntax/BracketWarn.cmake:1:16
-
-  A future version of CMake may treat unquoted argument:
-
-    \[\[
-
-  as an opening long bracket.  Double-quote the argument.
-This warning is for project developers.  Use -Wno-dev to suppress it.
-
-CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
-  Syntax Warning in cmake code at
-
-    .*/Tests/RunCMake/Syntax/BracketWarn.cmake:1:19
-
-  A future version of CMake may treat unquoted argument:
-
-    \[=\[
-
-  as an opening long bracket.  Double-quote the argument.
-This warning is for project developers.  Use -Wno-dev to suppress it.
-
-CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
-  Syntax Warning in cmake code at
-
-    .*/Tests/RunCMake/Syntax/BracketWarn.cmake:1:27
-
-  A future version of CMake may treat unquoted argument:
-
-    \[==\[x
-
-  as an opening long bracket.  Double-quote the argument.
-This warning is for project developers.  Use -Wno-dev to suppress it.

+ 0 - 1
Tests/RunCMake/Syntax/BracketWarn-stdout.txt

@@ -1 +0,0 @@
--- \[\[\[=\[\[=x\[==\[x

+ 0 - 1
Tests/RunCMake/Syntax/BracketWarn.cmake

@@ -1 +0,0 @@
-message(STATUS [[ [=[ [=x [==[x)

+ 1 - 0
Tests/RunCMake/Syntax/CommandError2-result.txt

@@ -0,0 +1 @@
+1

+ 7 - 0
Tests/RunCMake/Syntax/CommandError2-stderr.txt

@@ -0,0 +1,7 @@
+CMake Error: Error in cmake code at
+.*/Tests/RunCMake/Syntax/CommandError2.cmake:1:
+Parse error.  Expected a command name, got bracket argument with text "oops-not-a-comment".
+CMake Error at CMakeLists.txt:3 \(include\):
+  include could not find load file:
+
+    CommandError2.cmake

+ 1 - 0
Tests/RunCMake/Syntax/CommandError2.cmake

@@ -0,0 +1 @@
+message("Example Message") [[oops-not-a-comment]]

+ 3 - 0
Tests/RunCMake/Syntax/ParenNoSpace0-stdout.txt

@@ -0,0 +1,3 @@
+-- \(unquoted\)
+-- \(quoted\)
+-- \(bracket\)

+ 3 - 0
Tests/RunCMake/Syntax/ParenNoSpace0.cmake

@@ -0,0 +1,3 @@
+message(STATUS (unquoted))
+message(STATUS ("quoted"))
+message(STATUS ([[bracket]]))

+ 1 - 0
Tests/RunCMake/Syntax/ParenNoSpace1-result.txt

@@ -0,0 +1 @@
+1

+ 22 - 0
Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt

@@ -0,0 +1,22 @@
+CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
+  Syntax Warning in cmake code at
+
+    .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:1:26
+
+  Argument not separated from preceding token by whitespace.
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
+  Syntax Warning in cmake code at
+
+    .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:2:26
+
+  Argument not separated from preceding token by whitespace.
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+CMake Error at CMakeLists.txt:3 \(include\):
+  Syntax Error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:3:29
+
+  Argument not separated from preceding token by whitespace.

+ 3 - 0
Tests/RunCMake/Syntax/ParenNoSpace1.cmake

@@ -0,0 +1,3 @@
+message(STATUS (unquoted)unquoted)
+message(STATUS ("quoted")"quoted")
+message(STATUS ([[bracket]])[[bracket]])

+ 0 - 0
Tests/RunCMake/Syntax/ParenNoSpace-stderr.txt → Tests/RunCMake/Syntax/ParenNoSpace2-stderr.txt


+ 1 - 0
Tests/RunCMake/Syntax/ParenNoSpace-stdout.txt → Tests/RunCMake/Syntax/ParenNoSpace2-stdout.txt

@@ -1,2 +1,3 @@
 -- unquoted\(unquoted\)
 -- unquoted\(unquoted\)
 -- quoted\(quoted\)
 -- quoted\(quoted\)
+-- bracket\(bracket\)

+ 1 - 0
Tests/RunCMake/Syntax/ParenNoSpace.cmake → Tests/RunCMake/Syntax/ParenNoSpace2.cmake

@@ -1,2 +1,3 @@
 message(STATUS unquoted(unquoted))
 message(STATUS unquoted(unquoted))
 message(STATUS "quoted"("quoted"))
 message(STATUS "quoted"("quoted"))
+message(STATUS [[bracket]]([[bracket]]))

+ 24 - 2
Tests/RunCMake/Syntax/RunCMakeTest.cmake

@@ -11,6 +11,7 @@ run_cmake(CommandNewlines)
 run_cmake(CommandComments)
 run_cmake(CommandComments)
 run_cmake(CommandError0)
 run_cmake(CommandError0)
 run_cmake(CommandError1)
 run_cmake(CommandError1)
+run_cmake(CommandError2)
 run_cmake(String0)
 run_cmake(String0)
 run_cmake(String1)
 run_cmake(String1)
 run_cmake(StringCRLF)
 run_cmake(StringCRLF)
@@ -18,8 +19,29 @@ run_cmake(StringNoSpace)
 run_cmake(OneLetter)
 run_cmake(OneLetter)
 run_cmake(Unquoted0)
 run_cmake(Unquoted0)
 run_cmake(Unquoted1)
 run_cmake(Unquoted1)
-run_cmake(ParenNoSpace)
+run_cmake(Bracket0)
+run_cmake(Bracket1)
+run_cmake(Bracket2)
+run_cmake(BracketBackslash)
+run_cmake(BracketCRLF)
+run_cmake(BracketComment0)
+run_cmake(BracketComment1)
+run_cmake(BracketComment2)
+run_cmake(BracketComment3)
+run_cmake(BracketComment4)
+run_cmake(BracketComment5)
+run_cmake(BracketNoSpace0)
+run_cmake(BracketNoSpace1)
+run_cmake(BracketNoSpace2)
+run_cmake(BracketNoSpace3)
+run_cmake(BracketNoSpace4)
+run_cmake(BracketNoSpace5)
+run_cmake(ParenNoSpace0)
+run_cmake(ParenNoSpace1)
+run_cmake(ParenNoSpace2)
 run_cmake(UnterminatedCall1)
 run_cmake(UnterminatedCall1)
 run_cmake(UnterminatedCall2)
 run_cmake(UnterminatedCall2)
 run_cmake(UnterminatedString)
 run_cmake(UnterminatedString)
-run_cmake(BracketWarn)
+run_cmake(UnterminatedBracket0)
+run_cmake(UnterminatedBracket1)
+run_cmake(UnterminatedBracketComment)

+ 1 - 0
Tests/RunCMake/Syntax/UnterminatedBracket0-result.txt

@@ -0,0 +1 @@
+1

+ 8 - 0
Tests/RunCMake/Syntax/UnterminatedBracket0-stderr.txt

@@ -0,0 +1,8 @@
+CMake Error: Error in cmake code at
+.*/Syntax/UnterminatedBracket0.cmake:2:
+Parse error.  Function missing ending "\)".  Instead found unterminated bracket with text "\)
+".
+CMake Error at CMakeLists.txt:3 \(include\):
+  include could not find load file:
+
+    UnterminatedBracket0.cmake$

+ 1 - 0
Tests/RunCMake/Syntax/UnterminatedBracket0.cmake

@@ -0,0 +1 @@
+set(var [[)

+ 1 - 0
Tests/RunCMake/Syntax/UnterminatedBracket1-result.txt

@@ -0,0 +1 @@
+1

+ 8 - 0
Tests/RunCMake/Syntax/UnterminatedBracket1-stderr.txt

@@ -0,0 +1,8 @@
+CMake Error: Error in cmake code at
+.*/Syntax/UnterminatedBracket1.cmake:2:
+Parse error.  Function missing ending "\)".  Instead found unterminated bracket with text "\]\]\)
+".
+CMake Error at CMakeLists.txt:3 \(include\):
+  include could not find load file:
+
+    UnterminatedBracket1.cmake$

+ 1 - 0
Tests/RunCMake/Syntax/UnterminatedBracket1.cmake

@@ -0,0 +1 @@
+set(var [=[]])

+ 1 - 0
Tests/RunCMake/Syntax/UnterminatedBracketComment-result.txt

@@ -0,0 +1 @@
+1

+ 8 - 0
Tests/RunCMake/Syntax/UnterminatedBracketComment-stderr.txt

@@ -0,0 +1,8 @@
+CMake Error: Error in cmake code at
+.*/Syntax/UnterminatedBracketComment.cmake:1:
+Parse error.  Expected a command name, got unterminated bracket with text "#\]\]
+".
+CMake Error at CMakeLists.txt:3 \(include\):
+  include could not find load file:
+
+    UnterminatedBracketComment.cmake

+ 2 - 0
Tests/RunCMake/Syntax/UnterminatedBracketComment.cmake

@@ -0,0 +1,2 @@
+#[=[
+#]]