Mercurial > vim
annotate runtime/syntax/dtrace.vim @ 10315:c1cfdf43560c v8.0.0053
commit https://github.com/vim/vim/commit/60ef3e81f4a54d9f7ee617d57021f0811ec8ada5
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 29 14:37:56 2016 +0200
patch 8.0.0053
Problem: No test for what 8.0.0047 fixes.
Solution: Add a test. (Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 29 Oct 2016 14:45:04 +0200 |
parents | 43efa4f5a8ea |
children |
rev | line source |
---|---|
1621 | 1 " DTrace D script syntax file. To avoid confusion with the D programming |
2 " language, I call this script dtrace.vim instead of d.vim. | |
3 " Language: D script as described in "Solaris Dynamic Tracing Guide", | |
4 " http://docs.sun.com/app/docs/doc/817-6223 | |
5 " Version: 1.5 | |
6 " Last Change: 2008/04/05 | |
7 " Maintainer: Nicolas Weber <nicolasweber@gmx.de> | |
8 | |
9 " dtrace lexer and parser are at | |
10 " http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libdtrace/common/dt_lex.l | |
11 " http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libdtrace/common/dt_grammar.y | |
12 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
1621
diff
changeset
|
13 " quit when a syntax file was already loaded |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
1621
diff
changeset
|
14 if exists("b:current_syntax") |
1621 | 15 finish |
16 endif | |
17 | |
18 " Read the C syntax to start with | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
1621
diff
changeset
|
19 runtime! syntax/c.vim |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
1621
diff
changeset
|
20 unlet b:current_syntax |
1621 | 21 |
22 syn clear cCommentL " dtrace doesn't support // style comments | |
23 | |
24 " First line may start with #!, also make sure a '-s' flag is somewhere in | |
25 " that line. | |
26 syn match dtraceComment "\%^#!.*-s.*" | |
27 | |
28 " Probe descriptors need explicit matches, so that keywords in probe | |
29 " descriptors don't show up as errors. Note that this regex detects probes | |
30 " as "something with three ':' in it". This works in practice, but it's not | |
31 " really correct. Also add special case code for BEGIN, END and ERROR, since | |
32 " they are common. | |
33 " Be careful not to detect '/*some:::node*/\n/**/' as probe, as it's | |
34 " commented out. | |
35 " XXX: This allows a probe description to end with ',', even if it's not | |
36 " followed by another probe. | |
37 " XXX: This doesn't work if followed by a comment. | |
38 let s:oneProbe = '\%(BEGIN\|END\|ERROR\|\S\{-}:\S\{-}:\S\{-}:\S\{-}\)\_s*' | |
39 exec 'syn match dtraceProbe "'.s:oneProbe.'\%(,\_s*'.s:oneProbe.'\)*\ze\_s\%({\|\/[^*]\|\%$\)"' | |
40 | |
41 " Note: We have to be careful to not make this match /* */ comments. | |
42 " Also be careful not to eat `c = a / b; b = a / 2;`. We use the same | |
43 " technique as the dtrace lexer: a predicate has to be followed by {, ;, or | |
44 " EOF. Also note that dtrace doesn't allow an empty predicate // (we do). | |
45 " This regex doesn't allow a divison operator in the predicate. | |
46 " Make sure that this matches the empty predicate as well. | |
47 " XXX: This doesn't work if followed by a comment. | |
48 syn match dtracePredicate "/\*\@!\_[^/]*/\ze\_s*\%({\|;\|\%$\)" | |
49 "contains=ALLBUT,dtraceOption " this lets the region contain too much stuff | |
50 | |
51 " Pragmas. | |
52 " dtrace seems not to support whitespace before or after the '='. dtrace | |
53 " supports only one option per #pragma, and no continuations of #pragma over | |
54 " several lines with '\'. | |
55 " Note that dtrace treats units (Hz etc) as case-insenstive, we allow only | |
56 " sane unit capitalization in this script (ie 'ns', 'us', 'ms', 's' have to be | |
57 " small, Hertz can be 'Hz' or 'hz') | |
58 " XXX: "cpu" is always highlighted as builtin var, not as option | |
59 | |
60 " auto or manual: bufresize | |
61 syn match dtraceOption contained "bufresize=\%(auto\|manual\)\s*$" | |
62 | |
63 " scalar: cpu jstackframes jstackstrsize nspec stackframes stackindent ustackframes | |
64 syn match dtraceOption contained "\%(cpu\|jstackframes\|jstackstrsize\|nspec\|stackframes\|stackindent\|ustackframes\)=\d\+\s*$" | |
65 | |
66 " size: aggsize bufsize dynvarsize specsize strsize | |
67 " size defaults to something if no unit is given (ie., having no unit is ok) | |
68 syn match dtraceOption contained "\%(aggsize\|bufsize\|dynvarsize\|specsize\|strsize\)=\d\+\%(k\|m\|g\|t\|K\|M\|G\|T\)\=\s*$" | |
69 | |
70 " time: aggrate cleanrate statusrate switchrate | |
71 " time defaults to hz if no unit is given | |
72 syn match dtraceOption contained "\%(aggrate\|cleanrate\|statusrate\|switchrate\)=\d\+\%(hz\|Hz\|ns\|us\|ms\|s\)\=\s*$" | |
73 | |
74 " No type: defaultargs destructive flowindent grabanon quiet rawbytes | |
75 syn match dtraceOption contained "\%(defaultargs\|destructive\|flowindent\|grabanon\|quiet\|rawbytes\)\s*$" | |
76 | |
77 | |
78 " Turn reserved but unspecified keywords into errors | |
79 syn keyword dtraceReservedKeyword auto break case continue counter default do | |
80 syn keyword dtraceReservedKeyword else for goto if import probe provider | |
81 syn keyword dtraceReservedKeyword register restrict return static switch while | |
82 | |
83 " Add dtrace-specific stuff | |
84 syn keyword dtraceOperator sizeof offsetof stringof xlate | |
85 syn keyword dtraceStatement self inline xlate this translator | |
86 | |
87 " Builtin variables | |
88 syn keyword dtraceIdentifier arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 | |
89 syn keyword dtraceIdentifier args caller chip cpu curcpu curlwpsinfo curpsinfo | |
90 syn keyword dtraceIdentifier curthread cwd epid errno execname gid id ipl lgrp | |
91 syn keyword dtraceIdentifier pid ppid probefunc probemod probename probeprov | |
92 syn keyword dtraceIdentifier pset root stackdepth tid timestamp uid uregs | |
93 syn keyword dtraceIdentifier vtimestamp walltimestamp | |
94 syn keyword dtraceIdentifier ustackdepth | |
95 | |
96 " Macro Variables | |
97 syn match dtraceConstant "$[0-9]\+" | |
98 syn match dtraceConstant "$\(egid\|euid\|gid\|pgid\|ppid\)" | |
99 syn match dtraceConstant "$\(projid\|sid\|target\|taskid\|uid\)" | |
100 | |
101 " Data Recording Actions | |
102 syn keyword dtraceFunction trace tracemem printf printa stack ustack jstack | |
103 | |
104 " Process Destructive Actions | |
105 syn keyword dtraceFunction stop raise copyout copyoutstr system | |
106 | |
107 " Kernel Destructive Actions | |
108 syn keyword dtraceFunction breakpoint panic chill | |
109 | |
110 " Special Actions | |
111 syn keyword dtraceFunction speculate commit discard exit | |
112 | |
113 " Subroutines | |
114 syn keyword dtraceFunction alloca basename bcopy cleanpath copyin copyinstr | |
115 syn keyword dtraceFunction copyinto dirname msgdsize msgsize mutex_owned | |
116 syn keyword dtraceFunction mutex_owner mutex_type_adaptive progenyof | |
117 syn keyword dtraceFunction rand rw_iswriter rw_write_held speculation | |
118 syn keyword dtraceFunction strjoin strlen | |
119 | |
120 " Aggregating Functions | |
121 syn keyword dtraceAggregatingFunction count sum avg min max lquantize quantize | |
122 | |
123 syn keyword dtraceType int8_t int16_t int32_t int64_t intptr_t | |
124 syn keyword dtraceType uint8_t uint16_t uint32_t uint64_t uintptr_t | |
125 syn keyword dtraceType string | |
126 syn keyword dtraceType pid_t id_t | |
127 | |
128 | |
129 " Define the default highlighting. | |
130 " We use `hi def link` directly, this requires 5.8. | |
131 hi def link dtraceReservedKeyword Error | |
132 hi def link dtracePredicate String | |
133 hi def link dtraceProbe dtraceStatement | |
134 hi def link dtraceStatement Statement | |
135 hi def link dtraceConstant Constant | |
136 hi def link dtraceIdentifier Identifier | |
137 hi def link dtraceAggregatingFunction dtraceFunction | |
138 hi def link dtraceFunction Function | |
139 hi def link dtraceType Type | |
140 hi def link dtraceOperator Operator | |
141 hi def link dtraceComment Comment | |
142 hi def link dtraceNumber Number | |
143 hi def link dtraceOption Identifier | |
144 | |
145 let b:current_syntax = "dtrace" |