summaryrefslogtreecommitdiff
path: root/runtime/syntax/forth.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/syntax/forth.vim')
-rw-r--r--runtime/syntax/forth.vim110
1 files changed, 86 insertions, 24 deletions
diff --git a/runtime/syntax/forth.vim b/runtime/syntax/forth.vim
index a61f7db3f..8713a721a 100644
--- a/runtime/syntax/forth.vim
+++ b/runtime/syntax/forth.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: FORTH
" Maintainer: Christian V. J. Brüssow <cvjb@cvjb.de>
-" Last Change: Sa 14 Jul 2007 21:39:53 CEST
+" Last Change: Sa 09 Feb 2008 13:27:29 CET
" Filenames: *.fs,*.ft
" URL: http://www.cvjb.de/comp/vim/forth.vim
@@ -10,9 +10,17 @@
" The list of keywords is incomplete, compared with the offical ANS
" wordlist. If you use this language, please improve it, and send me
" the patches.
+"
+" Before sending me patches, please download the newest version of this file
+" from http://www.cvjb.de/comp/vim/forth.vim or http://www.vim.org/ (search
+" for forth.vim).
" Many Thanks to...
"
+" 2008-02-09:
+" Shawn K. Quinn <sjquinn at speakeasy dot net> send a big patch with
+" new words commonly used in Forth programs or defined by GNU Forth.
+"
" 2007-07-11:
" Benjamin Krill <ben at codiert dot org> send me a patch
" to highlight space errors.
@@ -79,7 +87,7 @@ syn keyword forthTodo contained TODO FIXME XXX
syn match forthTodo contained 'Copyright\(\s([Cc])\)\=\(\s[0-9]\{2,4}\)\='
" Characters allowed in keywords
-" I don't know if 128-255 are allowed in ANS-FORHT
+" I don't know if 128-255 are allowed in ANS-FORTH
if version >= 600
setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
else
@@ -100,21 +108,27 @@ endif
" basic mathematical and logical operators
syn keyword forthOperators + - * / MOD /MOD NEGATE ABS MIN MAX
-syn keyword forthOperators AND OR XOR NOT INVERT 2* 2/ 1+ 1- 2+ 2- 8*
+syn keyword forthOperators AND OR XOR NOT LSHIFT RSHIFT INVERT 2* 2/ 1+
+syn keyword forthOperators 1- 2+ 2- 8* UNDER+
syn keyword forthOperators M+ */ */MOD M* UM* M*/ UM/MOD FM/MOD SM/REM
-syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX
+syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX D2* D2/
syn keyword forthOperators F+ F- F* F/ FNEGATE FABS FMAX FMIN FLOOR FROUND
syn keyword forthOperators F** FSQRT FEXP FEXPM1 FLN FLNP1 FLOG FALOG FSIN
syn keyword forthOperators FCOS FSINCOS FTAN FASIN FACOS FATAN FATAN2 FSINH
-syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH
-syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= < <= <> = > >=
-syn keyword forthOperators ?NEGATE ?DNEGATE
+syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH F2* F2/ 1/F
+syn keyword forthOperators F~REL F~ABS F~
+syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= < <= <> = > >= U< U<=
+syn keyword forthOperators U> U>= D0< D0<= D0<> D0= D0> D0>= D< D<= D<>
+syn keyword forthOperators D= D> D>= DU< DU<= DU> DU>= WITHIN ?NEGATE
+syn keyword forthOperators ?DNEGATE
" stack manipulations
syn keyword forthStack DROP NIP DUP OVER TUCK SWAP ROT -ROT ?DUP PICK ROLL
-syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT
-syn keyword forthStack 3DUP 4DUP
+syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT 2-ROT
+syn keyword forthStack 3DUP 4DUP 5DUP 3DROP 4DROP 5DROP 8DROP 4SWAP 4ROT
+syn keyword forthStack 4-ROT 4TUCK 8SWAP 8DUP
syn keyword forthRStack >R R> R@ RDROP 2>R 2R> 2R@ 2RDROP
+syn keyword forthRstack 4>R 4R> 4R@ 4RDROP
syn keyword forthFStack FDROP FNIP FDUP FOVER FTUCK FSWAP FROT
" stack pointer manipulations
@@ -139,24 +153,40 @@ syn keyword forthLoop ?DO LOOP I J K +DO U+DO -DO U-DO DO +LOOP -LOOP
syn keyword forthLoop UNLOOP LEAVE ?LEAVE EXIT DONE FOR NEXT
" new words
+syn match forthClassDef '\<:class\s*[^ \t]\+\>'
+syn match forthObjectDef '\<:object\s*[^ \t]\+\>'
syn match forthColonDef '\<:m\?\s*[^ \t]\+\>'
syn keyword forthEndOfColonDef ; ;M ;m
-syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE CREATE
-syn keyword forthDefine USER VALUE TO DEFER IS DOES> IMMEDIATE COMPILE-ONLY
-syn keyword forthDefine COMPILE RESTRICT INTERPRET POSTPONE EXECUTE LITERAL
-syn keyword forthDefine CREATE-INTERPRET/COMPILE INTERPRETATION> <INTERPRETATION
-syn keyword forthDefine COMPILATION> <COMPILATION ] LASTXT COMP' POSTPONE,
-syn keyword forthDefine FIND-NAME NAME>INT NAME?INT NAME>COMP NAME>STRING STATE
-syn keyword forthDefine C; CVARIABLE
+syn keyword forthEndOfClassDef ;class
+syn keyword forthEndOfObjectDef ;object
+syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE
+syn keyword forthDefine FVARIABLE CREATE USER VALUE TO DEFER IS DOES> IMMEDIATE
+syn keyword forthDefine COMPILE-ONLY COMPILE RESTRICT INTERPRET POSTPONE EXECUTE
+syn keyword forthDefine LITERAL CREATE-INTERPRET/COMPILE INTERPRETATION>
+syn keyword forthDefine <INTERPRETATION COMPILATION> <COMPILATION ] LASTXT
+syn keyword forthDefine COMP' POSTPONE, FIND-NAME NAME>INT NAME?INT NAME>COMP
+syn keyword forthDefine NAME>STRING STATE C; CVARIABLE
+syn keyword forthDefine , 2, F, C,
+syn match forthDefine "\[IFDEF]"
+syn match forthDefine "\[IFUNDEF]"
+syn match forthDefine "\[THEN]"
+syn match forthDefine "\[ENDIF]"
+syn match forthDefine "\[ELSE]"
+syn match forthDefine "\[?DO]"
+syn match forthDefine "\[DO]"
+syn match forthDefine "\[LOOP]"
+syn match forthDefine "\[+LOOP]"
+syn match forthDefine "\[NEXT]"
+syn match forthDefine "\[BEGIN]"
+syn match forthDefine "\[UNTIL]"
+syn match forthDefine "\[AGAIN]"
+syn match forthDefine "\[WHILE]"
+syn match forthDefine "\[REPEAT]"
syn match forthDefine "\[COMP']"
syn match forthDefine "'"
syn match forthDefine '\<\[\>'
syn match forthDefine "\[']"
syn match forthDefine '\[COMPILE]'
-syn match forthClassDef '\<:class\s*[^ \t]\+\>'
-syn match forthObjectDef '\<:object\s*[^ \t]\+\>'
-syn keyword forthEndOfClassDef ';class'
-syn keyword forthEndOfObjectDef ';object'
" debugging
syn keyword forthDebug PRINTDEBUGDATA PRINTDEBUGLINE
@@ -175,27 +205,48 @@ syn match forthCharOps '\<\[char\]\s\S\s'
syn region forthCharOps start=+."\s+ skip=+\\"+ end=+"+
" char-number conversion
-syn keyword forthConversion <# # #> #S (NUMBER) (NUMBER?) CONVERT D>F D>S DIGIT
-syn keyword forthConversion DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER
+syn keyword forthConversion <<# <# # #> #>> #S (NUMBER) (NUMBER?) CONVERT D>F
+syn keyword forthConversion D>S DIGIT DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER
+syn keyword forthConversion F>S S>F
" interptreter, wordbook, compiler
syn keyword forthForth (LOCAL) BYE COLD ABORT >BODY >NEXT >LINK CFA >VIEW HERE
syn keyword forthForth PAD WORDS VIEW VIEW> N>LINK NAME> LINK> L>NAME FORGET
-syn keyword forthForth BODY>
+syn keyword forthForth BODY> ASSERT( ASSERT0( ASSERT1( ASSERT2( ASSERT3( )
syn region forthForth start=+ABORT"\s+ skip=+\\"+ end=+"+
" vocabularies
syn keyword forthVocs ONLY FORTH ALSO ROOT SEAL VOCS ORDER CONTEXT #VOCS
syn keyword forthVocs VOCABULARY DEFINITIONS
+" File keywords
+syn keyword forthFileMode R/O R/W W/O BIN
+syn keyword forthFileWords OPEN-FILE CREATE-FILE CLOSE-FILE DELETE-FILE
+syn keyword forthFileWords RENAME-FILE READ-FILE READ-LINE KEY-FILE
+syn keyword forthFileWords KEY?-FILE WRITE-FILE WRITE-LINE EMIT-FILE
+syn keyword forthFileWords FLUSH-FILE FILE-STATUS FILE-POSITION
+syn keyword forthFileWords REPOSITION-FILE FILE-SIZE RESIZE-FILE
+syn keyword forthFileWords SLURP-FILE SLURP-FID STDIN STDOUT STDERR
+syn keyword forthBlocks OPEN-BLOCKS USE LOAD --> BLOCK-OFFSET
+syn keyword forthBlocks GET-BLOCK-FID BLOCK-POSITION LIST SCR BLOCK
+syn keyword forthBlocks BUFER EMPTY-BUFFERS EMPTY-BUFFER UPDATE UPDATED?
+syn keyword forthBlocks SAVE-BUFFERS SAVE-BUFFER FLUSH THRU +LOAD +THRU
+syn keyword forthBlocks BLOCK-INCLUDED
+
" numbers
syn keyword forthMath DECIMAL HEX BASE
syn match forthInteger '\<-\=[0-9.]*[0-9.]\+\>'
+syn match forthInteger '\<&-\=[0-9.]*[0-9.]\+\>'
" recognize hex and binary numbers, the '$' and '%' notation is for gforth
syn match forthInteger '\<\$\x*\x\+\>' " *1* --- dont't mess
syn match forthInteger '\<\x*\d\x*\>' " *2* --- this order!
syn match forthInteger '\<%[0-1]*[0-1]\+\>'
-syn match forthFloat '\<-\=\d*[.]\=\d\+[Ee]\d\+\>'
+syn match forthFloat '\<-\=\d*[.]\=\d\+[DdEe]\d\+\>'
+syn match forthFloat '\<-\=\d*[.]\=\d\+[DdEe][-+]\d\+\>'
+
+" XXX If you find this overkill you can remove it. this has to come after the
+" highlighting for numbers otherwise it has no effect.
+syn region forthComment start='0 \[if\]' end='\[endif\]' end='\[then\]' contains=forthTodo
" Strings
syn region forthString start=+\.*\"+ end=+"+ end=+$+
@@ -212,9 +263,15 @@ syn region forthComment start='/\*' end='\*/' contains=forthTodo,forthSpaceError
" Include files
syn match forthInclude '^INCLUDE\s\+\k\+'
+syn match forthInclude '^require\s\+\k\+'
syn match forthInclude '^fload\s\+'
syn match forthInclude '^needs\s\+'
+" Locals definitions
+syn region forthLocals start='{\s' start='{$' end='\s}' end='^}'
+syn match forthLocals '{ }' " otherwise, at least two spaces between
+syn region forthDeprecated start='locals|' end='|'
+
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
@@ -257,6 +314,11 @@ if version >= 508 || !exists("did_forth_syn_inits")
HiLink forthObjectDef Define
HiLink forthEndOfObjectDef Define
HiLink forthInclude Include
+ HiLink forthLocals Type " nothing else uses type and locals must stand out
+ HiLink forthDeprecated Error " if you must, change to Type
+ HiLink forthFileMode Function
+ HiLink forthFileWords Statement
+ HiLink forthBlocks Statement
HiLink forthSpaceError Error
delcommand HiLink