2 " Language: JavaCC, a Java Compiler Compiler written by JavaSoft
3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
4 " URL: http://www.fleiner.com/vim/syntax/javacc.vim
5 " Last Change: 2012 Oct 05
7 " Uses java.vim, and adds a few special things for JavaCC Parser files.
8 " Those files usually have the extension *.jj
10 " For version 5.x: Clear all syntax items
11 " For version 6.x: Quit when a syntax file was already loaded
14 elseif exists("b:current_syntax")
21 " source the java.vim file
23 source <sfile>:p:h/java.vim
25 runtime! syntax/java.vim
27 unlet b:current_syntax
29 "remove catching errors caused by wrong parenthesis (does not work in javacc
30 "files) (first define them in case they have not been defined in java)
31 syn match javaParen "--"
32 syn match javaParenError "--"
33 syn match javaInParen "--"
34 syn match javaError2 "--"
36 syn clear javaParenError
40 " remove function definitions (they look different) (first define in
41 " in case it was not defined in java.vim)
42 "syn match javaFuncDef "--"
44 syn match javaFuncDef "[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)[ \t]*:" contains=javaType
46 syn keyword javaccPackages options DEBUG_PARSER DEBUG_LOOKAHEAD DEBUG_TOKEN_MANAGER
47 syn keyword javaccPackages COMMON_TOKEN_ACTION IGNORE_CASE CHOICE_AMBIGUITY_CHECK
48 syn keyword javaccPackages OTHER_AMBIGUITY_CHECK STATIC LOOKAHEAD ERROR_REPORTING
49 syn keyword javaccPackages USER_TOKEN_MANAGER USER_CHAR_STREAM JAVA_UNICODE_ESCAPE
50 syn keyword javaccPackages UNICODE_INPUT JDK_VERSION
51 syn match javaccPackages "PARSER_END([^)]*)"
52 syn match javaccPackages "PARSER_BEGIN([^)]*)"
53 syn match javaccSpecToken "<EOF>"
54 " the dot is necessary as otherwise it will be matched as a keyword.
55 syn match javaccSpecToken ".LOOKAHEAD("ms=s+1,me=e-1
56 syn match javaccToken "<[^> \t]*>"
57 syn keyword javaccActionToken TOKEN SKIP MORE SPECIAL_TOKEN
58 syn keyword javaccError DEBUG IGNORE_IN_BNF
60 " Define the default highlighting.
61 " For version 5.7 and earlier: only when not done already
62 " For version 5.8 and later: only when an item doesn't have highlighting yet
63 if version >= 508 || !exists("did_css_syn_inits")
65 let did_css_syn_inits = 1
66 command -nargs=+ HiLink hi link <args>
68 command -nargs=+ HiLink hi def link <args>
70 HiLink javaccSpecToken Statement
71 HiLink javaccActionToken Type
72 HiLink javaccPackages javaScopeDecl
73 HiLink javaccToken String
74 HiLink javaccError Error
78 let b:current_syntax = "javacc"