TextPad 4 Syntax File Generator
[1/1] from: johnkenyon::uk::ibm::com at: 5-Dec-2000 14:08
To all Windows users,
Here is a quick hack at a syntax generator for Textpad 4.4 for rebol.
It grabs lists of keywords by type using the same technique as the help
function.
Not intended to be an example of good rebol code just a useful tool. Should
work with core and view (probably command too) though only tested with view
0.10.38.3.1.
As this reads system/words it will also include any user defined words or
functions in the syntax file so re-run it whenever you define something new
in your user.r
Source based upon source help among others.
Hope people find it useful. Any comments would be appreciated.
Cheers, John
8<--
REBOL [
Title: "Textpad syntax generator"
Date: 04-Dec-2000
File: %text-pad.r
Author: "John Kenyon"
Version: "0.1"
Purpose: {
Textpad syntax generator for Textpad 4.4
}
]
basic-syntax-header: rejoin [
{; TextPad syntax definitions for Rebol (http://www.rebol.com)
; JKenyon generated } now/date
{
C=1
[Syntax]
Namespace1 = 6
IgnoreCase = Yes
InitKeyWordChars = A-Za-z_$
KeyWordChars = A-Za-z0-9_$
BracketChars = []{}
OperatorChars PreprocStart SyntaxStart SyntaxEnd CommentStartAlt SingleComment = ;
SingleCommentEsc StringStart = "
StringEnd = "
StringsSpanLines = Yes
StringAlt StringEsc = \
CharStart = '
CharEnd = '
CharEsc = \
}
]
mapping: [
"Keywords 1" 'op!
"Keywords 2" 'action!
"Keywords 3" 'function!
"Keywords 4" 'decimal!
"Keywords 5" 'string!
]
find-by-type: func [ search-type ] [
list-words: copy ""
word: search-type
types: copy []
attrs: second system/words
if all [word? :word not value? :word] [word: mold :word]
if any [string? :word all [word? :word datatype? get :word]] [
foreach item first system/words [
value: copy " "
change value :item
if all [not unset? first attrs
any [
all [string? :word find value word]
all [not string? :word datatype? get :word (get :word)
= type? first attrs]
]
] [
append types value
]
attrs: next attrs
]
sort types
if not empty? types [
foreach item types [append list-words join item newline ]
]
]
return list-words
]
outstr: make string! 10000
emit: func [ val ] [
either block? val [
val: reduce val
foreach item val [
outstr: append outstr form item
]
] [
outstr: append outstr form val
]
]
; Now generate the file
emit basic-syntax-header
foreach [ keyword word-type ] mapping [
emit [ newline "[" keyword "]" newline ]
emit [ find-by-type word-type ]
]
write to-file ask "Save as ... eg /c/Program Files/TextPad
4/Samples/rebol.syn > " outstr
; or in view
; write first request-file outstr