frontend/parse.c, bug fix, PPlex(.."dc1.@m1[vth][1]"..)
The whole string was lexed into only one TOK_STR instead of the actual (quasi) identifier "dc1.@m1[vth]"
This commit is contained in:
parent
192eeadb0b
commit
a5f933b3ec
|
|
@ -667,13 +667,23 @@ PPlex(YYSTYPE *lvalp, struct PPltype *llocp, char **line)
|
||||||
/* It is bad how we have to recognise '[' -- sometimes
|
/* It is bad how we have to recognise '[' -- sometimes
|
||||||
* it is part of a word, when it defines a parameter
|
* it is part of a word, when it defines a parameter
|
||||||
* name, and otherwise it isn't.
|
* name, and otherwise it isn't.
|
||||||
* va, ']' too
|
*
|
||||||
|
* what is valid here ?
|
||||||
|
* foo dc1.foo dc1.@m1[vth]
|
||||||
|
* this too ?
|
||||||
|
* vthing#branch
|
||||||
|
* should we convert the pseudo identifier ?
|
||||||
|
* i(v5) --> v5#branch
|
||||||
*/
|
*/
|
||||||
for (; *sbuf && !strchr(specials, *sbuf); sbuf++)
|
for (; *sbuf && !strchr(specials, *sbuf); sbuf++)
|
||||||
if (*sbuf == '@')
|
if (*sbuf == '@')
|
||||||
atsign = 1;
|
atsign = 1;
|
||||||
else if (!atsign && (*sbuf == '[' || *sbuf == ']'))
|
else if (!atsign && *sbuf == '[')
|
||||||
break;
|
break;
|
||||||
|
else if (atsign && *sbuf == ']') {
|
||||||
|
sbuf++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
lvalp->str = copy_substring(start, sbuf);
|
lvalp->str = copy_substring(start, sbuf);
|
||||||
lexer_return(TOK_STR, 0);
|
lexer_return(TOK_STR, 0);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
|
||||||
TESTS = bugs-1.cir dollar-1.cir empty-1.cir resume-1.cir log-functions-1.cir
|
TESTS = bugs-1.cir bugs-2.cir dollar-1.cir empty-1.cir resume-1.cir log-functions-1.cir
|
||||||
|
|
||||||
TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice
|
TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
parser test
|
||||||
|
*
|
||||||
|
* test capability to parse @foo[bar][42]
|
||||||
|
* (exec-spice "ngspice %s" t)
|
||||||
|
|
||||||
|
v1 1 0 dc=0
|
||||||
|
|
||||||
|
.control
|
||||||
|
|
||||||
|
save @v1[dc]
|
||||||
|
|
||||||
|
dc v1 0 1 250m
|
||||||
|
|
||||||
|
let foo = @v1[dc]
|
||||||
|
|
||||||
|
let gold = 500m
|
||||||
|
let bar = foo[2]
|
||||||
|
let baz = @v1[dc][2]
|
||||||
|
|
||||||
|
let fail_count = 0
|
||||||
|
|
||||||
|
if bar <> 0.5
|
||||||
|
echo "ERROR: bar = $&bar should be 0.5"
|
||||||
|
let fail_count = fail_count + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if baz <> 0.5
|
||||||
|
echo "ERROR: baz = $&baz should be 0.5"
|
||||||
|
let fail_count = fail_count + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if fail_count > 0
|
||||||
|
echo "ERROR: $&fail_count tests failed"
|
||||||
|
quit 1
|
||||||
|
else
|
||||||
|
echo "INFO: $&fail_count tests failed"
|
||||||
|
quit 0
|
||||||
|
end
|
||||||
|
|
||||||
|
.endc
|
||||||
|
|
||||||
|
.end
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
Circuit: parser test
|
||||||
|
|
||||||
|
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
|
||||||
|
|
||||||
|
|
||||||
|
No. of Data Rows : 5
|
||||||
|
INFO: 0 tests failed
|
||||||
Loading…
Reference in New Issue