Commit 19e89153 authored by Ken Martin's avatar Ken Martin

ENH: support parenthesis as arguments and in conditionals feature request #6191

parent d8e05b43
This diff is collapsed.
......@@ -242,11 +242,26 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
// Arguments.
unsigned long lastLine = cmListFileLexer_GetCurrentLine(lexer);
unsigned long parenDepth = 0;
while((token = cmListFileLexer_Scan(lexer)))
{
if(token->type == cmListFileLexer_Token_ParenRight)
if(token->type == cmListFileLexer_Token_ParenLeft)
{
return true;
parenDepth++;
cmListFileArgument a("(",
false, filename, token->line);
function.Arguments.push_back(a);
}
else if(token->type == cmListFileLexer_Token_ParenRight)
{
if (parenDepth == 0)
{
return true;
}
parenDepth--;
cmListFileArgument a(")",
false, filename, token->line);
function.Arguments.push_back(a);
}
else if(token->type == cmListFileLexer_Token_Identifier ||
token->type == cmListFileLexer_Token_ArgumentUnquoted)
......
......@@ -336,6 +336,12 @@ if (NOT ELSEIF_RESULT EQUAL 2)
set (ELSEIF_RESULT 0)
endif (NOT ELSEIF_RESULT EQUAL 2)
# test handling of parenthetical groups in conditionals
if (2 GREATER 1 AND (4 LESS 3 OR 5 LESS 6) AND NOT (7 GREATER 8))
set(CONDITIONAL_PARENTHESES 1)
endif()
#
# Configure file
# (plug vars to #define so that they can be tested)
......
......@@ -369,6 +369,12 @@ int main()
cmFailed("ELSEIF did not work");
#endif
#ifdef CONDITIONAL_PARENTHESES
cmPassed("CONDITIONAL_PARENTHESES did work");
#else
cmFailed("CONDITIONAL_PARENTHESES did not work");
#endif
if(file2() != 1)
{
cmFailed("Call to file2 function from library failed.");
......
......@@ -81,3 +81,7 @@
// test elseif
#cmakedefine ELSEIF_RESULT
// test parenthesis in conditionals
#cmakedefine CONDITIONAL_PARENTHESES
......@@ -336,6 +336,12 @@ if (NOT ELSEIF_RESULT EQUAL 2)
set (ELSEIF_RESULT 0)
endif (NOT ELSEIF_RESULT EQUAL 2)
# test handling of parenthetical groups in conditionals
if (2 GREATER 1 AND (4 LESS 3 OR 5 LESS 6) AND NOT (7 GREATER 8))
set(CONDITIONAL_PARENTHESES 1)
endif()
#
# Configure file
# (plug vars to #define so that they can be tested)
......
......@@ -369,6 +369,12 @@ int main()
cmFailed("ELSEIF did not work");
#endif
#ifdef CONDITIONAL_PARENTHESES
cmPassed("CONDITIONAL_PARENTHESES did work");
#else
cmFailed("CONDITIONAL_PARENTHESES did not work");
#endif
if(file2() != 1)
{
cmFailed("Call to file2 function from library failed.");
......
......@@ -81,3 +81,7 @@
// test elseif
#cmakedefine ELSEIF_RESULT
// test parenthesis in conditionals
#cmakedefine CONDITIONAL_PARENTHESES
......@@ -336,6 +336,12 @@ if (NOT ELSEIF_RESULT EQUAL 2)
set (ELSEIF_RESULT 0)
endif (NOT ELSEIF_RESULT EQUAL 2)
# test handling of parenthetical groups in conditionals
if (2 GREATER 1 AND (4 LESS 3 OR 5 LESS 6) AND NOT (7 GREATER 8))
set(CONDITIONAL_PARENTHESES 1)
endif()
#
# Configure file
# (plug vars to #define so that they can be tested)
......
......@@ -369,6 +369,12 @@ int main()
cmFailed("ELSEIF did not work");
#endif
#ifdef CONDITIONAL_PARENTHESES
cmPassed("CONDITIONAL_PARENTHESES did work");
#else
cmFailed("CONDITIONAL_PARENTHESES did not work");
#endif
if(file2() != 1)
{
cmFailed("Call to file2 function from library failed.");
......
......@@ -81,3 +81,7 @@
// test elseif
#cmakedefine ELSEIF_RESULT
// test parenthesis in conditionals
#cmakedefine CONDITIONAL_PARENTHESES
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment