7
|
1 " Vim syntax file
|
|
2 " Language: PCCTS
|
26
|
3 " Maintainer: Scott Bigham <dsb@killerbunnies.org>
|
7
|
4 " Last Change: 10 Aug 1999
|
|
5
|
|
6 " For version 5.x: Clear all syntax items
|
|
7 " For version 6.x: Quit when a syntax file was already loaded
|
|
8 if version < 600
|
|
9 syntax clear
|
|
10 elseif exists("b:current_syntax")
|
|
11 finish
|
|
12 endif
|
|
13
|
|
14 " Read the C++ syntax to start with
|
|
15 if version < 600
|
|
16 syn include @cppTopLevel <sfile>:p:h/cpp.vim
|
|
17 else
|
|
18 syn include @cppTopLevel syntax/cpp.vim
|
|
19 endif
|
|
20
|
|
21 syn region pcctsAction matchgroup=pcctsDelim start="<<" end=">>?\=" contains=@cppTopLevel,pcctsRuleRef
|
|
22
|
|
23 syn region pcctsArgBlock matchgroup=pcctsDelim start="\(>\s*\)\=\[" end="\]" contains=@cppTopLevel,pcctsRuleRef
|
|
24
|
|
25 syn region pcctsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pcctsSpecialChar
|
|
26 syn match pcctsSpecialChar "\\\\\|\\\"" contained
|
|
27
|
|
28 syn region pcctsComment start="/\*" end="\*/" contains=cTodo
|
|
29 syn match pcctsComment "//.*$" contains=cTodo
|
|
30
|
|
31 syn region pcctsDirective start="^\s*#header\s\+<<" end=">>" contains=pcctsAction keepend
|
|
32 syn match pcctsDirective "^\s*#parser\>.*$" contains=pcctsString,pcctsComment
|
|
33 syn match pcctsDirective "^\s*#tokdefs\>.*$" contains=pcctsString,pcctsComment
|
|
34 syn match pcctsDirective "^\s*#token\>.*$" contains=pcctsString,pcctsAction,pcctsTokenName,pcctsComment
|
|
35 syn region pcctsDirective start="^\s*#tokclass\s\+[A-Z]\i*\s\+{" end="}" contains=pcctsString,pcctsTokenName
|
|
36 syn match pcctsDirective "^\s*#lexclass\>.*$" contains=pcctsTokenName
|
|
37 syn region pcctsDirective start="^\s*#errclass\s\+[^{]\+\s\+{" end="}" contains=pcctsString,pcctsTokenName
|
|
38 syn match pcctsDirective "^\s*#pred\>.*$" contains=pcctsTokenName,pcctsAction
|
|
39
|
|
40 syn cluster pcctsInRule contains=pcctsString,pcctsRuleName,pcctsTokenName,pcctsAction,pcctsArgBlock,pcctsSubRule,pcctsLabel,pcctsComment
|
|
41
|
|
42 syn region pcctsRule start="\<[a-z][A-Za-z0-9_]*\>\(\s*\[[^]]*\]\)\=\(\s*>\s*\[[^]]*\]\)\=\s*:" end=";" contains=@pcctsInRule
|
|
43
|
|
44 syn region pcctsSubRule matchgroup=pcctsDelim start="(" end=")\(+\|\*\|?\(\s*=>\)\=\)\=" contains=@pcctsInRule contained
|
|
45 syn region pcctsSubRule matchgroup=pcctsDelim start="{" end="}" contains=@pcctsInRule contained
|
|
46
|
|
47 syn match pcctsRuleName "\<[a-z]\i*\>" contained
|
|
48 syn match pcctsTokenName "\<[A-Z]\i*\>" contained
|
|
49
|
|
50 syn match pcctsLabel "\<\I\i*:\I\i*" contained contains=pcctsLabelHack,pcctsRuleName,pcctsTokenName
|
|
51 syn match pcctsLabel "\<\I\i*:\"\([^\\]\|\\.\)*\"" contained contains=pcctsLabelHack,pcctsString
|
|
52 syn match pcctsLabelHack "\<\I\i*:" contained
|
|
53
|
|
54 syn match pcctsRuleRef "\$\I\i*\>" contained
|
|
55 syn match pcctsRuleRef "\$\d\+\(\.\d\+\)\>" contained
|
|
56
|
|
57 syn keyword pcctsClass class nextgroup=pcctsClassName skipwhite
|
|
58 syn match pcctsClassName "\<\I\i*\>" contained nextgroup=pcctsClassBlock skipwhite skipnl
|
|
59 syn region pcctsClassBlock start="{" end="}" contained contains=pcctsRule,pcctsComment,pcctsDirective,pcctsAction,pcctsException,pcctsExceptionHandler
|
|
60
|
|
61 syn keyword pcctsException exception nextgroup=pcctsExceptionRuleRef skipwhite
|
|
62 syn match pcctsExceptionRuleRef "\[\I\i*\]" contained contains=pcctsExceptionID
|
|
63 syn match pcctsExceptionID "\I\i*" contained
|
|
64 syn keyword pcctsExceptionHandler catch default
|
|
65 syn keyword pcctsExceptionHandler NoViableAlt NoSemViableAlt
|
|
66 syn keyword pcctsExceptionHandler MismatchedToken
|
|
67
|
|
68 syn sync clear
|
|
69 syn sync match pcctsSyncAction grouphere pcctsAction "<<"
|
|
70 syn sync match pcctsSyncAction "<<\([^>]\|>[^>]\)*>>"
|
|
71 syn sync match pcctsSyncRule grouphere pcctsRule "\<[a-z][A-Za-z0-9_]*\>\s*\[[^]]*\]\s*:"
|
|
72 syn sync match pcctsSyncRule grouphere pcctsRule "\<[a-z][A-Za-z0-9_]*\>\(\s*\[[^]]*\]\)\=\s*>\s*\[[^]]*\]\s*:"
|
|
73
|
|
74 " Define the default highlighting.
|
|
75 " For version 5.7 and earlier: only when not done already
|
|
76 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
77 if version >= 508 || !exists("did_pccts_syntax_inits")
|
|
78 if version < 508
|
|
79 let did_pccts_syntax_inits = 1
|
|
80 command -nargs=+ HiLink hi link <args>
|
|
81 else
|
|
82 command -nargs=+ HiLink hi def link <args>
|
|
83 endif
|
|
84
|
|
85 HiLink pcctsDelim Special
|
|
86 HiLink pcctsTokenName Identifier
|
|
87 HiLink pcctsRuleName Statement
|
|
88 HiLink pcctsLabelHack Label
|
|
89 HiLink pcctsDirective PreProc
|
|
90 HiLink pcctsString String
|
|
91 HiLink pcctsComment Comment
|
|
92 HiLink pcctsClass Statement
|
|
93 HiLink pcctsClassName Identifier
|
|
94 HiLink pcctsException Statement
|
|
95 HiLink pcctsExceptionHandler Keyword
|
|
96 HiLink pcctsExceptionRuleRef pcctsDelim
|
|
97 HiLink pcctsExceptionID Identifier
|
|
98 HiLink pcctsRuleRef Identifier
|
|
99 HiLink pcctsSpecialChar SpecialChar
|
|
100
|
|
101 delcommand HiLink
|
|
102 endif
|
|
103
|
|
104 let b:current_syntax = "pccts"
|
|
105
|
|
106 " vim: ts=8
|