aboutsummaryrefslogtreecommitdiff
path: root/stow/vim/.vim/ftplugin/antlr/antlr4.vim
blob: 456076c4f6d2c6c0b9f4cac98b7357e4735122fc (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
" vim: ts=8
" Vim syntax file
" Language:     ANTLRv4
" Maintainer:   J�rn Horstmann (updated by Dylon Edwards)
" Last Change:  2015-12-15

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

syn keyword antlrKeyword import fragment lexer parser grammar returns locals throws catch finally mode options tokens header members init after channels mode protected public private

syn keyword antlrReserved rule

syn match  antlrCharacter '\\\(r\|n\|t\|f\|b\|"\|\'\|\\\|u\x\{4}\)' contained display

syn match antlrToken "\<[A-Z_][a-zA-Z_0-9]\+\>"
syn match antlrRule "[a-z][a-zA-Z_0-9]\+"
syn match antlrScopeVariable '$\k\+::\k\+'

syn match antlrOperator "[:;@.]"
syn match antlrOperator "[()]"
syn match antlrOperator "[?+*~|!]"
syn match antlrOperator "[->=^]"

syn match antlrBlock "[{}]"
syn region antlrAction matchgroup=antlrBlock start="{" end="}" contains=antlrVariable,antlrAction
syn match antlrVariable contained "$[a-zA-Z][a-zA-Z_0-9]*"

syn include @JAVA syntax/java.vim
syn region ANTLR4EmbeddedJavaAction matchgroup=antlrBlock start="{" end="}" contains=@JAVA,antlrVariable containedin=antlrAction

syn keyword antlrOperations pushMode popMode skip channel

syn match antlrBrace "[\[\]]"
syn region antlrCharClass matchgroup=antlrBrace start="\[" end="\]" contains=antlrCharacter

syn region antlrLiteral start=+'+ end=+'+ contains=antlrCharacter
syn region antlrLiteral start=+"+ end=+"+ contains=antlrCharacter

syn region antlrComment start="/\*" end="\*/"
syn match  antlrComment "//.*$"

" 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
if version >= 508
  if version < 508
    let did_antlr_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  HiLink antlrReserved          Error
  HiLink antlrOperations        Identifier
  HiLink antlrLiteral           String
  hi def antlrVariable		term=bold cterm=bold gui=bold
  HiLink antlrBrace		Operator
  HiLink antlrBlock		Operator
  HiLink antlrCharacter         Special
  HiLink antlrComment           Comment
  HiLink antlrOperator          Operator
  HiLink antlrKeyword           Keyword
  HiLink antlrToken             PreProc
  HiLink antlrScopeVariable     Identifier
  HiLink antlrRule		Type

  delcommand HiLink
endif

let b:current_syntax = "antlr4"