blob: 6ba9366a412077e070688d6e70e2a31c7c75a74a [file] [log] [blame]
Bram Moolenaarbaca7f72013-09-22 14:42:24 +02001" Vim syntax file
2" Language: J
3" Maintainer: David Bürgin <676c7473@gmail.com>
4" Last Change: 2013-09-21
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\..*$/
37
38hi def link jControl Statement
39hi def link jString String
40hi def link jNumber Number
41hi def link jComment Comment
42
43let b:current_syntax = "j"