about summary refs log blame commit diff stats
path: root/arc/.traces/channel-write-full
blob: a12e20f988546223bcd9837c9130629f225b2d69 (plain) (tree)















































































































































































































































































































                                                                                                                                           
c{0: 0 (((1 channel-address)) <- ((init-channel)) ((1 literal))) -- nil
c{0: 1 (((2 integer)) <- ((copy)) ((34 literal))) -- nil
c{0: 2 (((3 tagged-value)) <- ((save-type)) ((2 integer))) -- nil
c{0: 3 (((1 channel-address) (deref)) <- ((write)) ((1 channel-address)) ((3 tagged-value))) -- nil
c{0: 4 (((5 boolean)) <- ((empty?)) ((1 channel-address) (deref))) -- nil
c{0: 5 (((6 boolean)) <- ((full?)) ((1 channel-address) (deref))) -- nil
c{1: 0 ✓ (((1 channel-address)) <- ((init-channel)) ((1 literal)))
c{1: 1 ✓ (((2 integer)) <- ((copy)) ((34 literal)))
c{1: 2 ✓ (((3 tagged-value)) <- ((save-type)) ((2 integer)))
c{1: 3 ✓ (((1 channel-address) (deref)) <- ((write)) ((1 channel-address)) ((3 tagged-value)))
c{1: 4 ✓ (((5 boolean)) <- ((empty?)) ((1 channel-address) (deref)))
c{1: 5 ✓ (((6 boolean)) <- ((full?)) ((1 channel-address) (deref)))
cn0: convert-names in main
cn0: (((1 channel-address)) <- ((init-channel)) ((1 literal))) nil nil
cn0: checking arg ((1 literal))
cn0: checking oarg ((1 channel-address))
maybe-add: ((1 channel-address))
cn0: (((2 integer)) <- ((copy)) ((34 literal))) nil nil
cn0: checking arg ((34 literal))
cn0: checking oarg ((2 integer))
maybe-add: ((2 integer))
cn0: (((3 tagged-value)) <- ((save-type)) ((2 integer))) nil nil
cn0: checking arg ((2 integer))
maybe-add: ((2 integer))
cn0: checking oarg ((3 tagged-value))
maybe-add: ((3 tagged-value))
cn0: (((1 channel-address) (deref)) <- ((write)) ((1 channel-address)) ((3 tagged-value))) nil nil
cn0: checking arg ((1 channel-address))
maybe-add: ((1 channel-address))
cn0: checking arg ((3 tagged-value))
maybe-add: ((3 tagged-value))
cn0: checking oarg ((1 channel-address) (deref))
maybe-add: ((1 channel-address) (deref))
cn0: (((5 boolean)) <- ((empty?)) ((1 channel-address) (deref))) nil nil
cn0: checking arg ((1 channel-address) (deref))
maybe-add: ((1 channel-address) (deref))
cn0: checking oarg ((5 boolean))
maybe-add: ((5 boolean))
cn0: (((6 boolean)) <- ((full?)) ((1 channel-address) (deref))) nil nil
cn0: checking arg ((1 channel-address) (deref))
maybe-add: ((1 channel-address) (deref))
cn0: checking oarg ((6 boolean))
maybe-add: ((6 boolean))
cn1: (((1 channel-address)) <- ((init-channel)) ((1 literal)))
cn1: (((2 integer)) <- ((copy)) ((34 literal)))
cn1: (((3 tagged-value)) <- ((save-type)) ((2 integer)))
cn1: (((1 channel-address) (deref)) <- ((write)) ((1 channel-address)) ((3 tagged-value)))
cn1: (((5 boolean)) <- ((empty?)) ((1 channel-address) (deref)))
cn1: (((6 boolean)) <- ((full?)) ((1 channel-address) (deref)))
schedule: main
run: main 0: (((1 channel-address)) <- ((init-channel)) ((1 literal)))
run: init-channel/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: init-channel/main 0: 1000 => ((default-space space-address))
run: init-channel/main 1: (((1 channel-address)) <- ((new)) ((channel literal)))
run: init-channel/main 1: 1031 => ((1 channel-address))
mem: ((1 channel-address)): 1002 <= 1031
run: init-channel/main 2: (((2 integer-address)) <- ((get-address)) ((1 channel-address) (deref)) ((0 offset)))
run: init-channel/main 2: 1031 => ((2 integer-address))
mem: ((2 integer-address)): 1003 <= 1031
run: init-channel/main 3: (((2 integer-address) (deref)) <- ((copy)) ((0 literal)))
run: init-channel/main 3: 0 => ((2 integer-address) (deref))
mem: ((2 integer-address) (deref)): 1031 <= 0
run: init-channel/main 4: (((3 integer-address)) <- ((get-address)) ((1 channel-address) (deref)) ((1 offset)))
run: init-channel/main 4: 1032 => ((3 integer-address))
mem: ((3 integer-address)): 1004 <= 1032
run: init-channel/main 5: (((3 integer-address) (deref)) <- ((copy)) ((0 literal)))
run: init-channel/main 5: 0 => ((3 integer-address) (deref))
mem: ((3 integer-address) (deref)): 1032 <= 0
run: init-channel/main 6: (((4 integer)) <- ((next-input)))
arg: nil 0 (1)
run: init-channel/main 6: 1 => ((4 integer))
mem: ((4 integer)): 1005 <= 1
run: init-channel/main 7: (((4 integer)) <- ((add)) ((4 integer)) ((1 literal)))
mem: ((4 integer)) => 1
run: init-channel/main 7: 2 => ((4 integer))
mem: ((4 integer)): 1005 <= 2
run: init-channel/main 8: (((5 tagged-value-array-address-address)) <- ((get-address)) ((1 channel-address) (deref)) ((2 offset)))
run: init-channel/main 8: 1033 => ((5 tagged-value-array-address-address))
mem: ((5 tagged-value-array-address-address)): 1006 <= 1033
run: init-channel/main 9: (((5 tagged-value-array-address-address) (deref)) <- ((new)) ((tagged-value-array literal)) ((4 integer)))
mem: ((4 integer)) => 2
run: init-channel/main 9: 1034 => ((5 tagged-value-array-address-address) (deref))
mem: ((5 tagged-value-array-address-address) (deref)): 1033 <= 1034
run: init-channel/main 10: (((reply)) ((1 channel-address)))
mem: ((1 channel-address)) => 1031
run: main 0: 1031 => ((1 channel-address))
mem: ((1 channel-address)): 1 <= 1031
run: main 1: (((2 integer)) <- ((copy)) ((34 literal)))
run: main 1: 34 => ((2 integer))
mem: ((2 integer)): 2 <= 34
run: main 2: (((3 tagged-value)) <- ((save-type)) ((2 integer)))
mem: ((2 integer)) => 34
run: main 2: #(tagged record (integer 34)) => ((3 tagged-value))
mem: ((3 tagged-value)): 3 <= integer
mem: ((3 tagged-value)): 4 <= 34
run: main 3: (((1 channel-address) (deref)) <- ((write)) ((1 channel-address)) ((3 tagged-value)))
mem: ((1 channel-address)) => 1031
mem: ((3 tagged-value)) => #(tagged record (integer 34 . nil))
run: write/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: write/main 0: 1039 => ((default-space space-address))
run: write/main 1: (((1 channel-address)) <- ((next-input)))
arg: nil 0 (1031 #(tagged record (integer 34 . nil)))
run: write/main 1: 1031 => ((1 channel-address))
mem: ((1 channel-address)): 1041 <= 1031
run: write/main 2: (((2 tagged-value)) <- ((next-input)))
arg: nil 1 (1031 #(tagged record (integer 34 . nil)))
run: write/main 2: #(tagged record (integer 34 . nil)) => ((2 tagged-value))
mem: ((2 tagged-value)): 1042 <= integer
mem: ((2 tagged-value)): 1043 <= 34
run: write/main 3: (((4 boolean)) <- ((full?)) ((1 channel-address) (deref)))
mem: ((1 channel-address) (deref)) => #(tagged record (0 0 1034 . nil))
run: full?/write/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: full?/write/main 0: 1070 => ((default-space space-address))
run: full?/write/main 1: (((1 channel)) <- ((next-input)))
arg: nil 0 (#(tagged record (0 0 1034 . nil)))
run: full?/write/main 1: #(tagged record (0 0 1034 . nil)) => ((1 channel))
mem: ((1 channel)): 1072 <= 0
mem: ((1 channel)): 1073 <= 0
mem: ((1 channel)): 1074 <= 1034
run: full?/write/main 2: (((4 integer)) <- ((get)) ((1 channel)) ((1 offset)))
mem: ((1073 integer) (raw)) => 0
run: full?/write/main 2: 0 => ((4 integer))
mem: ((4 integer)): 1075 <= 0
run: full?/write/main 3: (((4 integer)) <- ((add)) ((4 integer)) ((1 literal)))
mem: ((4 integer)) => 0
run: full?/write/main 3: 1 => ((4 integer))
mem: ((4 integer)): 1075 <= 1
run: full?/write/main 4: (((5 integer)) <- ((capacity)) ((1 channel)))
mem: ((1 channel)) => #(tagged record (0 0 1034 . nil))
run: capacity/full?/write/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: capacity/full?/write/main 0: 1101 => ((default-space space-address))
run: capacity/full?/write/main 1: (((1 channel)) <- ((next-input)))
arg: nil 0 (#(tagged record (0 0 1034 . nil)))
run: capacity/full?/write/main 1: #(tagged record (0 0 1034 . nil)) => ((1 channel))
mem: ((1 channel)): 1103 <= 0
mem: ((1 channel)): 1104 <= 0
mem: ((1 channel)): 1105 <= 1034
run: capacity/full?/write/main 2: (((4 tagged-value-array-address)) <- ((get)) ((1 channel)) ((2 offset)))
mem: ((1105 tagged-value-array-address) (raw)) => 1034
run: capacity/full?/write/main 2: 1034 => ((4 tagged-value-array-address))
mem: ((4 tagged-value-array-address)): 1106 <= 1034
run: capacity/full?/write/main 3: (((5 integer)) <- ((length)) ((4 tagged-value-array-address) (deref)))
array-len: ((4 tagged-value-array-address) (deref))
mem: ((1034 integer) (raw)) => 2
run: capacity/full?/write/main 3: 2 => ((5 integer))
mem: ((5 integer)): 1107 <= 2
run: capacity/full?/write/main 4: (((reply)) ((5 integer)))
mem: ((5 integer)) => 2
run: full?/write/main 4: 2 => ((5 integer))
mem: ((5 integer)): 1076 <= 2
run: full?/write/main 5: (((6 boolean)) <- ((less-than)) ((4 integer)) ((5 integer)))
mem: ((4 integer)) => 1
mem: ((5 integer)) => 2
run: full?/write/main 5: t => ((6 boolean))
mem: ((6 boolean)): 1077 <= t
run: full?/write/main 6: (((jump-if)) ((6 boolean)) ((1 offset)))
mem: ((6 boolean)) => t
run: full?/write/main 8: (((7 integer)) <- ((get)) ((1 channel)) ((0 offset)))
mem: ((1072 integer) (raw)) => 0
run: full?/write/main 8: 0 => ((7 integer))
mem: ((7 integer)): 1078 <= 0
run: full?/write/main 9: (((8 boolean)) <- ((equal)) ((7 integer)) ((4 integer)))
mem: ((7 integer)) => 0
mem: ((4 integer)) => 1
run: full?/write/main 9: nil => ((8 boolean))
mem: ((8 boolean)): 1079 <= nil
run: full?/write/main 10: (((reply)) ((8 boolean)))
mem: ((8 boolean)) => nil
run: write/main 3: nil => ((4 boolean))
mem: ((4 boolean)): 1044 <= nil
run: write/main 4: (((jump-unless)) ((4 boolean)) ((2 offset)))
mem: ((4 boolean)) => nil
run: write/main 7: (((6 tagged-value-array-address)) <- ((get)) ((1 channel-address) (deref)) ((2 offset)))
mem: ((1033 tagged-value-array-address) (raw)) => 1034
run: write/main 7: 1034 => ((6 tagged-value-array-address))
mem: ((6 tagged-value-array-address)): 1046 <= 1034
run: write/main 8: (((7 integer-address)) <- ((get-address)) ((1 channel-address) (deref)) ((1 offset)))
run: write/main 8: 1032 => ((7 integer-address))
mem: ((7 integer-address)): 1047 <= 1032
run: write/main 9: (((8 tagged-value-address)) <- ((index-address)) ((6 tagged-value-array-address) (deref)) ((7 integer-address) (deref)))
mem: ((7 integer-address) (deref)) => 0
array-len: ((1034 tagged-value-array) (raw))
mem: ((1034 integer) (raw)) => 2
run: write/main 9: 1035 => ((8 tagged-value-address))
mem: ((8 tagged-value-address)): 1048 <= 1035
run: write/main 10: (((8 tagged-value-address) (deref)) <- ((copy)) ((2 tagged-value)))
mem: ((2 tagged-value)) => #(tagged record (integer 34 . nil))
run: write/main 10: #(tagged record (integer 34 . nil)) => ((8 tagged-value-address) (deref))
mem: ((8 tagged-value-address) (deref)): 1035 <= integer
mem: ((8 tagged-value-address) (deref)): 1036 <= 34
run: write/main 11: (((7 integer-address) (deref)) <- ((add)) ((7 integer-address) (deref)) ((1 literal)))
mem: ((7 integer-address) (deref)) => 0
run: write/main 11: 1 => ((7 integer-address) (deref))
mem: ((7 integer-address) (deref)): 1032 <= 1
run: write/main 12: (((9 integer)) <- ((length)) ((6 tagged-value-array-address) (deref)))
array-len: ((6 tagged-value-array-address) (deref))
mem: ((1034 integer) (raw)) => 2
run: write/main 12: 2 => ((9 integer))
mem: ((9 integer)): 1049 <= 2
run: write/main 13: (((10 boolean)) <- ((less-than)) ((7 integer-address) (deref)) ((9 integer)))
mem: ((7 integer-address) (deref)) => 1
mem: ((9 integer)) => 2
run: write/main 13: t => ((10 boolean))
mem: ((10 boolean)): 1050 <= t
run: write/main 14: (((jump-if)) ((10 boolean)) ((1 offset)))
mem: ((10 boolean)) => t
run: write/main 16: (((reply)) ((1 channel-address) (deref) (same-as-arg 0)))
mem: ((1 channel-address) (deref) (same-as-arg 0)) => #(tagged record (0 1 1034 . nil))
run: main 3: #(tagged record (0 1 1034 . nil)) => ((1 channel-address) (deref))
mem: ((1 channel-address) (deref)): 1031 <= 0
mem: ((1 channel-address) (deref)): 1032 <= 1
mem: ((1 channel-address) (deref)): 1033 <= 1034
run: main 4: (((5 boolean)) <- ((empty?)) ((1 channel-address) (deref)))
mem: ((1 channel-address) (deref)) => #(tagged record (0 1 1034 . nil))
run: empty?/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: empty?/main 0: 1132 => ((default-space space-address))
run: empty?/main 1: (((1 channel)) <- ((next-input)))
arg: nil 0 (#(tagged record (0 1 1034 . nil)))
run: empty?/main 1: #(tagged record (0 1 1034 . nil)) => ((1 channel))
mem: ((1 channel)): 1134 <= 0
mem: ((1 channel)): 1135 <= 1
mem: ((1 channel)): 1136 <= 1034
run: empty?/main 2: (((4 integer)) <- ((get)) ((1 channel)) ((0 offset)))
mem: ((1134 integer) (raw)) => 0
run: empty?/main 2: 0 => ((4 integer))
mem: ((4 integer)): 1137 <= 0
run: empty?/main 3: (((5 integer)) <- ((get)) ((1 channel)) ((1 offset)))
mem: ((1135 integer) (raw)) => 1
run: empty?/main 3: 1 => ((5 integer))
mem: ((5 integer)): 1138 <= 1
run: empty?/main 4: (((6 boolean)) <- ((equal)) ((4 integer)) ((5 integer)))
mem: ((4 integer)) => 0
mem: ((5 integer)) => 1
run: empty?/main 4: nil => ((6 boolean))
mem: ((6 boolean)): 1139 <= nil
run: empty?/main 5: (((reply)) ((6 boolean)))
mem: ((6 boolean)) => nil
run: main 4: nil => ((5 boolean))
mem: ((5 boolean)): 5 <= nil
run: main 5: (((6 boolean)) <- ((full?)) ((1 channel-address) (deref)))
mem: ((1 channel-address) (deref)) => #(tagged record (0 1 1034 . nil))
run: full?/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: full?/main 0: 1163 => ((default-space space-address))
run: full?/main 1: (((1 channel)) <- ((next-input)))
arg: nil 0 (#(tagged record (0 1 1034 . nil)))
run: full?/main 1: #(tagged record (0 1 1034 . nil)) => ((1 channel))
mem: ((1 channel)): 1165 <= 0
mem: ((1 channel)): 1166 <= 1
mem: ((1 channel)): 1167 <= 1034
run: full?/main 2: (((4 integer)) <- ((get)) ((1 channel)) ((1 offset)))
mem: ((1166 integer) (raw)) => 1
run: full?/main 2: 1 => ((4 integer))
mem: ((4 integer)): 1168 <= 1
run: full?/main 3: (((4 integer)) <- ((add)) ((4 integer)) ((1 literal)))
mem: ((4 integer)) => 1
run: full?/main 3: 2 => ((4 integer))
mem: ((4 integer)): 1168 <= 2
run: full?/main 4: (((5 integer)) <- ((capacity)) ((1 channel)))
mem: ((1 channel)) => #(tagged record (0 1 1034 . nil))
run: capacity/full?/main 0: (((default-space space-address)) <- ((new)) ((space literal)) ((30 literal)))
run: capacity/full?/main 0: 1194 => ((default-space space-address))
run: capacity/full?/main 1: (((1 channel)) <- ((next-input)))
arg: nil 0 (#(tagged record (0 1 1034 . nil)))
run: capacity/full?/main 1: #(tagged record (0 1 1034 . nil)) => ((1 channel))
mem: ((1 channel)): 1196 <= 0
mem: ((1 channel)): 1197 <= 1
mem: ((1 channel)): 1198 <= 1034
run: capacity/full?/main 2: (((4 tagged-value-array-address)) <- ((get)) ((1 channel)) ((2 offset)))
mem: ((1198 tagged-value-array-address) (raw)) => 1034
run: capacity/full?/main 2: 1034 => ((4 tagged-value-array-address))
mem: ((4 tagged-value-array-address)): 1199 <= 1034
run: capacity/full?/main 3: (((5 integer)) <- ((length)) ((4 tagged-value-array-address) (deref)))
array-len: ((4 tagged-value-array-address) (deref))
mem: ((1034 integer) (raw)) => 2
run: capacity/full?/main 3: 2 => ((5 integer))
mem: ((5 integer)): 1200 <= 2
run: capacity/full?/main 4: (((reply)) ((5 integer)))
mem: ((5 integer)) => 2
run: full?/main 4: 2 => ((5 integer))
mem: ((5 integer)): 1169 <= 2
run: full?/main 5: (((6 boolean)) <- ((less-than)) ((4 integer)) ((5 integer)))
mem: ((4 integer)) => 2
mem: ((5 integer)) => 2
run: full?/main 5: nil => ((6 boolean))
mem: ((6 boolean)): 1170 <= nil
run: full?/main 6: (((jump-if)) ((6 boolean)) ((1 offset)))
mem: ((6 boolean)) => nil
run: full?/main 7: (((4 integer)) <- ((copy)) ((0 literal)))
run: full?/main 7: 0 => ((4 integer))
mem: ((4 integer)): 1168 <= 0
run: full?/main 8: (((7 integer)) <- ((get)) ((1 channel)) ((0 offset)))
mem: ((1165 integer) (raw)) => 0
run: full?/main 8: 0 => ((7 integer))
mem: ((7 integer)): 1171 <= 0
run: full?/main 9: (((8 boolean)) <- ((equal)) ((7 integer)) ((4 integer)))
mem: ((7 integer)) => 0
mem: ((4 integer)) => 0
run: full?/main 9: t => ((8 boolean))
mem: ((8 boolean)): 1172 <= t
run: full?/main 10: (((reply)) ((8 boolean)))
mem: ((8 boolean)) => t
run: main 5: t => ((6 boolean))
mem: ((6 boolean)): 6 <= t
schedule: done with routine nil
='n78' href='#n78'>78 79 80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129



                                                                                          
                                    

                                                
                                  

                                                                                         

                       
                                                                                                 
                                                                                            
                                      
                             
                                  
                            



                                                                           

        





                               

       
                         



                                                                                                              




                                                                                                          


                                                                                                          
 
                                                
                                                                               
          

                                                                                                                                                                                                                                                                                                      
                                                                                                                                                    
 
                                                                                                
                                                                                               

                                                                                                          


                                                                                                                                             
                                                                                                                  
                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                    
                                                                      


                                                                               
                                                                                                                                                                              





                                                                                                                                              
                                                                                                    

                                                                                                                                                                                                                                                       


                                                                                                             

                                                                                                                                                                                                                                              




                                                                                                                   
                                                                                                                                                                       
                                                                                                      


                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                               
                                                                                                                                                                           
                                    
                                                                                                                                                                                                                                               


                                                                                                                               











                                                                                                                                                                                                                                                                                                                                    




                                                                               
          






                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                               


       
                                     
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 017parse_tree.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.Constant { color: #00a0a0; }
.traceContains { color: #008000; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.Special { color: #c00000; }
.Identifier { color: #fcb165; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">// So far instructions can only contain linear lists of properties. Now we add</span>
<span class="Comment">// support for more complex trees of properties in dilated reagents. This will</span>
<span class="Comment">// come in handy later for expressing complex types, like &quot;a dictionary from</span>
<span class="Comment">// (address to array of charaters) to (list of numbers)&quot;.</span>
<span class="Comment">//</span>
<span class="Comment">// Type trees aren't as general as s-expressions even if they look like them:</span>
<span class="Comment">// the first element of a type tree is always an atom, and left and right</span>
<span class="Comment">// pointers of non-atoms are never NULL. All type trees are 'dotted' in lisp</span>
<span class="Comment">// parlance.</span>
<span class="Comment">//</span>
<span class="Comment">// For now you can't use the simpler 'colon-based' representation inside type</span>
<span class="Comment">// trees. Once you start typing parens, keep on typing parens.</span>

<span class="Delimiter">:(scenarios load)</span>
<span class="Delimiter">:(scenario dilated_reagent_with_nested_brackets)</span>
def main [
  <span class="Delimiter">{</span><span class="Constant">1</span>: number<span class="Delimiter">,</span> foo: <span class="Delimiter">(</span>bar <span class="Delimiter">(</span>baz quux<span class="Delimiter">))}</span><span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
]
<span class="traceContains">+parse:   product: {1: &quot;number&quot;, &quot;foo&quot;: (&quot;bar&quot; (&quot;baz&quot; &quot;quux&quot;))}</span>

<span class="Delimiter">:(before &quot;End Parsing Dilated Reagent Property(value)&quot;)</span>
value = parse_string_tree<span class="Delimiter">(</span>value<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Parsing Dilated Reagent Type Property(type_names)&quot;)</span>
type_names = parse_string_tree<span class="Delimiter">(</span>type_names<span class="Delimiter">);</span>

<span class="Delimiter">:(code)</span>
string_tree* parse_string_tree<span class="Delimiter">(</span>string_tree* s<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>s<span class="Delimiter">-&gt;</span>atom<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!starts_with<span class="Delimiter">(</span>s<span class="Delimiter">-&gt;</span>value<span class="Delimiter">,</span> <span class="Constant">&quot;(&quot;</span><span class="Delimiter">))</span> <span class="Identifier">return</span> s<span class="Delimiter">;</span>
  string_tree* result = parse_string_tree<span class="Delimiter">(</span>s<span class="Delimiter">-&gt;</span>value<span class="Delimiter">);</span>
  <span class="Normal">delete</span> s<span class="Delimiter">;</span>
  <span class="Identifier">return</span> result<span class="Delimiter">;</span>
<span class="Delimiter">}</span>

string_tree* parse_string_tree<span class="Delimiter">(</span><span class="Normal">const</span> string&amp; s<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span>
  in &gt;&gt; std::noskipws<span class="Delimiter">;</span>
  <span class="Identifier">return</span> parse_string_tree<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
<span class="Delimiter">}</span>

string_tree* parse_string_tree<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  skip_whitespace_but_not_newline<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">')'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
    <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="Constant">'('</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    string_tree* result = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>next_word<span class="Delimiter">(</span>in<span class="Delimiter">));</span>
    <span class="Identifier">return</span> result<span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>  <span class="Comment">// skip '('</span>
  string_tree* result = <span class="Constant">NULL</span><span class="Delimiter">;</span>
  string_tree** curr = &amp;result<span class="Delimiter">;</span>
  <span class="Normal">while</span> <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    skip_whitespace_but_not_newline<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
    assert<span class="Delimiter">(</span>has_data<span class="Delimiter">(</span>in<span class="Delimiter">));</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">')'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
    *curr = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span><span class="Constant">NULL</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'('</span><span class="Delimiter">)</span>
      <span class="Delimiter">(</span>*curr<span class="Delimiter">)-&gt;</span>left = parse_string_tree<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
    <span class="Normal">else</span>
      <span class="Delimiter">(</span>*curr<span class="Delimiter">)-&gt;</span>left = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>next_word<span class="Delimiter">(</span>in<span class="Delimiter">));</span>
    curr = &amp;<span class="Delimiter">(</span>*curr<span class="Delimiter">)-&gt;</span>right<span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>  <span class="Comment">// skip ')'</span>
  assert<span class="Delimiter">(</span>*curr == <span class="Constant">NULL</span><span class="Delimiter">);</span>
  <span class="Comment">// standardize the final element to always be on the right if it's an atom</span>
  <span class="Comment">// (a b c) =&gt; (a b . c) in s-expression parlance</span>
  string_tree* tmp = result<span class="Delimiter">;</span>
  <span class="Normal">while</span> <span class="Delimiter">(</span>tmp<span class="Delimiter">-&gt;</span>right &amp;&amp; tmp<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">)</span> tmp = tmp<span class="Delimiter">-&gt;</span>right<span class="Delimiter">;</span>
  assert<span class="Delimiter">(</span>!tmp<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>atom<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!tmp<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>left<span class="Delimiter">-&gt;</span>atom<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span>
  string_tree* tmp2 = tmp<span class="Delimiter">-&gt;</span>right<span class="Delimiter">;</span>
  tmp<span class="Delimiter">-&gt;</span>right = tmp2<span class="Delimiter">-&gt;</span>left<span class="Delimiter">;</span>
  tmp2<span class="Delimiter">-&gt;</span>left = <span class="Constant">NULL</span><span class="Delimiter">;</span>
  assert<span class="Delimiter">(</span>tmp2<span class="Delimiter">-&gt;</span>right == <span class="Constant">NULL</span><span class="Delimiter">);</span>
  <span class="Normal">delete</span> tmp2<span class="Delimiter">;</span>
  <span class="Identifier">return</span> result<span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(scenario dilated_reagent_with_type_tree)</span>
<span class="Special">% Hide_errors = true;  // 'map' isn't defined yet</span>
def main [
  <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>foo <span class="Delimiter">(</span>address array character<span class="Delimiter">)</span> <span class="Delimiter">(</span>bar number<span class="Delimiter">))}</span><span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
]
<span class="Comment"># just to avoid errors</span>
container foo [
]
container bar [
]
<span class="traceContains">+parse:   product: {1: (&quot;foo&quot; (&quot;address&quot; &quot;array&quot; &quot;character&quot;) (&quot;bar&quot; &quot;number&quot;))}</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->