summaryrefslogtreecommitdiff
path: root/private_dot_config/nvim/after/syntax/antlr4.vim
blob: 8f6c412045a0f6c06e647a5efa5100d77031bf3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
if exists('b:current_syntax')
    finish
endif

command -nargs=* HiLink highlight link <args>

syntax match antlr4EventId      +[a-zA-Z_][a-zA-Z0-9_]*+ contained
syntax match antlr4ParName      +\<[a-z][a-zA-Z0-9_]*\>+ containedin=antlr4RHS
syntax match antlr4LexName      +\<[A-Z][a-zA-Z0-9_]*\>+ containedin=antlr4RHS
syntax match antlr4Assign       /[a-zA-Z]\++\?=/         containedin=antlr4RHS

if exists('g:antlr4_highlight_punctuation')
    syntax match antlr4Punctuation     +[\-():;]+
endif

syntax include @included syntax/java.vim

syntax region antlr4RHS     start=+:+   end=+;+ extend

syntax region antlr4Embed   start=+{+   end=+}?\?+ contains=@included,antlr4Variable keepend
    \ containedin=antlr4RHS
syntax region antlr4Embed   start=+\[+  end=+\]+   contains=@included,antlr4Variable keepend


syntax match antlr4Repeat       +[+*]+      containedin=antlr4RHS
syntax match antlr4Condition    +?+         containedin=antlr4RHS
syntax match antlr4Option       "|"         containedin=antlr4RHS

" Use specifically containedin=javaParenT so it will be highlighted inside
" parens
syntax match antlr4Variable  contained   +\$[a-zA-Z_][a-zA-Z0-9_]*+ containedin=javaParenT

syntax match antlr4Keyword      /@\(\(parser\|lexer\)::\)\?\(header\|members\)/
syntax match antlr4Keyword      /@after/

syntax match antlr4Escape       +\\[nrvt]+
syntax match antlr4Escape       +\\u[0-9a-fA-F]\{4}+
syntax match antlr4Escape       +\\u{[0-9a-fA-F]\{4}}+
syntax match antlr4Escape       +\\p{.\{-}}+

syntax match antlr4SetEscape    +\\-+       containedin=antlr4RHS

syntax keyword antlr4Keyword grammar
syntax keyword antlr4Keyword lexer parser options
syntax keyword antlr4Keyword fragment tokens
syntax keyword antlr4Keyword returns locals throws catch finally mode options

syntax keyword antlr4Import import

syntax keyword antlr4Operation skip more popMode mode pushMode type channel
    \ containedin=antlr4RHS

syntax region antlr4Set     start=+\[+  end=+\]+ contained
    \ contains=antlr4Escape,antlr4SetEscape containedin=antlr4RHS
syntax region antlr4Attr    start="<"   end=">"
    \ containedin=antlr4RHS
syntax region antlr4String  start=+'+   end=+'+ containedin=antlr4RHS contains=antlr4Escape

syntax region antlr4Comment start=+/\*+ end=+\*/+
    \ containedin=antlr4RHS
syntax region antlr4Comment start=+//+  end=+$+
    \ containedin=antlr4RHS

syntax region antlr4Event   start=+#+   end=+$+
    \ containedin=antlr4RHS contains=antlr4EventId

HiLink antlr4Comment        Comment
HiLink antlr4Keyword        KeyWord
HiLink antlr4ParName        Type
HiLink antlr4LexName        Macro
HiLink antlr4Attr           Special
HiLink antlr4Assign         Statement
HiLink antlr4Set            Character
HiLink antlr4String         String

if exists('g:antlr4_highlight_punctuation')
    HiLink antlr4Punctuation    Operator
endif

HiLink antlr4Repeat         Repeat
HiLink antlr4Condition      Conditional
HiLink antlr4Option         Delimiter
HiLink antlr4Import         PreProc
HiLink antlr4Escape         Special
HiLink antlr4SetEscape      antlr4Escape
HiLink antlr4Operation      Function
HiLink antlr4EventId        Function
HiLink antlr4Annotation     KeyWord
HiLink antlr4Variable       Special

delcommand HiLink

let b:current_syntax = 'antlr4'