From e5e75b7f713251dd6caa472f9c5fb8d49e36ff5a Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 4 Mar 2018 18:54:04 +0100 Subject: Bug 778012 - Python List as Default Parameter not parsed correctly Added handling of square brackets, single quoted strings and double quoted strings (could contain comma's as well) to default values of arguments. --- src/pyscanner.l | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/pyscanner.l b/src/pyscanner.l index 9c21d41..1d964b4 100644 --- a/src/pyscanner.l +++ b/src/pyscanner.l @@ -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; @@ -993,35 +993,49 @@ STARTDOCSYMS "##" } { - "(" { // 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; + } } -- cgit v0.12