Skip to content

Commit

Permalink
Merge pull request #424 from albert-github/feature/bug_py_types
Browse files Browse the repository at this point in the history
Correct / set types for python variables
  • Loading branch information
Dimitri van Heesch committed Dec 19, 2015
2 parents cbc268d + c47920b commit b0d3174
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/pyscanner.l
Expand Up @@ -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;

//-----------------------------------------------------------------------------


Expand Down Expand Up @@ -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 [#(){}\[\],:.%/\\=`*~|&<>!;+-]
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 += " ";
}
Expand All @@ -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;
Expand Down Expand Up @@ -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";
}
Expand All @@ -1218,15 +1235,15 @@ STARTDOCSYMS "##"
BEGIN( VariableAtom );
}
"[" { // list
current->type = "list";
if (g_start_init) current->type = "list";
current->initializer+=*yytext;
g_atomStart='[';
g_atomEnd=']';
g_atomCount=1;
BEGIN( VariableAtom );
}
"{" { // dictionary
current->type = "dictionary";
if (g_start_init) current->type = "dictionary";
current->initializer+=*yytext;
g_atomStart='{';
g_atomEnd='}';
Expand All @@ -1237,9 +1254,11 @@ STARTDOCSYMS "##"
BEGIN( VariableEnd );
}
{IDENTIFIER} {
g_start_init = FALSE;
current->initializer+=yytext;
}
. {
g_start_init = FALSE;
current->initializer+=*yytext;
}
\n {
Expand All @@ -1264,7 +1283,8 @@ STARTDOCSYMS "##"
}
if (g_atomCount==0)
{
BEGIN(VariableEnd);
g_start_init = FALSE;
BEGIN(VariableDec);
}
}
{TRIDOUBLEQUOTE} { // start of a comment block
Expand Down

0 comments on commit b0d3174

Please sign in to comment.