Skip to content

Commit

Permalink
Initialization of python variables and type determination
Browse files Browse the repository at this point in the history
A bit better python initialization (not only the fist "word") and subsequent determination of the type.
  • Loading branch information
albert-github committed Aug 24, 2016
1 parent cd6a8d3 commit 46ba776
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions src/pyscanner.l
Expand Up @@ -1205,51 +1205,49 @@ STARTDOCSYMS "##"
current->initializer += " ";
}
{B} { // spaces
current->initializer += yytext;
}
{INTNUMBER} { // integer value
current->type = "int";
if (current-> type.isEmpty()) current->type = "int";
current->initializer += yytext;
BEGIN(VariableEnd);
}
{FLOATNUMBER} { // floating point value
current->type = "float";
if (current->type.isEmpty()) current->type = "float";
current->initializer += yytext;
BEGIN(VariableEnd);
}
{BOOL} { // boolean value
current->type = "bool";
if (current->type.isEmpty()) current->type = "bool";
current->initializer += yytext;
BEGIN(VariableEnd);
}
{STRINGPREFIX}?"'" { // string
current->type = "string";
if (current->type.isEmpty()) current->type = "string";
current->initializer += yytext;
g_copyString=&current->initializer;
g_stringContext=VariableEnd;
g_stringContext=VariableDec;
BEGIN( SingleQuoteString );
}
{STRINGPREFIX}?"\"" { // string
current->type = "string";
if (current->type.isEmpty()) current->type = "string";
current->initializer += yytext;
g_copyString=&current->initializer;
g_stringContext=VariableEnd;
g_stringContext=VariableDec;
BEGIN( DoubleQuoteString );
}
{TRIDOUBLEQUOTE} { // start of a comment block
current->type = "string";
if (current->type.isEmpty()) current->type = "string";
current->initializer += yytext;
g_doubleQuote=TRUE;
g_copyString=&current->initializer;
g_stringContext=VariableEnd;
g_stringContext=VariableDec;
BEGIN(TripleString);
}

{TRISINGLEQUOTE} { // start of a comment block
current->type = "string";
if (current->type.isEmpty()) current->type = "string";
current->initializer += yytext;
g_doubleQuote=FALSE;
g_copyString=&current->initializer;
g_stringContext=VariableEnd;
g_stringContext=VariableDec;
BEGIN(TripleString);
}
"(" { // tuple, only when direct after =
Expand Down Expand Up @@ -1283,6 +1281,20 @@ STARTDOCSYMS "##"
BEGIN( VariableEnd );
}
{IDENTIFIER} {
// do something based on the type of the IDENTIFIER
if (current->type.isEmpty())
{
QListIterator<Entry> eli(*(current_root->children()));
Entry *child;
for (eli.toFirst();(child=eli.current());++eli)
{
if (child->name == QCString(yytext))
{
current->type = child->type;
break;
}
}
}
g_start_init = FALSE;
current->initializer+=yytext;
}
Expand Down

0 comments on commit 46ba776

Please sign in to comment.