blob: 5ddc570bbec881112cb1d5a43ae3bf04b5bc4fb7 [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
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02006" quit when a syntax file was already loaded
7if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +00008 finish
9endif
10
11" Read the C++ syntax to start with
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020012syn include @cppTopLevel syntax/cpp.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000013
14syn region pcctsAction matchgroup=pcctsDelim start="<<" end=">>?\=" contains=@cppTopLevel,pcctsRuleRef
15
16syn region pcctsArgBlock matchgroup=pcctsDelim start="\(>\s*\)\=\[" end="\]" contains=@cppTopLevel,pcctsRuleRef
17
18syn region pcctsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pcctsSpecialChar
19syn match pcctsSpecialChar "\\\\\|\\\"" contained
20
21syn region pcctsComment start="/\*" end="\*/" contains=cTodo
22syn match pcctsComment "//.*$" contains=cTodo
23
24syn region pcctsDirective start="^\s*#header\s\+<<" end=">>" contains=pcctsAction keepend
25syn match pcctsDirective "^\s*#parser\>.*$" contains=pcctsString,pcctsComment
26syn match pcctsDirective "^\s*#tokdefs\>.*$" contains=pcctsString,pcctsComment
27syn match pcctsDirective "^\s*#token\>.*$" contains=pcctsString,pcctsAction,pcctsTokenName,pcctsComment
28syn region pcctsDirective start="^\s*#tokclass\s\+[A-Z]\i*\s\+{" end="}" contains=pcctsString,pcctsTokenName
29syn match pcctsDirective "^\s*#lexclass\>.*$" contains=pcctsTokenName
30syn region pcctsDirective start="^\s*#errclass\s\+[^{]\+\s\+{" end="}" contains=pcctsString,pcctsTokenName
31syn match pcctsDirective "^\s*#pred\>.*$" contains=pcctsTokenName,pcctsAction
32
33syn cluster pcctsInRule contains=pcctsString,pcctsRuleName,pcctsTokenName,pcctsAction,pcctsArgBlock,pcctsSubRule,pcctsLabel,pcctsComment
34
35syn region pcctsRule start="\<[a-z][A-Za-z0-9_]*\>\(\s*\[[^]]*\]\)\=\(\s*>\s*\[[^]]*\]\)\=\s*:" end=";" contains=@pcctsInRule
36
37syn region pcctsSubRule matchgroup=pcctsDelim start="(" end=")\(+\|\*\|?\(\s*=>\)\=\)\=" contains=@pcctsInRule contained
38syn region pcctsSubRule matchgroup=pcctsDelim start="{" end="}" contains=@pcctsInRule contained
39
40syn match pcctsRuleName "\<[a-z]\i*\>" contained
41syn match pcctsTokenName "\<[A-Z]\i*\>" contained
42
43syn match pcctsLabel "\<\I\i*:\I\i*" contained contains=pcctsLabelHack,pcctsRuleName,pcctsTokenName
44syn match pcctsLabel "\<\I\i*:\"\([^\\]\|\\.\)*\"" contained contains=pcctsLabelHack,pcctsString
45syn match pcctsLabelHack "\<\I\i*:" contained
46
47syn match pcctsRuleRef "\$\I\i*\>" contained
48syn match pcctsRuleRef "\$\d\+\(\.\d\+\)\>" contained
49
50syn keyword pcctsClass class nextgroup=pcctsClassName skipwhite
51syn match pcctsClassName "\<\I\i*\>" contained nextgroup=pcctsClassBlock skipwhite skipnl
52syn region pcctsClassBlock start="{" end="}" contained contains=pcctsRule,pcctsComment,pcctsDirective,pcctsAction,pcctsException,pcctsExceptionHandler
53
54syn keyword pcctsException exception nextgroup=pcctsExceptionRuleRef skipwhite
55syn match pcctsExceptionRuleRef "\[\I\i*\]" contained contains=pcctsExceptionID
56syn match pcctsExceptionID "\I\i*" contained
57syn keyword pcctsExceptionHandler catch default
58syn keyword pcctsExceptionHandler NoViableAlt NoSemViableAlt
59syn keyword pcctsExceptionHandler MismatchedToken
60
61syn sync clear
62syn sync match pcctsSyncAction grouphere pcctsAction "<<"
63syn sync match pcctsSyncAction "<<\([^>]\|>[^>]\)*>>"
64syn sync match pcctsSyncRule grouphere pcctsRule "\<[a-z][A-Za-z0-9_]*\>\s*\[[^]]*\]\s*:"
65syn sync match pcctsSyncRule grouphere pcctsRule "\<[a-z][A-Za-z0-9_]*\>\(\s*\[[^]]*\]\)\=\s*>\s*\[[^]]*\]\s*:"
66
67" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020068" Only when an item doesn't have highlighting yet
69command -nargs=+ HiLink hi def link <args>
Bram Moolenaar071d4272004-06-13 20:20:40 +000070
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020071HiLink pcctsDelim Special
72HiLink pcctsTokenName Identifier
73HiLink pcctsRuleName Statement
74HiLink pcctsLabelHack Label
75HiLink pcctsDirective PreProc
76HiLink pcctsString String
77HiLink pcctsComment Comment
78HiLink pcctsClass Statement
79HiLink pcctsClassName Identifier
80HiLink pcctsException Statement
81HiLink pcctsExceptionHandler Keyword
82HiLink pcctsExceptionRuleRef pcctsDelim
83HiLink pcctsExceptionID Identifier
84HiLink pcctsRuleRef Identifier
85HiLink pcctsSpecialChar SpecialChar
Bram Moolenaar071d4272004-06-13 20:20:40 +000086
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020087delcommand HiLink
Bram Moolenaar071d4272004-06-13 20:20:40 +000088
89let b:current_syntax = "pccts"
90
91" vim: ts=8