2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2012-09-11 21:53:38 +04:00
|
|
|
#include "cmGeneratorExpressionLexer.h"
|
|
|
|
|
|
|
|
cmGeneratorExpressionLexer::cmGeneratorExpressionLexer()
|
2016-05-16 17:34:04 +03:00
|
|
|
: SawBeginExpression(false)
|
|
|
|
, SawGeneratorExpression(false)
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void InsertText(const char* upto, const char* c,
|
|
|
|
std::vector<cmGeneratorExpressionToken>& result)
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (upto != c) {
|
2012-09-11 21:53:38 +04:00
|
|
|
result.push_back(cmGeneratorExpressionToken(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorExpressionToken::Text, upto, c - upto));
|
|
|
|
}
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmGeneratorExpressionToken> cmGeneratorExpressionLexer::Tokenize(
|
|
|
|
const std::string& input)
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
std::vector<cmGeneratorExpressionToken> result;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* c = input.c_str();
|
|
|
|
const char* upto = c;
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; *c; ++c) {
|
|
|
|
switch (*c) {
|
2014-02-08 21:01:30 +04:00
|
|
|
case '$':
|
2016-05-16 17:34:04 +03:00
|
|
|
if (c[1] == '<') {
|
2014-02-08 21:01:30 +04:00
|
|
|
InsertText(upto, c, result);
|
|
|
|
result.push_back(cmGeneratorExpressionToken(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorExpressionToken::BeginExpression, c, 2));
|
2014-02-08 21:01:30 +04:00
|
|
|
upto = c + 2;
|
|
|
|
++c;
|
|
|
|
SawBeginExpression = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 21:01:30 +04:00
|
|
|
break;
|
|
|
|
case '>':
|
|
|
|
InsertText(upto, c, result);
|
|
|
|
result.push_back(cmGeneratorExpressionToken(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorExpressionToken::EndExpression, c, 1));
|
2014-02-08 21:01:30 +04:00
|
|
|
upto = c + 1;
|
|
|
|
SawGeneratorExpression = SawBeginExpression;
|
|
|
|
break;
|
|
|
|
case ':':
|
|
|
|
InsertText(upto, c, result);
|
|
|
|
result.push_back(cmGeneratorExpressionToken(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorExpressionToken::ColonSeparator, c, 1));
|
2014-02-08 21:01:30 +04:00
|
|
|
upto = c + 1;
|
|
|
|
break;
|
|
|
|
case ',':
|
|
|
|
InsertText(upto, c, result);
|
|
|
|
result.push_back(cmGeneratorExpressionToken(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorExpressionToken::CommaSeparator, c, 1));
|
2014-02-08 21:01:30 +04:00
|
|
|
upto = c + 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
InsertText(upto, c, result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|