blob: 8341f5bd432124abf5f720e0bc28b1723774d6bb [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: PCCTS
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +00003" Maintainer: Scott Bigham <dsb@killerbunnies.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00004" 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
8if version < 600
9 syntax clear
10elseif exists("b:current_syntax")
11 finish
12endif
13
14" Read the C++ syntax to start with
15if version < 600
16 syn include @cppTopLevel <sfile>:p:h/cpp.vim
17else
18 syn include @cppTopLevel syntax/cpp.vim
19endif
20
21syn region pcctsAction matchgroup=pcctsDelim start="<<" end=">>?\=" contains=@cppTopLevel,pcctsRuleRef
22
23syn region pcctsArgBlock matchgroup=pcctsDelim start="\(>\s*\)\=\[" end="\]" contains=@cppTopLevel,pcctsRuleRef
24
25syn region pcctsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pcctsSpecialChar
26syn match pcctsSpecialChar "\\\\\|\\\"" contained
27
28syn region pcctsComment start="/\*" end="\*/" contains=cTodo
29syn match pcctsComment "//.*$" contains=cTodo
30
31syn region pcctsDirective start="^\s*#header\s\+<<" end=">>" contains=pcctsAction keepend
32syn match pcctsDirective "^\s*#parser\>.*$" contains=pcctsString,pcctsComment
33syn match pcctsDirective "^\s*#tokdefs\>.*$" contains=pcctsString,pcctsComment
34syn match pcctsDirective "^\s*#token\>.*$" contains=pcctsString,pcctsAction,pcctsTokenName,pcctsComment
35syn region pcctsDirective start="^\s*#tokclass\s\+[A-Z]\i*\s\+{" end="}" contains=pcctsString,pcctsTokenName
36syn match pcctsDirective "^\s*#lexclass\>.*$" contains=pcctsTokenName
37syn region pcctsDirective start="^\s*#errclass\s\+[^{]\+\s\+{" end="}" contains=pcctsString,pcctsTokenName
38syn match pcctsDirective "^\s*#pred\>.*$" contains=pcctsTokenName,pcctsAction
39
40syn cluster pcctsInRule contains=pcctsString,pcctsRuleName,pcctsTokenName,pcctsAction,pcctsArgBlock,pcctsSubRule,pcctsLabel,pcctsComment
41
42syn region pcctsRule start="\<[a-z][A-Za-z0-9_]*\>\(\s*\[[^]]*\]\)\=\(\s*>\s*\[[^]]*\]\)\=\s*:" end=";" contains=@pcctsInRule
43
44syn region pcctsSubRule matchgroup=pcctsDelim start="(" end=")\(+\|\*\|?\(\s*=>\)\=\)\=" contains=@pcctsInRule contained
45syn region pcctsSubRule matchgroup=pcctsDelim start="{" end="}" contains=@pcctsInRule contained
46
47syn match pcctsRuleName "\<[a-z]\i*\>" contained
48syn match pcctsTokenName "\<[A-Z]\i*\>" contained
49
50syn match pcctsLabel "\<\I\i*:\I\i*" contained contains=pcctsLabelHack,pcctsRuleName,pcctsTokenName
51syn match pcctsLabel "\<\I\i*:\"\([^\\]\|\\.\)*\"" contained contains=pcctsLabelHack,pcctsString
52syn match pcctsLabelHack "\<\I\i*:" contained
53
54syn match pcctsRuleRef "\$\I\i*\>" contained
55syn match pcctsRuleRef "\$\d\+\(\.\d\+\)\>" contained
56
57syn keyword pcctsClass class nextgroup=pcctsClassName skipwhite
58syn match pcctsClassName "\<\I\i*\>" contained nextgroup=pcctsClassBlock skipwhite skipnl
59syn region pcctsClassBlock start="{" end="}" contained contains=pcctsRule,pcctsComment,pcctsDirective,pcctsAction,pcctsException,pcctsExceptionHandler
60
61syn keyword pcctsException exception nextgroup=pcctsExceptionRuleRef skipwhite
62syn match pcctsExceptionRuleRef "\[\I\i*\]" contained contains=pcctsExceptionID
63syn match pcctsExceptionID "\I\i*" contained
64syn keyword pcctsExceptionHandler catch default
65syn keyword pcctsExceptionHandler NoViableAlt NoSemViableAlt
66syn keyword pcctsExceptionHandler MismatchedToken
67
68syn sync clear
69syn sync match pcctsSyncAction grouphere pcctsAction "<<"
70syn sync match pcctsSyncAction "<<\([^>]\|>[^>]\)*>>"
71syn sync match pcctsSyncRule grouphere pcctsRule "\<[a-z][A-Za-z0-9_]*\>\s*\[[^]]*\]\s*:"
72syn 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
77if 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
102endif
103
104let b:current_syntax = "pccts"
105
106" vim: ts=8