Fix bug reported by Anant Devi in user discussion 22/9/22.

A function call, vi(v) was misparsed as the special token i(vsource)
for the current in a voltage source.
This commit is contained in:
Giles Atkinson 2022-09-23 10:13:06 +01:00 committed by Holger Vogt
parent c75476eaa0
commit 583ee06232
1 changed files with 13 additions and 7 deletions

View File

@ -885,7 +885,7 @@ int PPlex(YYSTYPE *lvalp, struct PPltype *llocp, char **line)
* vthing#branch
* i(vthing)
*/
for (; *sbuf && !strchr(specials, *sbuf); sbuf++)
for (; *sbuf && !strchr(specials, *sbuf); sbuf++) {
if (*sbuf == '@') {
atsign = 1;
}
@ -897,16 +897,22 @@ int PPlex(YYSTYPE *lvalp, struct PPltype *llocp, char **line)
sbuf++;
}
break;
}
/* keep the identifier i(vss) as a single token, even as dc1.i(vss) */
else if (prefix("i(v", sbuf)) {
} else if ((sbuf == start || sbuf[-1] == '.') &&
prefix("i(v", sbuf)) {
/* Special case for current through voltage source:
* keep the identifier i(vss) as a single token,
* even as dc1.i(vss).
*/
if (get_r_paren(&sbuf) == 1) {
fprintf(stderr, "Error: missing ')' in token\n %s\n", start);
fprintf(stderr,
"Error: missing ')' in token\n %s\n",
start);
break;
}
sbuf--;
sbuf--; // Point at ')', last accepted char.
}
}
lvalp->str = copy_substring(start, sbuf);
lexer_return(TOK_STR, 0);
}