34 lines
1.5 KiB
Text
34 lines
1.5 KiB
Text
commands:=Data(0,String, // "add\01\0alter\0..."
|
|
#<<<
|
|
"add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3
|
|
compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate
|
|
3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2
|
|
forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load
|
|
locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2
|
|
msg next 1 overlay 1 parse preserve 4 purge 3 put putD query 1 quit read recover 3
|
|
refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left
|
|
2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1"
|
|
.toUpper().split());
|
|
#<<<
|
|
|
|
var szs=Dictionary(); // [<index>:<length> ...]
|
|
n:=0; while(n<commands.len()){
|
|
cmd,nc := commands.readString(n), n + cmd.len() + 1;
|
|
len:=commands.readString(nc);
|
|
if(len.matches("[0-9]*")){ szs[n]=len.toInt(); n=nc+len.len()+1 }
|
|
else { szs[n]=cmd.len(); n=nc; }
|
|
}
|
|
|
|
testText:="riG rePEAT copies put mo rest types "
|
|
" fup. 6 poweRin";
|
|
|
|
testText.split().apply('wrap(w){
|
|
w=w.toUpper(); n:=0;
|
|
while(True){ // check for length requirement and, if there, verify
|
|
n=commands.find(w,n);
|
|
if(Void==n) return("*error*"); // end of loop if no match
|
|
c:=commands.readString(n);
|
|
if(w.len()>=szs.find(n,99999)) return(c);
|
|
n+=c.len();
|
|
}
|
|
}).concat(" ").println();
|