Skip to content

Commit

Permalink
Bug 778012 - Python List as Default Parameter not parsed correctly
Browse files Browse the repository at this point in the history
Added handling of square brackets, single quoted strings and double quoted strings (could contain comma's as well) to default values of arguments.
  • Loading branch information
albert-github committed Mar 4, 2018
1 parent fd2e305 commit e5e75b7
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/pyscanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static QCString g_packageName;

//static bool g_hideClassDocs;

static QCString g_defVal;
static QGString g_defVal;
static int g_braceCount;

static bool g_lexInit = FALSE;
Expand Down Expand Up @@ -993,35 +993,49 @@ STARTDOCSYMS "##"
}
<FunctionParamDefVal>{
"(" { // internal opening brace
"[" |
"(" { // internal opening brace, assumption is that we have correct code so braces do match
g_braceCount++;
g_defVal+=*yytext;
}
"," |
"]" |
")" {
if (g_braceCount==0) // end of default argument
{
if (current->argList->getLast())
{
current->argList->getLast()->defval=g_defVal.stripWhiteSpace();
current->argList->getLast()->defval=QCString(g_defVal.data()).stripWhiteSpace();
}
if (*yytext == ')')
if (*yytext != ',')
current->args = argListToString(current->argList);
BEGIN(FunctionParams);
}
else // continue
{
if (*yytext == ')')g_braceCount--;
if (*yytext != ',')g_braceCount--;
g_defVal+=*yytext;
}
}
. {
g_defVal+=*yytext;
}
"'" {
g_defVal+=*yytext;
g_copyString=&g_defVal;
g_stringContext=FunctionParamDefVal;
BEGIN( SingleQuoteString );
}
"\"" {
g_defVal+=*yytext;
g_copyString=&g_defVal;
g_stringContext=FunctionParamDefVal;
BEGIN( DoubleQuoteString );
}
\n {
g_defVal+=*yytext;
incLineNr();
}
. {
g_defVal+=*yytext;
}
}


Expand Down

0 comments on commit e5e75b7

Please sign in to comment.