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