xref: /vim-8.2.3635/runtime/syntax/j.vim (revision d5d015d4)
1" Vim syntax file
2" Language:	J
3" Maintainer:	David Bürgin <[email protected]>
4" Last Change:	2013-10-06
5
6if exists("b:current_syntax")
7  finish
8endif
9
10syntax case match
11syntax sync minlines=50
12
13syn match jControl /\<\%(assert\|break\|case\|catch[dt]\=\|continue\|do\|else\%(if\)\=\|end\|fcase\|for\|if\|return\|select\|throw\|try\|whil\%(e\|st\)\)\./
14syn match jControl /\<\%(for\|goto\|label\)_\a\k*\./
15
16syn region jString oneline start=/'/ skip=/''/ end=/'/
17
18" Patterns for numbers in general, rational numbers, numbers with explicit
19" base, infinities, and numbers with extended precision.
20"
21" Matching J numbers is difficult. The regular expression used for the general
22" case roughly embodies this grammar sketch:
23"
24"         EXP     := /_?\d+(\.\d*)?([eE]_?\d+)?/
25"         COMP    := EXP  |  EXP (j|a[dr]) EXP
26"         PIEU    := COMP  |  COMP [px] COMP
27"
28" For the rest, a compromise between correctness and practicality was made.
29" See http://www.jsoftware.com/help/dictionary/dcons.htm for reference.
30syn match jNumber /\<_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%(\%(j\|a[dr]\)_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\)\=\%([px]_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\%(\%(j\|a[dr]\)_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=\)\=\)\=/
31syn match jNumber /\<_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=r_\=\d\+\%(\.\d*\)\=\%([eE]_\=\d\+\)\=/
32syn match jNumber /\<_\=\d\+\%([eE]\d\+\)\=b_\=[0-9a-z]\+/
33syn match jNumber /\<__\=\>/
34syn match jNumber /\<_\=\d\+x\>/
35
36syn match jComment /NB\..*$/ contains=jTodo,@Spell
37syn keyword jTodo TODO FIXME XXX contained
38
39hi def link jControl Statement
40hi def link jString String
41hi def link jNumber Number
42hi def link jComment Comment
43hi def link jTodo Todo
44
45let b:current_syntax = "j"
46