summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2015-12-19 16:57:54 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2015-12-19 16:57:54 (GMT)
commitb0d31742d25a1a87eb4f5c27945164231197854b (patch)
tree7f878b205c9f2cdbda8f5800041b52ee0e7d7f3d /src
parentcbc268d3c892934a24e6958bd20af8a875f603b6 (diff)
parentc47920b217491fc861cdac73d44ab4f93d08423e (diff)
downloadDoxygen-b0d31742d25a1a87eb4f5c27945164231197854b.zip
Doxygen-b0d31742d25a1a87eb4f5c27945164231197854b.tar.gz
Doxygen-b0d31742d25a1a87eb4f5c27945164231197854b.tar.bz2
Merge pull request #424 from albert-github/feature/bug_py_types
Correct / set types for python variables
Diffstat (limited to 'src')
-rw-r--r--src/pyscanner.l30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/pyscanner.l b/src/pyscanner.l
index 99650bd..1ccb943 100644
--- a/src/pyscanner.l
+++ b/src/pyscanner.l
@@ -113,6 +113,9 @@ static int g_braceCount;
static bool g_lexInit = FALSE;
static bool g_packageCommentAllowed;
+static bool g_start_init = FALSE;
+static int g_search_count = 0;
+
//-----------------------------------------------------------------------------
@@ -458,6 +461,7 @@ OCTNUMBER "0"[0-7]+[lL]?
NUMBER {DIGIT}+[lLjJ]?
INTNUMBER {HEXNUMBER}|{OCTNUMBER}|{NUMBER}
FLOATNUMBER {DIGIT}+"."{DIGIT}+([eE][+\-]?{DIGIT}+)?[jJ]?
+BOOL ("True"|"False")
LETTER [A-Za-z\x80-\xFF]
NONEMPTY [A-Za-z0-9_\x80-\xFF]
EXPCHAR [#(){}\[\],:.%/\\=`*~|&<>!;+-]
@@ -580,6 +584,7 @@ STARTDOCSYMS "##"
BEGIN(VariableDec);
}
^{B}{IDENTIFIER}/{B}"="[^=] { // variable
+ if (g_search_count) REJECT;
g_indent=computeIndent(yytext);
current->section = Entry::VARIABLE_SEC;
current->name = QCString(yytext).stripWhiteSpace();
@@ -634,6 +639,12 @@ STARTDOCSYMS "##"
initSpecialBlock();
BEGIN(SpecialComment);
}
+ [(] { // we have to do something with (
+ g_search_count += 1;
+ }
+ [)] { // we have to do something with )
+ g_search_count -= 1;
+ }
[^\n] { // any other character...
// This is the major default
// that should catch everything
@@ -1160,6 +1171,7 @@ STARTDOCSYMS "##"
<VariableDec>{
"=" { // the assignment operator
//printf("====== VariableDec at line %d\n",yyLineNr);
+ g_start_init = TRUE;
current->initializer = yytext;
current->initializer += " ";
}
@@ -1175,6 +1187,11 @@ STARTDOCSYMS "##"
current->initializer += yytext;
BEGIN(VariableEnd);
}
+ {BOOL} { // boolean value
+ current->type = "bool";
+ current->initializer += yytext;
+ BEGIN(VariableEnd);
+ }
{STRINGPREFIX}?"'" { // string
current->type = "string";
current->initializer += yytext;
@@ -1206,8 +1223,8 @@ STARTDOCSYMS "##"
g_stringContext=VariableEnd;
BEGIN(TripleString);
}
- "(" { // tuple
- if (current->mtype!=Property)
+ "(" { // tuple, only when direct after =
+ if (current->mtype!=Property && g_start_init)
{
current->type = "tuple";
}
@@ -1218,7 +1235,7 @@ STARTDOCSYMS "##"
BEGIN( VariableAtom );
}
"[" { // list
- current->type = "list";
+ if (g_start_init) current->type = "list";
current->initializer+=*yytext;
g_atomStart='[';
g_atomEnd=']';
@@ -1226,7 +1243,7 @@ STARTDOCSYMS "##"
BEGIN( VariableAtom );
}
"{" { // dictionary
- current->type = "dictionary";
+ if (g_start_init) current->type = "dictionary";
current->initializer+=*yytext;
g_atomStart='{';
g_atomEnd='}';
@@ -1237,9 +1254,11 @@ STARTDOCSYMS "##"
BEGIN( VariableEnd );
}
{IDENTIFIER} {
+ g_start_init = FALSE;
current->initializer+=yytext;
}
. {
+ g_start_init = FALSE;
current->initializer+=*yytext;
}
\n {
@@ -1264,7 +1283,8 @@ STARTDOCSYMS "##"
}
if (g_atomCount==0)
{
- BEGIN(VariableEnd);
+ g_start_init = FALSE;
+ BEGIN(VariableDec);
}
}
{TRIDOUBLEQUOTE} { // start of a comment block