44 lines
809 B
Plaintext
44 lines
809 B
Plaintext
(remove-comments) text:
|
|
]
|
|
for line in text:
|
|
if and line not starts-with line "#":
|
|
line
|
|
[
|
|
|
|
(markov-parse) text:
|
|
]
|
|
for line in text:
|
|
local :index find line " -> "
|
|
local :pat slice line 0 index
|
|
local :rep slice line + index 4 len line
|
|
local :term starts-with rep "."
|
|
if term:
|
|
set :rep slice rep 1 len rep
|
|
& pat & term rep
|
|
[
|
|
|
|
markov-parse:
|
|
(markov-parse) (remove-comments) split !decode!utf-8 !read!stdin "\n"
|
|
|
|
(markov-tick) rules start:
|
|
for rule in copy rules:
|
|
local :pat &< rule
|
|
local :rep &> dup &> rule
|
|
local :term &<
|
|
local :index find start pat
|
|
if < -1 index:
|
|
)
|
|
slice start + index len pat len start
|
|
rep
|
|
slice start 0 index
|
|
concat(
|
|
return term
|
|
true start
|
|
|
|
markov rules:
|
|
true
|
|
while:
|
|
not (markov-tick) rules
|
|
|
|
!. markov markov-parse get-from !args 1
|