annotate runtime/syntax/dtrace.vim @ 32816:939396a5711c v9.0.1722

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