about summary refs log tree commit diff stats
path: root/arc/.traces/string-equal-empty
blob: a9a3b420ec32a1d2c894040bfca14348cf2072c8 (plain) (blame)
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
c{0: 0 (((1 string-address)) <- ((new)) ) -- nil
c{0: 1 (((2 string-address)) <- ((new)) ) -- nil
c{0: 2 (((3 boolean)) <- ((string-equal)) ((1 string-address)) ((2 string-address))) -- nil
c{1: 0 ✓ (((1 string-address)) <- ((new)) )
c{1: 1 ✓ (((2 string-address)) <- ((new)) )
c{1: 2 ✓ (((3 boolean)) <- ((string-equal)) ((1 string-address)) ((2 string-address)))
cn0: convert-names in main
cn0: (((1 string-address)) <- ((new)) ) nil nil
cn0: checking arg 
cn0: checking oarg ((1 string-address))
maybe-add: ((1 string-address))
cn0: (((2 string-address)) <- ((new)) ) nil nil
cn0: checking arg 
cn0: checking oarg ((2 string-address))
maybe-add: ((2 string-address))
cn0: (((3 boolean)) <- ((string-equal)) ((1 string-address)) ((2 string-address))) nil nil
cn0: checking arg ((1 string-address))
maybe-add: ((1 string-address))
cn0: checking arg ((2 string-address))
maybe-add: ((2 string-address))
cn0: checking oarg ((3 boolean))
maybe-add: ((3 boolean))
cn1: (((1 string-address)) <- ((new)) )
cn1: (((2 string-address)) <- ((new)) )
cn1: (((3 boolean)) <- ((string-equal)) ((1 string-address)) ((2 string-address)))
schedule: main
run: main 0: (((1 string-address)) <- ((new)) )
run: main 0: 1000 => ((1 string-address))
mem: ((1 string-address)): 1 <= 1000
run: main 1: (((2 string-address)) <- ((new)) )
run: main 1: 1001 => ((2 string-address))
mem: ((2 string-address)): 2 <= 1001
run: main 2: (((3 boolean)) <- ((string-equal)) ((1 string-address)) ((2 string-address)))
mem: ((1 string-address)) => 1000
mem: ((2 string-address)) => 1001
run: string-equal/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: string-equal/main 0: 1002 => ((default-space space-address))
run: string-equal/main 1: (((1 string-address)) <- ((next-input)))
arg: nil 0 (1000 1001)
run: string-equal/main 1: 1000 => ((1 string-address))
mem: ((1 string-address)): 1004 <= 1000
run: string-equal/main 2: (((2 integer)) <- ((length)) ((1 string-address) (deref)))
array-len: ((1 string-address) (deref))
mem: ((1000 integer) (raw)) => 0
run: string-equal/main 2: 0 => ((2 integer))
mem: ((2 integer)): 1005 <= 0
run: string-equal/main 3: (((3 string-address)) <- ((next-input)))
arg: nil 1 (1000 1001)
run: string-equal/main 3: 1001 => ((3 string-address))
mem: ((3 string-address)): 1006 <= 1001
run: string-equal/main 4: (((4 integer)) <- ((length)) ((3 string-address) (deref)))
array-len: ((3 string-address) (deref))
mem: ((1001 integer) (raw)) => 0
run: string-equal/main 4: 0 => ((4 integer))
mem: ((4 integer)): 1007 <= 0
run: string-equal/main 5: (((5 boolean)) <- ((equal)) ((2 integer)) ((4 integer)))
mem: ((2 integer)) => 0
mem: ((4 integer)) => 0
run: string-equal/main 5: t => ((5 boolean))
mem: ((5 boolean)): 1008 <= t
run: string-equal/main 6: (((jump-if)) ((5 boolean)) ((1 offset)))
mem: ((5 boolean)) => t
run: string-equal/main 8: (((6 integer)) <- ((copy)) ((0 literal)))
run: string-equal/main 8: 0 => ((6 integer))
mem: ((6 integer)): 1009 <= 0
run: string-equal/main 9: (((7 boolean)) <- ((greater-or-equal)) ((6 integer)) ((2 integer)))
mem: ((6 integer)) => 0
mem: ((2 integer)) => 0
run: string-equal/main 9: t => ((7 boolean))
mem: ((7 boolean)): 1010 <= t
run: string-equal/main 10: (((jump-if)) ((7 boolean)) ((7 offset)))
mem: ((7 boolean)) => t
run: string-equal/main 18: (((reply)) ((t literal)))
run: main 2: t => ((3 boolean))
mem: ((3 boolean)): 3 <= t
schedule: done with routine nil
{ font-size: 1.05em; } .traceContains { color: #008000; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } .Identifier { color: #804000; } .Constant { color: #00a0a0; } --> </style> <script type='text/javascript'> <!-- --> </script> </head> <body> <pre id='vimCodeElement'> <span class="Comment">//: Support literal non-integers.</span> <span class="Delimiter">:(scenarios load)</span> <span class="Delimiter">:(scenario noninteger_literal)</span> recipe main [ <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">3.14159</span> ] <span class="traceContains">+parse: ingredient: {&quot;3.14159&quot;: &quot;literal-number&quot;}</span> <span class="Delimiter">:(after &quot;Parsing reagent(string s)&quot;)</span> if <span class="Delimiter">(</span>is_noninteger<span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> name = s<span class="Delimiter">;</span> type = new type_tree<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair&lt;string<span class="Delimiter">,</span> string_tree*&gt;<span class="Delimiter">(</span>name<span class="Delimiter">,</span> new string_tree<span class="Delimiter">(</span><span class="Constant">&quot;literal-number&quot;</span><span class="Delimiter">)));</span> set_value<span class="Delimiter">(</span>to_double<span class="Delimiter">(</span>s<span class="Delimiter">));</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> bool is_noninteger<span class="Delimiter">(</span>const string&amp; s<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> s<span class="Delimiter">.</span>find_first_not_of<span class="Delimiter">(</span><span class="Constant">&quot;0123456789-.&quot;</span><span class="Delimiter">)</span> == string::npos &amp;&amp; s<span class="Delimiter">.</span>find_first_of <span class="Delimiter">(</span><span class="Constant">&quot;0123456789-&quot;</span><span class="Delimiter">)</span> != string::npos &amp;&amp; std::count<span class="Delimiter">(</span>s<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> s<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <span class="Constant">'.'</span><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> double to_double<span class="Delimiter">(</span>string n<span class="Delimiter">)</span> <span class="Delimiter">{</span> char* end = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Comment">// safe because string.c_str() is guaranteed to be null-terminated</span> double result = strtod<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &amp;end<span class="Delimiter">);</span> assert<span class="Delimiter">(</span>*end == <span class="cSpecial">'\0'</span><span class="Delimiter">);</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> void test_is_noninteger<span class="Delimiter">()</span> <span class="Delimiter">{</span> CHECK<span class="Delimiter">(</span>!is_noninteger<span class="Delimiter">(</span><span class="Constant">&quot;1234&quot;</span><span class="Delimiter">));</span> CHECK<span class="Delimiter">(</span>!is_noninteger<span class="Delimiter">(</span><span class="Constant">&quot;1a2&quot;</span><span class="Delimiter">));</span> CHECK<span class="Delimiter">(</span>is_noninteger<span class="Delimiter">(</span><span class="Constant">&quot;234.0&quot;</span><span class="Delimiter">));</span> CHECK<span class="Delimiter">(</span>!is_noninteger<span class="Delimiter">(</span><span class="Constant">&quot;...&quot;</span><span class="Delimiter">));</span> CHECK<span class="Delimiter">(</span>!is_noninteger<span class="Delimiter">(</span><span class="Constant">&quot;.&quot;</span><span class="Delimiter">));</span> CHECK<span class="Delimiter">(</span>is_noninteger<span class="Delimiter">(</span><span class="Constant">&quot;2.&quot;</span><span class="Delimiter">));</span> CHECK<span class="Delimiter">(</span>is_noninteger<span class="Delimiter">(</span><span class="Constant">&quot;.2&quot;</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> </pre> </body> </html> <!-- vim: set foldmethod=manual : -->