1" Vim syntax file 2" Language: J 3" Maintainer: David Bürgin <[email protected]> 4" URL: https://github.com/glts/vim-j 5" Last Change: 2014-03-17 6 7if exists('b:current_syntax') 8 finish 9endif 10 11syntax case match 12syntax sync minlines=50 13 14syntax match jControl /\<\%(assert\|break\|case\|catch[dt]\=\|continue\|do\|else\%(if\)\=\|end\|fcase\|for\|if\|return\|select\|throw\|try\|whil\%(e\|st\)\)\./ 15syntax match jControl /\<\%(for\|goto\|label\)_\a\k*\./ 16 17" Standard library names defined in the z locale. A few verbs need to be 18" defined with ":syntax match" because they would otherwise take precedence 19" over the corresponding jControl items. 20syntax keyword jNoun ARGV BINPATH CR CRLF DEL Debug EAV EMPTY FF FHS IF64 IFIOS IFJCDROID IFJHS IFQT IFRASPI IFUNIX IFWIN IFWINCE IFWINE IFWOW64 JB01 JBOXED JCHAR JCMPX JFL JINT JPTR JSIZES JSTR JTYPES JVERSION LF LF2 TAB UNAME UNXLIB adverb andurl conjunction dbhelp dyad libjqt monad noun verb 21syntax keyword jAdverb define each every fapplylines inv inverse items leaf rows table 22syntax keyword jConjunction bind cuts def on 23syntax keyword jVerb AND Endian IFDEF Note OR XOR alpha17 alpha27 anddf android_exec_host andunzip apply boxopen boxxopen bx calendar cd cdcb cder cderx cdf charsub chopstring clear coclass cocreate cocurrent codestroy coerase cofind cofindv cofullname coinfo coinsert coname conames conew conl conouns conounsx copath copathnl copathnlx coreset costate cut cutLF cutopen cutpara datatype dbctx dberm dberr dbg dbjmp dblocals dblxq dblxs dbnxt dbq dbr dbret dbrr dbrrx dbrun dbs dbsig dbsq dbss dbst dbstack dbstk dbstop dbstopme dbstopnext dbstops dbtrace dbview deb debc delstring detab dfh dir dircompare dircompares dirfind dirpath dirss dirssrplc dirtree dirused dlb dltb dltbs dquote drop dropafter dropto dtb dtbs echo empty endian erase evtloop exit expand f2utf8 fappend fappends fboxname fc fcopynew fdir ferase fetch fexist fexists fgets file2url fixdotdot fliprgb fmakex foldpara foldtext fpathcreate fpathname fputs fread freadblock freadr freads frename freplace fsize fss fssrplc fstamp fstringreplace ftype fview fwrite fwritenew fwrites getargs getdate getenv getqtbin hfd hostpathsep ic install iospath isatty isotimestamp isutf8 jcwdpath joinstring jpathsep jsystemdefs list ljust load loadd mema memf memr memw nameclass namelist names nc nl pick quote require rjust rplc script scriptd setbreak show sign sminfo smoutput sort split splitnostring splitstring ss startupandroid startupconsole startupide stderr stdin stdout stringreplace symdat symget symset take takeafter taketo timespacex timestamp timex tmoutput toCRLF toHOST toJ todate todayno tolower topara toupper tsdiff tsrep tstamp type ucp ucpcount unxlib usleep utf8 uucp valdate wcsize weekday weeknumber weeksinyear winpathsep 24syntax match jVerb /\<\%(assert\|break\|do\)\>\.\@!/ 25 26syntax region jString oneline start=/'/ skip=/''/ end=/'/ 27 28" Number patterns. Matching J numbers is difficult. The regular expression 29" used for the general case roughly embodies this grammar sketch: 30" 31" BASE := /_?\d+(\.\d*)?([eE]_?\d+)?/ 32" RATIONAL := BASE | BASE r BASE 33" COMPLEX := BASE | BASE (j|a[dr]) BASE 34" JNUMBER := RATIONAL | RATIONAL [px] RATIONAL | COMPLEX | COMPLEX [px] COMPLEX 35" 36" The grammar is implemented as shown in this pseudo-regexp: 37" 38" base rational complex remainder 39" /\< B ( [r]B ([px]B([r]B)?)? | (j|a[dr])B ([px]B((j|a[dr])B)?)? | [px]B ((j|a[dr]|r)B)? )?/ 40" 41" All in all, a compromise between correctness and practicality had to be 42" made. See http://www.jsoftware.com/help/dictionary/dcons.htm for reference. 43syntax match jNumber /\<_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%(\%(r_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%([px]_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%(r_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\)\=\)\=\)\|\%(\%(j\|a[dr]\)_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%([px]_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%(\%(j\|a[dr]\)_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\)\=\)\=\)\|\%([px]_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%(\%(j\|a[dr]\|r\)_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\)\=\)\)\=/ 44syntax match jNumber /\<_\=\d\+\%([eE]\d\+\)\=b_\=[0-9a-z]\+/ 45syntax match jNumber /\<__\=\>/ 46syntax match jNumber /\<_\=\d\+x\>/ 47 48syntax keyword jTodo TODO FIXME XXX contained 49syntax match jComment /NB\..*$/ contains=jTodo,@Spell 50syntax match jSharpBang /\%^#!.*$/ 51 52highlight default link jControl Statement 53highlight default link jNoun Identifier 54highlight default link jAdverb Identifier 55highlight default link jConjunction Identifier 56highlight default link jVerb Function 57highlight default link jString String 58highlight default link jNumber Number 59highlight default link jTodo Todo 60highlight default link jComment Comment 61highlight default link jSharpBang PreProc 62 63let b:current_syntax = 'j' 64