Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Syntax highlighting

From: john_kenyon:mlc:au at: 5-Oct-2001 12:46

All, Sorry for the large post. With everyone using different text editors with syntax highlighting I though this may come in useful. Just add the words 'op! 'action! etc to your vanilla syntax file and it will search and replace with the actual words split by a separator. Comments, improvements, complete rewrites appreciated :) (watch out for any lines >80 chars which may have wrapped) Cheers, John REBOL [ Title: "Syntax generator" Date: 5-Oct-2001 File: %syntax-gen.r Author: "John Kenyon" email: [johnkenyon--iname--com] Version: "0.1" Purpose: { Generic syntax file generator for Rebol Uses template format for syntax files Grabs words using a modifed version of 'help } History: { 0.1 5-Oct-2001 "First attempt at a more generic Rebol syntax generator" } Instructions: { Take a syntax file for your favourite editor Add 'op! 'action! 'datatype! 'native! 'string! 'function! 'view 'none to sensible positions in the syntax file Run this code and select the syntax file - it will replace all of the occurances with rebol words Separator is the string to place between each word (defaults to newline) Re-run for each new version of Rebol (and whenver you add new definitions to your user.r) Tested with core and view - should work with command } ] categories: [ 'op! 'action! 'datatype! 'native! 'string! 'function! ] 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 value first system/words [ 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 separator ] ] list-words: head remove back tail list-words ] return list-words ] if error? try [ view? ] [ view?: false ] either view? [ in-file: request-file/title/filter "Location of Rebol syntax file" "Open" "*" in-file: to-file first in-file view layout [ label "Separator between words - default newline" separator: field button "OK" [unview] ] separator: separator/data ] [ in-file: to-file ask "Please enter full path to template file: " separator: ask "Separator between words - default newline: " ] if equal? separator "" [ separator: newline ] template: read in-file foreach word-type categories [ replace/all template to-string join "'" word-type find-by-type word-type ] either view? [ view-words: copy "" foreach word system/view/vid/vid-words [ append view-words join word separator ] replace/all template "'view" view-words ] [ replace/all template "'view" "" ] replace/all template "'none" "none" either view? [ out-file: request-file/title/filter "Location to save Rebol syntax file" "Save" "*.syn" if not none? out-file [ write first out-file template ] ][ write to-file ask "Save as ... eg /c/Program Files/TextPad 4/Samples/rebol.syn > " template ]