121 else{ |
121 else{ |
122 (head left_align (port beside pref) ) left_align (port up_align suff) |
122 (head left_align (port beside pref) ) left_align (port up_align suff) |
123 } |
123 } |
124 } |
124 } |
125 val arr_of_size = ListBuffer.empty[Int] |
125 val arr_of_size = ListBuffer.empty[Int] |
126 def spill(r: Rexp, or: Rexp): Set[Rexp] = { |
126 |
127 if(r == or) |
|
128 Set(r) |
|
129 else{ |
|
130 r match { |
|
131 case ALTS(rs) => rs.flatMap(r1 => spill(r1, or)).toSet |
|
132 case SEQ(ALTS(rs), r3) => rs.flatMap(r1 => spill(r1, or).map(a => if(a == ONE) r3 else SEQ(a, r3)) ).toSet |
|
133 case ZERO => Set() |
|
134 case r => Set(r) |
|
135 } |
|
136 } |
|
137 } |
|
138 def pC(r: Rexp): Set[Rexp] = {//PD's companion |
127 def pC(r: Rexp): Set[Rexp] = {//PD's companion |
139 r match { |
128 r match { |
140 case SEQ(r1, r2) => pC(r2) |
129 case SEQ(r1, r2) => pC(r2) |
141 case ALTS(rs) => rs.flatMap(a => pC(a) ).toSet |
130 case ALTS(rs) => rs.flatMap(a => pC(a) ).toSet |
142 case CHAR(c) => Set(r) |
131 case CHAR(c) => Set(r) |
143 case r => Set() |
132 case r => Set() |
144 } |
133 } |
145 } |
134 } |
146 |
|
147 def aspill(ar: ARexp, or: Rexp): Set[Rexp] = spill(erase(ar), or) |
|
148 def illustration(r: Rexp, s: String){ |
135 def illustration(r: Rexp, s: String){ |
149 var i_like_imperative_style = internalise(r) |
136 var i_like_imperative_style = internalise(r) |
150 val all_chars = s.toList |
137 val all_chars = s.toList |
151 for (i <- 0 to s.length - 1){ |
138 for (i <- 0 to s.length - 1){ |
152 val der_res = bder(all_chars(i), i_like_imperative_style) |
139 val der_res = bder(all_chars(i), i_like_imperative_style) |