2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2001-08-29 02:28:31 +04:00
|
|
|
#include "cmListFileCache.h"
|
2003-12-08 21:36:59 +03:00
|
|
|
|
|
|
|
#include "cmListFileLexer.h"
|
2001-08-29 02:28:31 +04:00
|
|
|
#include "cmSystemTools.h"
|
2008-03-06 18:57:59 +03:00
|
|
|
#include "cmMakefile.h"
|
2008-03-19 22:18:21 +03:00
|
|
|
#include "cmVersion.h"
|
2003-06-23 22:10:12 +04:00
|
|
|
|
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2001-08-29 02:28:31 +04:00
|
|
|
|
2006-08-01 19:38:42 +04:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
# pragma warn -8060 /* possibly incorrect assignment */
|
|
|
|
#endif
|
|
|
|
|
2013-02-17 05:14:23 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct cmListFileParser
|
|
|
|
{
|
|
|
|
cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
|
|
|
|
~cmListFileParser();
|
|
|
|
bool ParseFile();
|
|
|
|
bool ParseFunction(const char* name, long line);
|
2013-08-06 23:58:22 +04:00
|
|
|
bool AddArgument(cmListFileLexer_Token* token,
|
2013-02-17 05:14:23 +04:00
|
|
|
cmListFileArgument::Delimiter delim);
|
|
|
|
cmListFile* ListFile;
|
|
|
|
cmMakefile* Makefile;
|
|
|
|
const char* FileName;
|
|
|
|
cmListFileLexer* Lexer;
|
|
|
|
cmListFileFunction Function;
|
2013-08-06 23:58:22 +04:00
|
|
|
enum { SeparationOkay, SeparationWarning, SeparationError} Separation;
|
2013-02-17 05:14:23 +04:00
|
|
|
};
|
2003-12-08 21:36:59 +03:00
|
|
|
|
2013-02-17 05:14:23 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmListFileParser::cmListFileParser(cmListFile* lf, cmMakefile* mf,
|
|
|
|
const char* filename):
|
|
|
|
ListFile(lf), Makefile(mf), FileName(filename),
|
|
|
|
Lexer(cmListFileLexer_New())
|
2001-08-29 02:28:31 +04:00
|
|
|
{
|
2013-02-17 05:14:23 +04:00
|
|
|
}
|
2004-08-04 18:45:11 +04:00
|
|
|
|
2013-02-17 05:14:23 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmListFileParser::~cmListFileParser()
|
|
|
|
{
|
|
|
|
cmListFileLexer_Delete(this->Lexer);
|
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
|
2013-02-17 05:14:23 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmListFileParser::ParseFile()
|
|
|
|
{
|
2003-12-08 21:36:59 +03:00
|
|
|
// Open the file.
|
2013-10-14 23:13:11 +04:00
|
|
|
cmListFileLexer_BOM bom;
|
|
|
|
if(!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom))
|
2003-12-08 21:36:59 +03:00
|
|
|
{
|
2012-08-13 21:42:58 +04:00
|
|
|
cmSystemTools::Error("cmListFileCache: error can not open file ",
|
2013-02-17 05:14:23 +04:00
|
|
|
this->FileName);
|
2001-08-29 02:28:31 +04:00
|
|
|
return false;
|
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
|
2013-10-14 23:13:11 +04:00
|
|
|
// Verify the Byte-Order-Mark, if any.
|
|
|
|
if(bom != cmListFileLexer_BOM_None &&
|
|
|
|
bom != cmListFileLexer_BOM_UTF8)
|
|
|
|
{
|
|
|
|
cmListFileLexer_SetFileName(this->Lexer, 0, 0);
|
|
|
|
cmOStringStream m;
|
|
|
|
m << "File\n " << this->FileName << "\n"
|
|
|
|
<< "starts with a Byte-Order-Mark that is not UTF-8.";
|
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-12-08 21:36:59 +03:00
|
|
|
// Use a simple recursive-descent parser to process the token
|
|
|
|
// stream.
|
|
|
|
bool haveNewline = true;
|
2013-02-17 05:14:23 +04:00
|
|
|
while(cmListFileLexer_Token* token =
|
|
|
|
cmListFileLexer_Scan(this->Lexer))
|
2001-08-29 02:28:31 +04:00
|
|
|
{
|
2013-02-17 05:41:47 +04:00
|
|
|
if(token->type == cmListFileLexer_Token_Space)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else if(token->type == cmListFileLexer_Token_Newline)
|
2001-08-29 02:28:31 +04:00
|
|
|
{
|
2003-12-08 21:36:59 +03:00
|
|
|
haveNewline = true;
|
2001-08-29 02:28:31 +04:00
|
|
|
}
|
2013-08-06 23:58:22 +04:00
|
|
|
else if(token->type == cmListFileLexer_Token_CommentBracket)
|
|
|
|
{
|
|
|
|
haveNewline = false;
|
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
else if(token->type == cmListFileLexer_Token_Identifier)
|
2001-11-30 00:44:22 +03:00
|
|
|
{
|
2003-12-08 21:36:59 +03:00
|
|
|
if(haveNewline)
|
|
|
|
{
|
|
|
|
haveNewline = false;
|
2013-02-17 05:14:23 +04:00
|
|
|
if(this->ParseFunction(token->text, token->line))
|
2003-12-08 21:36:59 +03:00
|
|
|
{
|
2013-02-17 05:14:23 +04:00
|
|
|
this->ListFile->Functions.push_back(this->Function);
|
2003-12-08 21:36:59 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-17 05:14:23 +04:00
|
|
|
return false;
|
2003-12-08 21:36:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream error;
|
|
|
|
error << "Error in cmake code at\n"
|
2013-02-17 05:14:23 +04:00
|
|
|
<< this->FileName << ":" << token->line << ":\n"
|
2004-09-01 02:39:42 +04:00
|
|
|
<< "Parse error. Expected a newline, got "
|
2013-02-17 05:14:23 +04:00
|
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
2004-09-01 02:39:42 +04:00
|
|
|
<< " with text \"" << token->text << "\".";
|
2003-12-08 21:36:59 +03:00
|
|
|
cmSystemTools::Error(error.str().c_str());
|
2013-02-17 05:14:23 +04:00
|
|
|
return false;
|
2003-12-08 21:36:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream error;
|
|
|
|
error << "Error in cmake code at\n"
|
2013-02-17 05:14:23 +04:00
|
|
|
<< this->FileName << ":" << token->line << ":\n"
|
2004-09-01 02:39:42 +04:00
|
|
|
<< "Parse error. Expected a command name, got "
|
2013-02-17 05:14:23 +04:00
|
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
2004-09-01 02:39:42 +04:00
|
|
|
<< " with text \""
|
2003-12-08 21:36:59 +03:00
|
|
|
<< token->text << "\".";
|
|
|
|
cmSystemTools::Error(error.str().c_str());
|
2013-02-17 05:14:23 +04:00
|
|
|
return false;
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2001-08-29 02:28:31 +04:00
|
|
|
}
|
2013-02-17 05:14:23 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmListFile::ParseFile(const char* filename,
|
|
|
|
bool topLevel,
|
|
|
|
cmMakefile *mf)
|
|
|
|
{
|
|
|
|
if(!cmSystemTools::FileExists(filename))
|
2003-12-08 21:36:59 +03:00
|
|
|
{
|
2013-02-17 05:14:23 +04:00
|
|
|
return false;
|
2003-12-08 21:36:59 +03:00
|
|
|
}
|
|
|
|
|
2013-02-17 05:14:23 +04:00
|
|
|
bool parseError = false;
|
|
|
|
this->ModifiedTime = cmSystemTools::ModifiedTime(filename);
|
|
|
|
|
|
|
|
{
|
|
|
|
cmListFileParser parser(this, mf, filename);
|
|
|
|
parseError = !parser.ParseFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parseError)
|
|
|
|
{
|
|
|
|
this->ModifiedTime = 0;
|
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
|
2008-03-06 18:57:59 +03:00
|
|
|
// do we need a cmake_policy(VERSION call?
|
|
|
|
if(topLevel)
|
|
|
|
{
|
2008-03-19 22:18:21 +03:00
|
|
|
bool hasVersion = false;
|
2008-03-06 18:57:59 +03:00
|
|
|
// search for the right policy command
|
2012-08-13 21:42:58 +04:00
|
|
|
for(std::vector<cmListFileFunction>::iterator i
|
2008-03-06 18:57:59 +03:00
|
|
|
= this->Functions.begin();
|
|
|
|
i != this->Functions.end(); ++i)
|
|
|
|
{
|
2008-03-07 19:43:47 +03:00
|
|
|
if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required")
|
|
|
|
{
|
2008-03-19 22:18:21 +03:00
|
|
|
hasVersion = true;
|
2008-03-07 19:43:47 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-03-06 18:57:59 +03:00
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
// if no policy command is found this is an error if they use any
|
2008-04-27 15:01:05 +04:00
|
|
|
// non advanced functions or a lot of functions
|
2008-03-19 22:18:21 +03:00
|
|
|
if(!hasVersion)
|
2008-03-20 17:40:24 +03:00
|
|
|
{
|
|
|
|
bool isProblem = true;
|
|
|
|
if (this->Functions.size() < 30)
|
|
|
|
{
|
|
|
|
// the list of simple commands DO NOT ADD TO THIS LIST!!!!!
|
|
|
|
// these commands must have backwards compatibility forever and
|
|
|
|
// and that is a lot longer than your tiny mind can comprehend mortal
|
|
|
|
std::set<std::string> allowedCommands;
|
|
|
|
allowedCommands.insert("project");
|
|
|
|
allowedCommands.insert("set");
|
|
|
|
allowedCommands.insert("if");
|
|
|
|
allowedCommands.insert("endif");
|
|
|
|
allowedCommands.insert("else");
|
|
|
|
allowedCommands.insert("elseif");
|
|
|
|
allowedCommands.insert("add_executable");
|
|
|
|
allowedCommands.insert("add_library");
|
|
|
|
allowedCommands.insert("target_link_libraries");
|
|
|
|
allowedCommands.insert("option");
|
|
|
|
allowedCommands.insert("message");
|
|
|
|
isProblem = false;
|
2012-08-13 21:42:58 +04:00
|
|
|
for(std::vector<cmListFileFunction>::iterator i
|
2008-03-20 17:40:24 +03:00
|
|
|
= this->Functions.begin();
|
|
|
|
i != this->Functions.end(); ++i)
|
|
|
|
{
|
|
|
|
std::string name = cmSystemTools::LowerCase(i->Name);
|
|
|
|
if (allowedCommands.find(name) == allowedCommands.end())
|
|
|
|
{
|
2008-03-20 17:46:24 +03:00
|
|
|
isProblem = true;
|
|
|
|
break;
|
2012-08-13 21:42:58 +04:00
|
|
|
}
|
2008-03-20 17:40:24 +03:00
|
|
|
}
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2008-03-20 17:40:24 +03:00
|
|
|
if (isProblem)
|
2008-03-06 18:57:59 +03:00
|
|
|
{
|
2008-03-31 21:33:09 +04:00
|
|
|
// Tell the top level cmMakefile to diagnose
|
|
|
|
// this violation of CMP0000.
|
|
|
|
mf->SetCheckCMP0000(true);
|
|
|
|
|
|
|
|
// Implicitly set the version for the user.
|
|
|
|
mf->SetPolicyVersion("2.4");
|
2008-03-06 18:57:59 +03:00
|
|
|
}
|
2008-03-20 17:40:24 +03:00
|
|
|
}
|
2008-03-06 18:57:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if(topLevel)
|
2002-12-02 23:30:59 +03:00
|
|
|
{
|
|
|
|
bool hasProject = false;
|
|
|
|
// search for a project command
|
2012-08-13 21:42:58 +04:00
|
|
|
for(std::vector<cmListFileFunction>::iterator i
|
2006-03-15 19:02:08 +03:00
|
|
|
= this->Functions.begin();
|
|
|
|
i != this->Functions.end(); ++i)
|
2002-12-02 23:30:59 +03:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
if(cmSystemTools::LowerCase(i->Name) == "project")
|
2002-12-02 23:30:59 +03:00
|
|
|
{
|
|
|
|
hasProject = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if no project command is found, add one
|
|
|
|
if(!hasProject)
|
|
|
|
{
|
|
|
|
cmListFileFunction project;
|
2006-03-15 19:02:08 +03:00
|
|
|
project.Name = "PROJECT";
|
2012-08-06 18:07:58 +04:00
|
|
|
cmListFileArgument prj("Project", cmListFileArgument::Unquoted,
|
|
|
|
filename, 0);
|
2006-03-15 19:02:08 +03:00
|
|
|
project.Arguments.push_back(prj);
|
|
|
|
this->Functions.insert(this->Functions.begin(),project);
|
2002-12-02 23:30:59 +03:00
|
|
|
}
|
|
|
|
}
|
2007-11-19 21:42:05 +03:00
|
|
|
if(parseError)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2001-08-29 02:28:31 +04:00
|
|
|
return true;
|
|
|
|
}
|
2002-09-19 22:34:15 +04:00
|
|
|
|
2013-02-17 05:14:23 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmListFileParser::ParseFunction(const char* name, long line)
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2013-02-17 05:14:23 +04:00
|
|
|
// Inintialize a new function call.
|
|
|
|
this->Function = cmListFileFunction();
|
|
|
|
this->Function.FilePath = this->FileName;
|
|
|
|
this->Function.Name = name;
|
|
|
|
this->Function.Line = line;
|
|
|
|
|
2003-12-08 21:36:59 +03:00
|
|
|
// Command name has already been parsed. Read the left paren.
|
|
|
|
cmListFileLexer_Token* token;
|
2013-02-17 05:41:47 +04:00
|
|
|
while((token = cmListFileLexer_Scan(this->Lexer)) &&
|
|
|
|
token->type == cmListFileLexer_Token_Space) {}
|
|
|
|
if(!token)
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2003-12-08 21:36:59 +03:00
|
|
|
cmOStringStream error;
|
2013-02-17 05:14:23 +04:00
|
|
|
error << "Error in cmake code at\n" << this->FileName << ":"
|
|
|
|
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
2003-12-08 21:36:59 +03:00
|
|
|
<< "Parse error. Function missing opening \"(\".";
|
|
|
|
cmSystemTools::Error(error.str().c_str());
|
|
|
|
return false;
|
2002-12-12 02:13:33 +03:00
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
if(token->type != cmListFileLexer_Token_ParenLeft)
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2003-12-08 21:36:59 +03:00
|
|
|
cmOStringStream error;
|
2013-02-17 05:14:23 +04:00
|
|
|
error << "Error in cmake code at\n" << this->FileName << ":"
|
|
|
|
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
2004-09-01 02:39:42 +04:00
|
|
|
<< "Parse error. Expected \"(\", got "
|
2013-02-17 05:14:23 +04:00
|
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
2004-09-01 02:39:42 +04:00
|
|
|
<< " with text \"" << token->text << "\".";
|
2003-12-08 21:36:59 +03:00
|
|
|
cmSystemTools::Error(error.str().c_str());
|
2002-12-12 02:13:33 +03:00
|
|
|
return false;
|
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
|
|
|
|
// Arguments.
|
2013-02-17 05:41:47 +04:00
|
|
|
unsigned long lastLine;
|
2008-06-26 21:01:35 +04:00
|
|
|
unsigned long parenDepth = 0;
|
2013-02-17 05:41:47 +04:00
|
|
|
this->Separation = SeparationOkay;
|
|
|
|
while((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer),
|
|
|
|
token = cmListFileLexer_Scan(this->Lexer)))
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2013-02-17 05:41:47 +04:00
|
|
|
if(token->type == cmListFileLexer_Token_Space ||
|
|
|
|
token->type == cmListFileLexer_Token_Newline)
|
|
|
|
{
|
|
|
|
this->Separation = SeparationOkay;
|
|
|
|
continue;
|
|
|
|
}
|
2008-06-26 21:01:35 +04:00
|
|
|
if(token->type == cmListFileLexer_Token_ParenLeft)
|
2003-07-10 01:17:34 +04:00
|
|
|
{
|
2008-06-26 21:01:35 +04:00
|
|
|
parenDepth++;
|
2013-02-17 05:41:47 +04:00
|
|
|
this->Separation = SeparationOkay;
|
2013-08-06 23:58:22 +04:00
|
|
|
if(!this->AddArgument(token, cmListFileArgument::Unquoted))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-06-26 21:01:35 +04:00
|
|
|
}
|
|
|
|
else if(token->type == cmListFileLexer_Token_ParenRight)
|
|
|
|
{
|
|
|
|
if (parenDepth == 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
parenDepth--;
|
2013-02-17 05:41:47 +04:00
|
|
|
this->Separation = SeparationOkay;
|
2013-08-06 23:58:22 +04:00
|
|
|
if(!this->AddArgument(token, cmListFileArgument::Unquoted))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-02-17 05:41:47 +04:00
|
|
|
this->Separation = SeparationWarning;
|
2003-07-10 01:17:34 +04:00
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
else if(token->type == cmListFileLexer_Token_Identifier ||
|
|
|
|
token->type == cmListFileLexer_Token_ArgumentUnquoted)
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2013-08-06 23:58:22 +04:00
|
|
|
if(!this->AddArgument(token, cmListFileArgument::Unquoted))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-02-17 05:41:47 +04:00
|
|
|
this->Separation = SeparationWarning;
|
2002-12-12 02:13:33 +03:00
|
|
|
}
|
2003-12-08 21:36:59 +03:00
|
|
|
else if(token->type == cmListFileLexer_Token_ArgumentQuoted)
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2013-08-06 23:58:22 +04:00
|
|
|
if(!this->AddArgument(token, cmListFileArgument::Quoted))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-02-17 05:41:47 +04:00
|
|
|
this->Separation = SeparationWarning;
|
2002-12-12 02:13:33 +03:00
|
|
|
}
|
2013-08-06 23:58:22 +04:00
|
|
|
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;
|
|
|
|
}
|
2013-02-17 05:41:47 +04:00
|
|
|
else
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2003-12-08 21:36:59 +03:00
|
|
|
// Error.
|
2002-12-12 19:36:28 +03:00
|
|
|
cmOStringStream error;
|
2013-02-17 05:14:23 +04:00
|
|
|
error << "Error in cmake code at\n" << this->FileName << ":"
|
|
|
|
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
2003-12-08 21:36:59 +03:00
|
|
|
<< "Parse error. Function missing ending \")\". "
|
2004-09-01 02:39:42 +04:00
|
|
|
<< "Instead found "
|
2013-02-17 05:14:23 +04:00
|
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
2004-09-01 02:39:42 +04:00
|
|
|
<< " with text \"" << token->text << "\".";
|
2002-12-12 19:36:28 +03:00
|
|
|
cmSystemTools::Error(error.str().c_str());
|
2002-12-12 02:13:33 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-08 21:36:59 +03:00
|
|
|
cmOStringStream error;
|
|
|
|
error << "Error in cmake code at\n"
|
2013-02-17 05:14:23 +04:00
|
|
|
<< this->FileName << ":" << lastLine << ":\n"
|
2003-12-08 21:36:59 +03:00
|
|
|
<< "Parse error. Function missing ending \")\". "
|
|
|
|
<< "End of file reached.";
|
|
|
|
cmSystemTools::Error(error.str().c_str());
|
2002-12-12 02:13:33 +03:00
|
|
|
|
2003-12-08 21:36:59 +03:00
|
|
|
return false;
|
2002-12-12 02:13:33 +03:00
|
|
|
}
|
2008-03-13 20:48:57 +03:00
|
|
|
|
2013-02-17 05:14:23 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2013-08-06 23:58:22 +04:00
|
|
|
bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
|
2013-02-17 05:14:23 +04:00
|
|
|
cmListFileArgument::Delimiter delim)
|
|
|
|
{
|
|
|
|
cmListFileArgument a(token->text, delim, this->FileName, token->line);
|
|
|
|
this->Function.Arguments.push_back(a);
|
2013-02-17 05:41:47 +04:00
|
|
|
if(this->Separation == SeparationOkay)
|
|
|
|
{
|
2013-08-06 23:58:22 +04:00
|
|
|
return true;
|
2013-02-17 05:41:47 +04:00
|
|
|
}
|
2013-08-06 23:58:22 +04:00
|
|
|
bool isError = (this->Separation == SeparationError ||
|
|
|
|
delim == cmListFileArgument::Bracket);
|
2013-02-17 05:41:47 +04:00
|
|
|
cmOStringStream m;
|
2013-08-06 23:58:22 +04:00
|
|
|
m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n"
|
2013-02-17 05:41:47 +04:00
|
|
|
<< " " << this->FileName << ":" << token->line << ":"
|
|
|
|
<< token->column << "\n"
|
|
|
|
<< "Argument not separated from preceding token by whitespace.";
|
2013-08-06 23:58:22 +04:00
|
|
|
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;
|
|
|
|
}
|
2013-02-17 05:14:23 +04:00
|
|
|
}
|
|
|
|
|
2008-03-13 20:48:57 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
|
|
|
|
{
|
|
|
|
os << lfc.FilePath;
|
|
|
|
if(lfc.Line)
|
|
|
|
{
|
|
|
|
os << ":" << lfc.Line;
|
|
|
|
if(!lfc.Name.empty())
|
|
|
|
{
|
|
|
|
os << " (" << lfc.Name << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return os;
|
|
|
|
}
|