summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-06-08 18:18:31 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-06-08 18:18:31 (GMT)
commitbbf1c3a0e87c4358b65d41393455fc393d8e16e0 (patch)
treea2bd3776a2947d1caac17f2da80aa29844715077 /Source
parent859b51751811f1b4c160793010cf3ad20c00140d (diff)
downloadCMake-bbf1c3a0e87c4358b65d41393455fc393d8e16e0.zip
CMake-bbf1c3a0e87c4358b65d41393455fc393d8e16e0.tar.gz
CMake-bbf1c3a0e87c4358b65d41393455fc393d8e16e0.tar.bz2
ENH: Handle more cases
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommandArgumentLexer.in.l34
-rw-r--r--Source/cmCommandArgumentParser.y45
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx18
-rw-r--r--Source/cmCommandArgumentParserHelper.h2
4 files changed, 80 insertions, 19 deletions
diff --git a/Source/cmCommandArgumentLexer.in.l b/Source/cmCommandArgumentLexer.in.l
index 0a071fc..fcbfcd8 100644
--- a/Source/cmCommandArgumentLexer.in.l
+++ b/Source/cmCommandArgumentLexer.in.l
@@ -85,31 +85,61 @@ Modify cmCommandArgumentLexer.h:
%%
-"$[A-Za-z0-9_]+{" {
+\$[A-Za-z0-9_]+\{ {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
return cal_NCURLY;
}
+@[A-Za-z0-9_]+@ {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
+ yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
+ return cal_ATNAME;
+}
+
"${" {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
+ yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return cal_DCURLY;
}
"}" {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
+ yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return cal_RCURLY;
}
"@" {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
+ yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return cal_AT;
}
[A-Za-z0-9_]+ {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return cal_NAME;
}
-([^A-Za-z0-9_$}\\@]+|\.) {
+[^A-Za-z0-9_${}\\@]+|\\. {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return cal_SYMBOL;
}
+"$" {
+ yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
+ return cal_DOLLAR;
+}
+
+"{" {
+ yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
+ return cal_LCURLY;
+}
+
+.|\n {
+ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
+ return cal_ERROR;
+}
+
%%
diff --git a/Source/cmCommandArgumentParser.y b/Source/cmCommandArgumentParser.y
index 05a0674..dc1b9ee 100644
--- a/Source/cmCommandArgumentParser.y
+++ b/Source/cmCommandArgumentParser.y
@@ -49,7 +49,7 @@ YY_DECL;
static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
#define YYDEBUG 1
-#define YYMAXDEPTH 1000000
+#define YYMAXDEPTH 10000000
#define calCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp);
@@ -77,11 +77,14 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
/* Tokens */
%token cal_NCURLY
%token cal_DCURLY
+%token cal_DOLLAR
+%token cal_LCURLY
%token cal_RCURLY
%token cal_NAME
%token cal_SYMBOL
%token cal_AT
%token cal_ERROR
+%token cal_ATNAME
/*-------------------------------------------------------------------------*/
/* grammar */
@@ -98,11 +101,10 @@ Goal
}
Goal:
-String
{
- calElementStart(1);
- calCheckEmpty(1);
- $<str>$ = $<str>1;
+ calElementStart(0);
+ calCheckEmpty(0);
+ $<str>$ = 0;
}
|
String Goal
@@ -178,6 +180,27 @@ Text
$<str>$ = $<str>1;
}
|
+cal_AT
+{
+ calElementStart(1);
+ calCheckEmpty(1);
+ $<str>$ = $<str>1;
+}
+|
+cal_DOLLAR
+{
+ calElementStart(1);
+ calCheckEmpty(1);
+ $<str>$ = $<str>1;
+}
+|
+cal_LCURLY
+{
+ calElementStart(1);
+ calCheckEmpty(1);
+ $<str>$ = $<str>1;
+}
+|
cal_RCURLY
{
calElementStart(1);
@@ -191,7 +214,7 @@ cal_NCURLY MultipleIds cal_RCURLY
calElementStart(3);
calCheckEmpty(3);
$<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2);
- std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
+ //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
}
|
cal_DCURLY MultipleIds cal_RCURLY
@@ -199,14 +222,14 @@ cal_DCURLY MultipleIds cal_RCURLY
calElementStart(3);
calCheckEmpty(3);
$<str>$ = yyGetParser->ExpandVariable($<str>2);
- std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
+ //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
}
|
-cal_AT cal_NAME cal_AT
+cal_ATNAME
{
- calElementStart(3);
- calCheckEmpty(3);
- $<str>$ = yyGetParser->ExpandVariable($<str>2);
+ calElementStart(1);
+ calCheckEmpty(1);
+ $<str>$ = yyGetParser->ExpandVariable($<str>1);
}
%%
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 07f5554..e925bf2 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -26,6 +26,8 @@ int cmCommandArgument_yyparse( yyscan_t yyscanner );
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
{
m_FileLine = -1;
+ m_FileName = 0;
+ m_EmptyVariable[0] = 0;
}
@@ -79,17 +81,21 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, cons
char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
{
- if(var == "CMAKE_CURRENT_LIST_FILE")
+ if(m_FileName && strcmp(var, "CMAKE_CURRENT_LIST_FILE") == 0)
{
- return this->AddString(m_FileName.c_str());
+ return this->AddString(m_FileName);
}
- else if(m_FileLine >= 0 && (var == "CMAKE_CURRENT_LIST_LINE"))
+ else if(m_FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0)
{
cmOStringStream ostr;
ostr << m_FileLine;
return this->AddString(ostr.str().c_str());
}
const char* value = m_Makefile->GetDefinition(var);
+ if (m_EscapeQuotes)
+ {
+ return this->AddString(cmSystemTools::EscapeQuotes(value).c_str());
+ }
return this->AddString(value);
}
@@ -228,7 +234,8 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
cmCommandArgument_yylex_destroy(yyscanner);
if ( res != 0 )
{
- std::cout << "JP_Parse returned: " << res << std::endl;
+ std::cerr << "CAL_Parser returned: " << res << std::endl;
+ std::cerr << "When parsing: [" << str << "]" << std::endl;
return 0;
}
@@ -289,7 +296,7 @@ int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen)
void cmCommandArgumentParserHelper::Error(const char* str)
{
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
- fprintf(stderr, "JPError: %s (%lu / Line: %d)\n", str, pos, this->CurrentLine);
+ fprintf(stderr, "Argument Parser Error: %s (%lu / Line: %d)\n", str, pos, this->CurrentLine);
int cc;
std::cerr << "String: [";
for ( cc = 0; cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
@@ -345,6 +352,7 @@ void cmCommandArgumentParserHelper::SetResult(const char* value)
{
if ( !value )
{
+ m_Result = "";
return;
}
m_Result = value;
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 36a9f04..e1d4216 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -101,7 +101,7 @@ private:
char m_EmptyVariable[1];
const cmMakefile* m_Makefile;
std::string m_Result;
- std::string m_FileName;
+ const char* m_FileName;
long m_FileLine;
bool m_EscapeQuotes;