summaryrefslogtreecommitdiffstats
path: root/src/pyscanner.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/pyscanner.l')
-rw-r--r--src/pyscanner.l180
1 files changed, 147 insertions, 33 deletions
diff --git a/src/pyscanner.l b/src/pyscanner.l
index 4718e3b..aed1ede 100644
--- a/src/pyscanner.l
+++ b/src/pyscanner.l
@@ -118,6 +118,8 @@ static bool g_packageCommentAllowed;
static bool g_start_init = FALSE;
static int g_search_count = 0;
+static QCString g_argType = "";
+static bool g_funcParamsEnd;
//-----------------------------------------------------------------------------
@@ -513,6 +515,8 @@ STARTDOCSYMS "##"
%x FunctionDec
%x FunctionParams
%x FunctionBody
+%x FunctionAnnotation
+%x FunctionTypeAnnotation
%x FunctionParamDefVal
/* Class states */
@@ -932,7 +936,6 @@ STARTDOCSYMS "##"
}
<FunctionDec>{
-
{IDENTIFIER} {
//found function name
if (current->type.isEmpty())
@@ -943,47 +946,59 @@ STARTDOCSYMS "##"
current->name = current->name.stripWhiteSpace();
newFunction();
}
- {B}":" { // function without arguments
+ {B}":"{B} { // function without arguments
g_specialBlock = TRUE; // expecting a docstring
bodyEntry = current;
current->bodyLine = yyLineNr;
- BEGIN( FunctionBody );
+ BEGIN(FunctionBody);
}
+ "->" {
+ g_defVal.resize(0);
+ g_braceCount = 0;
+ BEGIN(FunctionTypeAnnotation);
+ }
{B}"(" {
- BEGIN( FunctionParams );
+ g_funcParamsEnd = FALSE;
+ BEGIN(FunctionParams);
}
+ ")" { // end of parameter list
+ current->args = argListToString(current->argList);
+ g_funcParamsEnd = TRUE;
+ }
}
<FunctionParams>{
({BB}|",") {
}
+ [\*]+ {
+ g_argType = yytext;
+ }
{IDENTIFIER} { // Name of parameter
lineCount();
Argument *a = new Argument;
current->argList->append(a);
current->argList->getLast()->name = QCString(yytext).stripWhiteSpace();
- current->argList->getLast()->type = "";
+ current->argList->getLast()->type = g_argType;
+ g_argType = "";
}
"=" { // default value
// TODO: this rule is too simple, need to be able to
// match things like =")" as well!
g_defVal.resize(0);
- g_braceCount=0;
+ g_braceCount = 0;
BEGIN(FunctionParamDefVal);
}
-
- ")" { // end of parameter list
- current->args = argListToString(current->argList);
+ ")" {
+ unput(*yytext);
+ BEGIN(FunctionDec);
}
-
":"{B} {
- g_specialBlock = TRUE; // expecting a docstring
- bodyEntry = current;
- current->bodyLine = yyLineNr;
- BEGIN( FunctionBody );
- }
+ g_defVal.resize(0);
+ g_braceCount = 0;
+ BEGIN(FunctionAnnotation);
+ }
{POUNDCOMMENT} { // a comment
}
{PARAMNONEMPTY} { // Default rule inside arguments.
@@ -991,31 +1006,131 @@ STARTDOCSYMS "##"
}
+<FunctionTypeAnnotation>{
+ "{" |
+ "[" |
+ "(" {
+ ++g_braceCount;
+ g_defVal+=*yytext;
+ }
+ "}" |
+ "]" |
+ ")" {
+ --g_braceCount;
+ g_defVal+=*yytext;
+ }
+ ":" {
+ if (g_braceCount == 0)
+ {
+ current->type = g_defVal.data();
+ unput(*yytext);
+ BEGIN(FunctionDec);
+ }
+ else
+ g_defVal+=*yytext;
+ }
+ "'" {
+ g_defVal+=*yytext;
+ g_copyString=&g_defVal;
+ g_stringContext=FunctionTypeAnnotation;
+ BEGIN(SingleQuoteString);
+ }
+ "\"" {
+ g_defVal+=*yytext;
+ g_copyString=&g_defVal;
+ g_stringContext=FunctionTypeAnnotation;
+ BEGIN(DoubleQuoteString);
+ }
+ \n {
+ g_defVal+=*yytext;
+ incLineNr();
+ }
+ . {
+ g_defVal+=*yytext;
+ }
+}
+
+<FunctionAnnotation>{
+ "{" |
+ "[" |
+ "(" {
+ ++g_braceCount;
+ g_defVal+=*yytext;
+ }
+ "}" |
+ "]" {
+ --g_braceCount;
+ g_defVal+=*yytext;
+ }
+ ")" |
+ "=" |
+ "," {
+ if (g_braceCount == 0)
+ {
+ if (current->argList->getLast())
+ current->argList->getLast()->type += g_defVal.data();
+ if (*yytext != ',')
+ unput(*yytext);
+ BEGIN(FunctionParams);
+ }
+ else
+ {
+ if (*yytext == ')')
+ --g_braceCount;
+ g_defVal += *yytext;
+ }
+ }
+ "'" {
+ g_defVal+=*yytext;
+ g_copyString=&g_defVal;
+ g_stringContext=FunctionAnnotation;
+ BEGIN(SingleQuoteString);
+ }
+ "\"" {
+ g_defVal+=*yytext;
+ g_copyString=&g_defVal;
+ g_stringContext=FunctionAnnotation;
+ BEGIN(DoubleQuoteString);
+ }
+ \n {
+ g_defVal+=*yytext;
+ incLineNr();
+ }
+ . {
+ g_defVal+=*yytext;
+ }
+}
+
<FunctionParamDefVal>{
+ "{" |
"[" |
"(" { // internal opening brace, assumption is that we have correct code so braces do match
- g_braceCount++;
+ ++g_braceCount;
g_defVal+=*yytext;
}
- "," |
- "]" |
- ")" {
- if (g_braceCount==0) // end of default argument
+ "}" |
+ "]" {
+ --g_braceCount;
+ g_defVal+=*yytext;
+ }
+ ")" |
+ "," {
+ if (g_braceCount == 0)
{
if (current->argList->getLast())
- {
current->argList->getLast()->defval=QCString(g_defVal.data()).stripWhiteSpace();
- }
- if (*yytext != ',')
- current->args = argListToString(current->argList);
+ if (*yytext == ')')
+ unput(*yytext);
BEGIN(FunctionParams);
}
- else // continue
- {
- if (*yytext != ',')g_braceCount--;
- g_defVal+=*yytext;
- }
+ else
+ {
+ if (*yytext == ')')
+ --g_braceCount;
+ g_defVal += *yytext;
+ }
}
+
"'" {
g_defVal+=*yytext;
g_copyString=&g_defVal;
@@ -1396,7 +1511,6 @@ STARTDOCSYMS "##"
BEGIN(Search);
}
<<EOF>> { yyterminate();
- newEntry();
}
}
@@ -1425,7 +1539,7 @@ STARTDOCSYMS "##"
actualDoc.prepend("\\verbatim ");
actualDoc.append("\\endverbatim ");
}
- actualDoc.prepend("\\namespace "+g_moduleScope+"\\_linebr ");
+ actualDoc.prepend("\\namespace "+g_moduleScope+" ");
handleCommentBlock(actualDoc, FALSE);
}
if ((docBlockContext==ClassBody /*&& !g_hideClassDocs*/) ||
@@ -1508,7 +1622,7 @@ STARTDOCSYMS "##"
\\. { // espaced char
addToString(yytext);
}
- "\"\"\"" { // tripple double quotes
+ "\"\"\"" { // triple double quotes
addToString(yytext);
}
"'" { // end of the string
@@ -1531,7 +1645,7 @@ STARTDOCSYMS "##"
\\. { // espaced char
addToString(yytext);
}
- "'''" { // tripple single quotes
+ "'''" { // triple single quotes
addToString(yytext);
}
"\"" { // end of the string