mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Complete mlr.vim syntax file
This commit is contained in:
parent
0c067054b1
commit
e60020caf0
2 changed files with 180 additions and 53 deletions
|
|
@ -1,8 +1,8 @@
|
|||
" Copyright 2021 John Kerl. All rights reserved.
|
||||
" Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
"
|
||||
" mlr.vim: Vim syntax file for the Miller DSL.
|
||||
|
||||
" " Copyright 2021 John Kerl. All rights reserved.
|
||||
" " Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
" "
|
||||
" " mlr.vim: Vim syntax file for the Miller DSL.
|
||||
"
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
|
@ -19,27 +19,49 @@ syn case match
|
|||
" ----------------------------------------------------------------
|
||||
syn region mlrComment start="#" end="$"
|
||||
syn region mlrString start=+"+ skip=+\\\\\|\\"+ end=+"+
|
||||
syn match mlrDecimalInt /\(\<[0-9]\+\>\)/
|
||||
syn match mlrDecimalInt /\(\<0x[0-9-a-fA-F]\+\>\)/
|
||||
syn match mlrDecimalInt /\(,,,\)/
|
||||
syn match mlrHexadecimalInt "\<-\=0[xX]_\?\(\x\+_\?\)\+\>"
|
||||
syn match mlrBinaryInt "\<-\=0[bB]_\?\([01]\+_\?\)\+\>"
|
||||
syn match mlrFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=\>"
|
||||
syn match mlrFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=\>"
|
||||
syn keyword mlrConstant M_PI M_E
|
||||
syn keyword mlrBoolean true false
|
||||
syn match mlrDecimalInt "\(\<[0-9][0-9]*\>\)"
|
||||
syn match mlrHexadecimalInt "\(\<0x[0-9a-fA-F][0-9a-fA-F]*\>\)"
|
||||
syn match mlrBinaryInt "\(\<0b[01][01]*\>\)"
|
||||
|
||||
syn match mlrFloat "\.[0-9][0-9]*"
|
||||
syn match mlrFloat "[0-9][0-9]*\."
|
||||
syn match mlrFloat "[0-9][0-9]*\.[0-9][0-9]*"
|
||||
syn match mlrFloat "[0-9][0-9]*\.[0-9]*"
|
||||
syn match mlrFloat "\([0-9][0-9]*[eE][0-9][0-9]*\)"
|
||||
syn match mlrFloat "\([0-9][0-9]*[eE]-[0-9][0-9]*\)"
|
||||
syn match mlrFloat "\([0-9][0-9]*\.[0-9]*[eE][0-9][0-9]*\)"
|
||||
syn match mlrFloat "\([0-9][0-9]*\.[0-9]*[eE]-[0-9][0-9]*\)"
|
||||
syn match mlrFloat "\([0-9]*\.[0-9][0-9]*[eE][0-9][0-9]*\)"
|
||||
syn match mlrFloat "\([0-9]*\.[0-9][0-9]*[eE]-[0-9][0-9]*\)"
|
||||
|
||||
syn keyword mlrConstant M_PI M_E
|
||||
syn keyword mlrContextVariable IPS IFS IRS OPS OFS ORS OFLATSEP NF NR FNR FILENAME FILENUM
|
||||
syn keyword mlrENV ENV
|
||||
|
||||
syn keyword mlrType arr bool float int map num str var
|
||||
syn keyword mlrKeyword begin do elif else end filter for if in while break continue return
|
||||
syn keyword mlrKeyword func subr call dump edump
|
||||
syn keyword mlrKeyword emit emitp emitf eprint eprintn print printn tee stdout stderr unset null
|
||||
syn match mlrFieldName /\(\$\<[a-zA-Z_][a-zA-Z_0-9]*\>\)/
|
||||
syn match mlrFieldName /\(\$\*\)/
|
||||
syn match mlrOosvarName /\(@\<[a-zA-Z_][a-zA-Z_0-9]*\>\)/
|
||||
syn match mlrOosvarName /\(@\*\)/
|
||||
syn match mlrIdentifier /\(\<[a-zA-Z_][a-zA-Z_0-9]*\>\)/
|
||||
syn match mlrFunctionCall /\(\<[a-zA-Z_][a-zA-Z_0-9]*\>\)[ \t]*(/
|
||||
|
||||
syn region mlrParen start='(' end=')' transparent
|
||||
syn region mlrBlock start="{" end="}" transparent
|
||||
|
||||
" Trailing whitespace; space-tab
|
||||
syn match mlrSpaceError display excludenl "\s\+$"
|
||||
syn match mlrSpaceError display " \+\t"me=e-1
|
||||
|
||||
syn match mlrOperator /!/
|
||||
syn match mlrOperator /%/
|
||||
syn match mlrOperator /&/
|
||||
syn match mlrOperator /(/
|
||||
syn match mlrOperator /)/
|
||||
syn match mlrOperator /*/
|
||||
syn match mlrOperator /\*/
|
||||
syn match mlrOperator /+/
|
||||
syn match mlrOperator /+/
|
||||
syn match mlrOperator /-/
|
||||
syn match mlrOperator /-/
|
||||
syn match mlrOperator /\./
|
||||
syn match mlrOperator /\//
|
||||
|
|
@ -47,13 +69,14 @@ syn match mlrOperator /:/
|
|||
syn match mlrOperator /</
|
||||
syn match mlrOperator />/
|
||||
syn match mlrOperator /?/
|
||||
syn match mlrOperator /^/
|
||||
syn match mlrOperator /\^/
|
||||
syn match mlrOperator /|/
|
||||
syn match mlrOperator /\~/
|
||||
syn match mlrOperator /!=/
|
||||
syn match mlrOperator /&&/
|
||||
syn match mlrOperator /**/
|
||||
syn match mlrOperator /\*\*/
|
||||
syn match mlrOperator /\.\*/
|
||||
|
||||
syn match mlrOperator /\.+/
|
||||
syn match mlrOperator /\.+/
|
||||
syn match mlrOperator /\.-/
|
||||
|
|
@ -75,7 +98,7 @@ syn match mlrOperator />>>/
|
|||
syn match mlrOperator /???/
|
||||
syn match mlrOperator /%=/
|
||||
syn match mlrOperator /&=/
|
||||
syn match mlrOperator /*=/
|
||||
syn match mlrOperator /\*=/
|
||||
syn match mlrOperator /+=/
|
||||
syn match mlrOperator /-=/
|
||||
syn match mlrOperator /\.=/
|
||||
|
|
@ -83,7 +106,7 @@ syn match mlrOperator /\/=/
|
|||
syn match mlrOperator /^=/
|
||||
syn match mlrOperator /|=/
|
||||
syn match mlrOperator /&&=/
|
||||
syn match mlrOperator /**=/
|
||||
syn match mlrOperator /\*\*=/
|
||||
syn match mlrOperator /\/\/=/
|
||||
syn match mlrOperator /<<=/
|
||||
syn match mlrOperator />>=/
|
||||
|
|
@ -93,48 +116,34 @@ syn match mlrOperator /||=/
|
|||
syn match mlrOperator />>>=/
|
||||
syn match mlrOperator /???=/
|
||||
|
||||
syn keyword mlrKeyword begin do elif else end filter for if in while break continue return
|
||||
syn keyword mlrKeyword func subr call dump edump
|
||||
syn keyword mlrKeyword emit emitp emitf eprint eprintn print printn tee stdout stderr unset null
|
||||
syn keyword mlrType arr bool float int map num str var
|
||||
syn match mlrFieldName /\(\$[_a-zA-Z0-9]\+\)/
|
||||
syn match mlrFieldName /\(\$\*\)/
|
||||
syn match mlrOosvarName /\(@[_a-zA-Z0-9]*\)/
|
||||
syn match mlrOosvarName /\(@\*\)/
|
||||
syn match mlrIdentifier /\(\<[a-zA-Z_][a-zA-Z_0-9]*\>\)/
|
||||
syn match mlrFunctionCall /\w\+\ze(/ contains=mlrBuiltins,mlrDeclaration
|
||||
|
||||
syn region mlrParen start='(' end=')' transparent
|
||||
syn region mlrBlock start="{" end="}" transparent
|
||||
|
||||
" Trailing whitespace; space-tab
|
||||
syn match mlrSpaceError display excludenl "\s\+$"
|
||||
syn match mlrSpaceError display " \+\t"me=e-1
|
||||
|
||||
" ----------------------------------------------------------------
|
||||
hi def link mlrConstant Constant
|
||||
hi def link mlrString String
|
||||
hi def link mlrBoolean Boolean
|
||||
hi def link mlrNumber Number
|
||||
hi def link mlrFloat Float
|
||||
hi def link mlrInteger Number
|
||||
|
||||
hi def link mlrComment Comment
|
||||
hi def link mlrString String
|
||||
hi def link mlrKeyword Keyword
|
||||
hi def link mlrContextVariable Keyword
|
||||
hi def link mlrENV Keyword
|
||||
hi def link mlrError Error
|
||||
hi def link mlrSpecial Special
|
||||
hi def link mlrType Type
|
||||
|
||||
hi def link mlrDecimalInt Number
|
||||
hi def link mlrHexadecimalInt Number
|
||||
hi def link mlrBinaryInt Number
|
||||
hi def link mlrFloat Float
|
||||
hi def link mlrConstant Constant
|
||||
hi def link mlrBoolean Boolean
|
||||
hi def link mlrContextVariable Keyword
|
||||
hi def link mlrENV Keyword
|
||||
hi def link mlrOperator Operator
|
||||
hi def link mlrKeyword Keyword
|
||||
hi def link mlrType Type
|
||||
hi def link mlrFieldName Macro
|
||||
hi def link mlrOosvarName Macro
|
||||
hi def link mlrFieldName Special
|
||||
hi def link mlrOosvarName Special
|
||||
hi def link mlrIdentifier Identifier
|
||||
hi def link mlrFunctionCall Type
|
||||
hi def link mlrSpaceError Error
|
||||
|
||||
hi def link mlrOperator Operator
|
||||
|
||||
" ----------------------------------------------------------------
|
||||
syn sync minlines=200
|
||||
|
||||
let b:current_syntax = "mlr"
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
|
|
|||
118
vim/syntax/testfile.mlr
Normal file
118
vim/syntax/testfile.mlr
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect magenta:
|
||||
M_PI M_E
|
||||
# Expect blue, like identifer:
|
||||
M_UUU
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect magenta:
|
||||
"abc" "123"
|
||||
" "
|
||||
"this is \"very\" special"
|
||||
"abc 'def' ghi"
|
||||
|
||||
# Expect mix:
|
||||
and "this is a string"
|
||||
'adsfasdf'
|
||||
'abc "def" ghi'
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect magenta except 'falls':
|
||||
true falls false
|
||||
|
||||
# Expect magenta:
|
||||
123
|
||||
0xabcd
|
||||
0b1101
|
||||
|
||||
# Expect not magenta:
|
||||
0xabcdxyz
|
||||
0xxxxx
|
||||
0b1021
|
||||
|
||||
# Expect magenta:
|
||||
123
|
||||
123.
|
||||
123.4
|
||||
.234
|
||||
0.234
|
||||
1e2
|
||||
1e-2
|
||||
1.2e3 1.e3
|
||||
1.2e-3 1.e-3
|
||||
.2e3
|
||||
.2e-3 1.e-3
|
||||
|
||||
# Expect magenta 3e4, non-magenta e5:
|
||||
3e4e5
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect cyan:
|
||||
abc
|
||||
abc123
|
||||
abc_123
|
||||
_abc
|
||||
_123
|
||||
# Expect non-cyan:
|
||||
123abc
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect cyan:
|
||||
# comment
|
||||
not a comment # yup now it is
|
||||
### asfasdf
|
||||
aaa # a # b # cde
|
||||
|
||||
# Expect cyan after '#':
|
||||
,,,,,, # here too
|
||||
,,, # a # b # cde
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect yellow except IXD, contain, set:
|
||||
|
||||
IPS IXS IFS IRS OPS OFS ORS OFLATSEP NF NR FNR FILENAME FILENUM
|
||||
ENV
|
||||
begin do elif else end filter for if in while break continue contain return
|
||||
func subr call dump edump
|
||||
emit emitp emitf eprint eprintn print printn tee stdout stderr set unset null
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect yellow in between 'a' and 'b':
|
||||
a ! b; a % b; a & b; a * b; a + b; a - b;
|
||||
a . b; a / b; a : b; a < b; a > b; a ? b;
|
||||
a ^ b; a | b; a ~ b; a != b; a && b; a ** b;
|
||||
a .* b; a .+ b; a .+ b; a .- b; a .- b; a ./ b;
|
||||
a // b; a << b; a <= b; a == b; a =~ b; a >= b;
|
||||
a >> b; a ?? b; a ^^ b; a || b; a !=~ b; a .// b;
|
||||
a >>> b; a ??? b; a %= b; a &= b; a *= b; a += b;
|
||||
a -= b; a .= b; a /= b; a ^= b; a |= b; a &&= b;
|
||||
a **= b; a //= b; a <<= b; a >>= b; a ??= b; a ^^= b;
|
||||
a ||= b; a >>>= b; a ???= b;
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect green except 'strang strung ver vor':
|
||||
arr bool float int map num str var strang strung ver vor
|
||||
|
||||
# Expect green foo and bar:
|
||||
func foo(int x, str y, bool z) {
|
||||
}
|
||||
subr bar(int x,str y, bool z) {
|
||||
}
|
||||
$xa = foo($x, $y, $z)
|
||||
call foo($x, $y, $z)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect strong white except @$ and $@:
|
||||
$abcde
|
||||
@abcde
|
||||
@$
|
||||
$@
|
||||
$*
|
||||
@*
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Expect space-tab and trailing-space to be red:
|
||||
asdf
|
||||
asdf
|
||||
asdf
|
||||
Loading…
Add table
Add a link
Reference in a new issue