1 | " Vim syntax file
|
---|
2 | " Language: JFlex
|
---|
3 | " Maintainer: Gerwin Klein <[email protected]>
|
---|
4 | " Last Change: $Revision: 50 $, $Date: 2003-06-08 21:01:12 +1000 (Sun, 08 Jun 2003) $
|
---|
5 |
|
---|
6 | " Thanks to Michael Brailsford for help and suggestions
|
---|
7 |
|
---|
8 | " Quit when a syntax file was already loaded {{{
|
---|
9 | if exists("b:current_syntax")
|
---|
10 | finish
|
---|
11 | endif
|
---|
12 | "}}}
|
---|
13 |
|
---|
14 | " Include java syntax {{{
|
---|
15 | if version >= 600
|
---|
16 | runtime! syntax/java.vim
|
---|
17 | unlet b:current_syntax
|
---|
18 | else
|
---|
19 | so $VIMRUNTIME/syntax/java.vim
|
---|
20 | endif
|
---|
21 | "}}}
|
---|
22 |
|
---|
23 | syn cluster jflexOptions contains=jflexOption,jflexCodeInclude,jflexComment,jflexMacroIdent,jflexMacroRegExp,jflexOptionError
|
---|
24 | syn cluster jflexRules contains=jflexRule,jflexComment,jflexActionCode,jflexRuleStates,jflexRegExp
|
---|
25 |
|
---|
26 | " java code section
|
---|
27 | syn region jflexStart start="/\*\|//\|import\|package\|class"me=s end="^%%"me=e-2 contains=@javaTop nextgroup=jflexOptionReg
|
---|
28 |
|
---|
29 | " %%
|
---|
30 | " options
|
---|
31 | syn region jflexOptionReg matchgroup=jflexSectionSep start="^%%" end="^%%"me=e-2 contains=@jflexOptions nextgroup=jflexRulesReg
|
---|
32 |
|
---|
33 | syn match jflexOptionError "%\i*" contained
|
---|
34 |
|
---|
35 | syn match jflexOption "^\(%s\|%x\)" contained
|
---|
36 | syn match jflexOption "^%state" contained
|
---|
37 | syn match jflexOption "^%states" contained
|
---|
38 | syn match jflexOption "^%xstate" contained
|
---|
39 | syn match jflexOption "^%xstates" contained
|
---|
40 | syn match jflexOption "^%char" contained
|
---|
41 | syn match jflexOption "^%line" contained
|
---|
42 | syn match jflexOption "^%column" contained
|
---|
43 | syn match jflexOption "^%byaccj" contained
|
---|
44 | syn match jflexOption "^%cup" contained
|
---|
45 | syn match jflexOption "^%cupsym" contained
|
---|
46 | syn match jflexOption "^%cupdebug" contained
|
---|
47 | syn match jflexOption "^%eofclose" contained
|
---|
48 | syn match jflexOption "^%class" contained
|
---|
49 | syn match jflexOption "^%function" contained
|
---|
50 | syn match jflexOption "^%type" contained
|
---|
51 | syn match jflexOption "^%integer" contained
|
---|
52 | syn match jflexOption "^%int" contained
|
---|
53 | syn match jflexOption "^%intwrap" contained
|
---|
54 | syn match jflexOption "^%yyeof" contained
|
---|
55 | syn match jflexOption "^%notunix" contained
|
---|
56 | syn match jflexOption "^%7bit" contained
|
---|
57 | syn match jflexOption "^%8bit" contained
|
---|
58 | syn match jflexOption "^%full" contained
|
---|
59 | syn match jflexOption "^%16bit" contained
|
---|
60 | syn match jflexOption "^%unicode" contained
|
---|
61 | syn match jflexOption "^%caseless" contained
|
---|
62 | syn match jflexOption "^%ignorecase" contained
|
---|
63 | syn match jflexOption "^%implements" contained
|
---|
64 | syn match jflexOption "^%extends" contained
|
---|
65 | syn match jflexOption "^%public" contained
|
---|
66 | syn match jflexOption "^%apiprivate" contained
|
---|
67 | syn match jflexOption "^%final" contained
|
---|
68 | syn match jflexOption "^%abstract" contained
|
---|
69 | syn match jflexOption "^%debug" contained
|
---|
70 | syn match jflexOption "^%standalone" contained
|
---|
71 | syn match jflexOption "^%switch" contained
|
---|
72 | syn match jflexOption "^%table" contained
|
---|
73 | syn match jflexOption "^%pack" contained
|
---|
74 | syn match jflexOption "^%include" contained
|
---|
75 | syn match jflexOption "^%buffer" contained
|
---|
76 | syn match jflexOption "^%initthrow" contained
|
---|
77 | syn match jflexOption "^%eofthrow" contained
|
---|
78 | syn match jflexOption "^%yylexthrow" contained
|
---|
79 | syn match jflexOption "^%throws" contained
|
---|
80 | syn match jflexOption "^%scannerror" contained
|
---|
81 |
|
---|
82 | syn match jflexMacroIdent "\I\i*\s*="me=e-1 contained nextgroup=jflexMacroRegExp
|
---|
83 |
|
---|
84 | syn region jflexMacroRegExp matchgroup=jflexOperator start="=" end="^\(%\|\I\|\i\|/\)"me=e-1 contains=NONE contained
|
---|
85 |
|
---|
86 | syn region jflexCodeInclude matchgroup=jflexCodeIncludeMark start="^%{" end="^%}" contains=@javaTop contained
|
---|
87 | syn region jflexCodeInclude matchgroup=jflexCodeIncludeMark start="^%init{" end="^%init}" contains=@javaTop contained
|
---|
88 | syn region jflexCodeInclude matchgroup=jflexCodeIncludeMark start="^%initthrow{" end="^%initthrow}" contains=@javaTop contained
|
---|
89 | syn region jflexCodeInclude matchgroup=jflexCodeIncludeMark start="^%eof{" end="^%eof}" contains=@javaTop contained
|
---|
90 | syn region jflexCodeInclude matchgroup=jflexCodeIncludeMark start="^%eofthrow{" end="^%eofthrow}" contains=@javaTop contained
|
---|
91 | syn region jflexCodeInclude matchgroup=jflexCodeIncludeMark start="^%yylexthrow{" end="^%yylexthrow}" contains=@javaTop contained
|
---|
92 | syn region jflexCodeInclude matchgroup=jflexCodeIncludeMark start="^%eofval{" end="^%eofval}" contains=@javaTop contained
|
---|
93 |
|
---|
94 | " rules (end pattern shouldn't occur, if it does anyway we just stay in jflexRulesReg)
|
---|
95 | syn region jflexRulesReg matchgroup=jflexSectionSep start="^%%" end="^%%"me=e-2 contains=@jflexRules
|
---|
96 |
|
---|
97 | " at first everything but strings is a regexp
|
---|
98 | syn match jflexRegExp "\([^\" \t]\|\\\"\)\+" contained
|
---|
99 |
|
---|
100 | " take out comments
|
---|
101 | syn match jflexComment "//.*" contained
|
---|
102 | syn region jflexComment start="/\*" end="\*/" contained contains=jflexComment
|
---|
103 |
|
---|
104 | " lex states
|
---|
105 | syn match jflexRuleStates "<\s*\I\i*\(\s*,\s*\I\i*\)*\s*>" contained skipnl skipwhite nextgroup=jflexStateGroup
|
---|
106 |
|
---|
107 | " action code (only after states braces and macro use)
|
---|
108 | syn region jflexActionCode matchgroup=Delimiter start="{" end="}" contained contains=@javaTop,jflexJavaBraces
|
---|
109 |
|
---|
110 | " macro use
|
---|
111 | syn match jflexRegExp "{\s*\I\i*\s*}" contained
|
---|
112 |
|
---|
113 | " state braces (only active after <state>)
|
---|
114 | syn region jflexStateGroup matchgroup=jflexRuleStates start="{$" start="{\s" end="}" contained contains=@jflexRules
|
---|
115 |
|
---|
116 | " string
|
---|
117 | syn region jflexRegExp matchgroup=String start=+"+ skip=+\\\\\|\\"+ end=+"+ contained
|
---|
118 |
|
---|
119 | " not to be confused with a state
|
---|
120 | syn match jflexRegExp "<<EOF>>" contained
|
---|
121 |
|
---|
122 | " escape sequence
|
---|
123 | syn match jflexRegExp "\\." contained
|
---|
124 |
|
---|
125 |
|
---|
126 | " keep braces in actions balanced
|
---|
127 | syn region jflexJavaBraces start="{" end="}" contained contains=@javaTop,jflexJavaBraces
|
---|
128 |
|
---|
129 |
|
---|
130 | " syncing
|
---|
131 | syn sync clear
|
---|
132 | syn sync minlines=10
|
---|
133 | syn sync match jflexSync grouphere jflexOptionReg "^%[a-z]"
|
---|
134 | syn sync match jflexSync grouphere jflexRulesReg "^<"
|
---|
135 |
|
---|
136 |
|
---|
137 | " highlighting
|
---|
138 | hi link jflexOption Special
|
---|
139 | hi link jflexMacroIdent Ident
|
---|
140 | hi link jflexMacroRegExp Macro
|
---|
141 | hi link jflexOptionError Error
|
---|
142 | hi link jflexComment Comment
|
---|
143 | hi link jflexOperator Operator
|
---|
144 | hi link jflexRuleStates Special
|
---|
145 | hi link jflexRegExp Function
|
---|
146 | hi jflexSectionSep guifg=yellow ctermfg=yellow guibg=blue ctermbg=blue gui=bold cterm=bold
|
---|
147 | hi link jflexCodeIncludeMark jflexSectionSep
|
---|
148 |
|
---|
149 | let b:current_syntax="jflex"
|
---|