summaryrefslogtreecommitdiff
path: root/Windows/spice/examples/control_structs/new-check-3.sp
blob: c85c19f6193a18174ed643034f1a99f9fa9c2581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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