new operation in control blocks
This commit is contained in:
parent
5fcf9c2afe
commit
49aadcca58
|
|
@ -1,5 +1,6 @@
|
|||
2010-04-11 Dietmar Warning
|
||||
* Robert Larice patch to allow ternary operation in control blocks:
|
||||
* Robert Larice patch to allow new operations in control blocks:
|
||||
* examples/new-check-3.sp, new-check-4.sp
|
||||
* src/include/fteparse.h, ngspice.h
|
||||
* src/frontend/parse*.*, evaluate.c, Makefile.am, src/misc/string.c, stringutil.h
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,96 @@
|
|||
new ft_getpnames parser check 3, try ternary
|
||||
|
||||
* (compile (concat "tmp-1/ng-spice-rework/src/ngspice " buffer-file-name) t)
|
||||
|
||||
VIN 1 0 DC=0
|
||||
|
||||
.control
|
||||
|
||||
dc VIN 0 10 5
|
||||
|
||||
* trying the ternary
|
||||
|
||||
let checks = 0
|
||||
|
||||
let const0 = 0
|
||||
let const5 = 5
|
||||
let const6 = 6
|
||||
|
||||
|
||||
let tmp = const0 ? const5 : const6
|
||||
if tmp eq const6
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
let tmp = const6 ? const5 : const6
|
||||
if tmp eq const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
define foo(a,b,d) a ? b : d
|
||||
|
||||
if foo(const0,const5,const6) eq const6
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if foo(const6,const5,const6) eq const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
let vec7 = 7*unitvec(7)
|
||||
let vec8 = 8*unitvec(8)
|
||||
|
||||
if length(const5 ? vec7 : vec8) eq 7
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if length(const0 ? vec7 : vec8) eq 8
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
* FIXME, "1 ? 1:1" (without spaces around of ':') doesnt work,
|
||||
* "1:1" is a lexem, WHY !!!
|
||||
* ist that an old artifact, (ancient hierarchical name separator ':')
|
||||
*
|
||||
*print length(1?1:1)
|
||||
|
||||
*if (1 ? 1:1) eq 1
|
||||
if (1 ? 1 : 1) eq 1
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
print @vin[dc]
|
||||
|
||||
* '"' survives, and will be processed in the ft_getpnames() lexer, that is PPlex()
|
||||
* where the string will be unqoted
|
||||
* thats used vor weired variable names, for example "zero(1)"
|
||||
let foo = "vec8"
|
||||
if foo eq vec8
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if checks eq 8
|
||||
echo "INFO: ok"
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
.endc
|
||||
|
||||
.end
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
demonstrate < etc in ft_getpnames
|
||||
|
||||
* (compile (concat "tmp-1/ng-spice-rework/src/ngspice " buffer-file-name) t)
|
||||
|
||||
VIN 1 0 DC=0
|
||||
|
||||
.control
|
||||
|
||||
dc VIN 0 10 5
|
||||
|
||||
let checks = 0
|
||||
|
||||
let const0 = 0
|
||||
let const5 = 5
|
||||
let const6 = 6
|
||||
|
||||
* check some relational operators, which are in danger to mixed up
|
||||
* with csh semantic, that is IO redirection
|
||||
|
||||
if const5 < const6
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if const6 > const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if const5 >= const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if const5 <= const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if const5 = const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
* check some wired non-equality operators
|
||||
* note: there are some awkward tranformations ahead of the ft_getpnames lexer
|
||||
* transforming "><" into "> <"
|
||||
* and "<>" into "< >"
|
||||
* note: "!=" would have been in serious danger to be fooled up within
|
||||
* csh history mechanism
|
||||
|
||||
if const6 <> const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if const6 >< const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
|
||||
* check some boolean operators, which are in danger to be mixed up
|
||||
* with csh semantic, `&' background '|' pipe '~' homedirectory
|
||||
|
||||
if const5 & const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if const0 | const5
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
if ~ const0
|
||||
let checks = checks + 1
|
||||
else
|
||||
echo "ERROR:"
|
||||
end
|
||||
|
||||
* note:
|
||||
* "!=" would be in danger, '!' triggers the csh history mechanism
|
||||
*if const5 != const6
|
||||
* echo "just trying"
|
||||
*end
|
||||
|
||||
|
||||
* Note: csh semantics swallows the '>' and '<' operators
|
||||
* on most of the com lines
|
||||
* witnessed by
|
||||
let tmp = const5 > unwanted_output_file_1
|
||||
define foo(a,b) a > unwanted_output_file_2
|
||||
print const0 > unwanted_output_file_3
|
||||
|
||||
if checks eq 10
|
||||
echo "INFO: ok"
|
||||
end
|
||||
|
||||
.endc
|
||||
|
||||
.end
|
||||
Loading…
Reference in New Issue