|
|
@ -20,7 +20,13 @@ function generate(start, rules, iterations) { |
|
|
|
while(pos < start.length) { |
|
|
|
while(pos < start.length) { |
|
|
|
let w = start.slice(pos, pos + rule[0].length); |
|
|
|
let w = start.slice(pos, pos + rule[0].length); |
|
|
|
if(startswith(w, rule[0])) { |
|
|
|
if(startswith(w, rule[0])) { |
|
|
|
start.splice(pos, rule[0].length, rule[1]) |
|
|
|
var ruleres; |
|
|
|
|
|
|
|
if(typeof rule[1] == 'function') { |
|
|
|
|
|
|
|
ruleres = rule[1](); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ruleres = rule[1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
start.splice(pos, rule[0].length, ruleres) |
|
|
|
pos += rule[0].length; |
|
|
|
pos += rule[0].length; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
pos += 1; |
|
|
|
pos += 1; |
|
|
|