[REBOL] Re: Rebol Product Suggestion.
From: agem:crosswinds at: 25-Jun-2001 2:01
RE: [REBOL] Re: Rebol Product Suggestion.
[g--santilli--tiscalinet--it] wrote:
> Hello Joel!
>
> On 24-Giu-01, you wrote:
>
--snip--
> JN> ply: func [print [series!] = [string! char!] /local
> JN> probe word? ] [ probe: copy word?: "" foreach to
> JN> print [ repend probe [ word? to ] word?: = ] probe ]
>
> This is nice, too. But I'm afraid it would be almost impossible to
> do automatically... (as you point out, too)
>
[REBOL [
title: "translate rebol-scripts to another language"
content: true
file: %trans3.r
comment: {
had a quick look on hd, not sure what this is ;-)
feature: translates words in pathes too, so
this/that would go dies/das .
based on Carls %clean-script.r
PROTOTYP, own risks and that! ;-)
}
]
script-cleaner: make object! [
a: none
to-type: func [t w] [
do load mold compose/deep [to (type? :t) first [(:w)]]
]
any-path?: func [s] [
any [path? :s set-path? :s lit-path? :s]
]
deutsch: make hash! [
;rebol
= any-word? ein-wort?
any manche
append ha&ng-an
change a&ndere
clear sa&ubere
compose stelle-zusammen
copy kopiere
deep tief
difference unterschied
do tue
does tut
either entscheide
emit gib-aus
end text-ende
first erstes
forall *jeder
forskip *gruppiert
found? gefunden?
func rezept
hash schnellfinder
head anfang
if wenn
last letztes
load lade
mold rebol-text
newline neue-zeile
next danach
parse analysiere
pick nimm-nr
remove entferne-an
set setze
select wa&hle-aus
skip u&berspringe
some einige
sort sortiere
tail ende
thru durch
to zu
true richtig
unique ohne-doppelte
;meins
a a
new neu
value wert
]
forskip deutsch 2 [change deutsch to string! first deutsch] deutsch: head deutsch
words: copy []
w: func [w /local e o] [
append words to word! :w
e: select deutsch to string! to word! :w
either e [to-type :w :e] [:w]
]
out: none ; output text
spaced: off ; add extra bracket spacing
indent: "" ; holds indentation tabs
emit-line: func [] [append out newline]
emit-space: func [pos] [
append out either newline = last out [indent] [
pick [#" " ""] found? any [
spaced
not any [find "[(" last out find ")]" first pos]
]
]
]
emit: func [from to] [emit-space from append out copy/part from to]
set 'clean-script func [
"Returns new script text with standard spacing."
script "Original Script text"
/spacey "Optional spaces near brackets and parens"
/local str new
] [
spaced: found? spacey
out: append clear copy script newline
parse script blk-rule: [
some [
str:
newline (emit-line) |
#";" [thru newline | to end] new: (emit str new) |
[#"[" | #"("] (emit str 1 append indent tab) blk-rule |
[#"]" | #")"] (remove indent emit str 1) |
skip (set [value new] load/next str
any [
if any-word? :value [emit a: mold w :value tail a true]
if any-path? :value [
forall value [if any-word? value/1 [value/1: w value/1]] value: head :value
emit a: mold :value tail a
true
]
do [emit str new]
]
) :new
]
]
remove out ; remove first char
]
dump: does [
probe sort unique script-cleaner/words
a: copy []
forskip deutsch 2 [append a to word! deutsch/1] deutsch: head deutsch
probe sort exclude words a
]
]
? 123
save f: system/script/header/file load/header system/script/header/content
print example: clean-script read f
;script-cleaner/dump
]
> Regards,
> Gabriele.
;-) Volker