Kaydet (Commit) a34de3e5 authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

Add support for python's assignment expressions

üst 95c0c06c
...@@ -561,11 +561,17 @@ static const char *findVariable(const char *line) ...@@ -561,11 +561,17 @@ static const char *findVariable(const char *line)
* Assignment to a tuple 'x, y = 2, 3' not supported. * Assignment to a tuple 'x, y = 2, 3' not supported.
* TODO: ignore duplicate tags from reassignment statements. */ * TODO: ignore duplicate tags from reassignment statements. */
const char *cp, *sp, *eq, *start; const char *cp, *sp, *eq, *start;
int offset = 2;
cp = strstr(line, "="); cp = strstr(line, ":=");
if (!cp) if (!cp){
return NULL; cp = strstr(line, "=");
eq = cp + 1; if (!cp){
return NULL;
}
--offset;
}
eq = cp + offset;
while (*eq) while (*eq)
{ {
if (*eq == '=') if (*eq == '=')
...@@ -586,7 +592,7 @@ static const char *findVariable(const char *line) ...@@ -586,7 +592,7 @@ static const char *findVariable(const char *line)
sp = start; sp = start;
while (sp >= line && isspace ((int) *sp)) while (sp >= line && isspace ((int) *sp))
--sp; --sp;
if ((sp + 1) != line) /* the line isn't a simple variable assignment */ if ((sp + 1) != line && offset == 1) /* the line isn't a simple variable assignment */
return NULL; return NULL;
/* the line is valid, parse the variable name */ /* the line is valid, parse the variable name */
++start; ++start;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment