2026-02-01 16:33:20 -08:00
|
|
|
-- demo\rosetta\inverted_syntax.exw
|
|
|
|
|
without js
|
|
|
|
|
constant pun = split(join_by("()[]=,-",7,1,"","*"),"*",true)
|
|
|
|
|
constant nup = split(join_by(")(][=,-",7,1,"","*"),"*",true)
|
|
|
|
|
constant rip = split(join_by(" <>{}@!- ",7,3,"","*"),"*",true)
|
2023-07-01 11:58:00 -04:00
|
|
|
|
2026-02-01 16:33:20 -08:00
|
|
|
function mung(string pgm)
|
|
|
|
|
sequence lines=reverse(split(substitute_all(pgm,pun,rip),"\r\n"))
|
|
|
|
|
for i=1 to length(lines) do lines[i] = substitute_all(join(reverse(split(lines[i]))),rip,nup) end for
|
|
|
|
|
return join(lines,"\n")
|
|
|
|
|
end function
|
|
|
|
|
sequence cl = command_line()
|
|
|
|
|
string pgm = get_text(cl[$])
|
|
|
|
|
include write_file.e
|
|
|
|
|
{} = write_file("test.exw",mung(pgm)&"\n")
|
|
|
|
|
if length(cl)>2 then
|
|
|
|
|
system(cl[1]&"test.exw")
|
|
|
|
|
end if
|