From 20d3e71c3f429120bfc570d13674eb8a4c881dfe Mon Sep 17 00:00:00 2001 From: Uday Bondhugula Date: Fri, 30 Aug 2019 17:38:36 -0700 Subject: [PATCH] update vim syntax file - more highlighting: numbers, elemental types inside shaped types - add some more keywords Signed-off-by: Uday Bondhugula Closes tensorflow/mlir#110 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/110 from bondhugula:vim 029777db0ecb95bfc6453c0869af1c233d84d521 PiperOrigin-RevId: 266487768 --- mlir/utils/vim/syntax/mlir.vim | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/mlir/utils/vim/syntax/mlir.vim b/mlir/utils/vim/syntax/mlir.vim index 41d277a..416ef1a 100644 --- a/mlir/utils/vim/syntax/mlir.vim +++ b/mlir/utils/vim/syntax/mlir.vim @@ -2,7 +2,7 @@ " Language: mlir " Maintainer: The MLIR team, http://github.com/tensorflow/mlir/ " Version: $Revision$ -" Adapted from the LLVM vim indent file +" Some parts adapted from the LLVM vim syntax file. if version < 600 syntax clear @@ -16,16 +16,22 @@ syn case match syn keyword mlirType index f16 f32 f64 " Integer type. syn match mlirType /\/ -" Primitive types inside memref, tensor, or vector. -syn match mlirType /<.*x\s*\zs\(f16\|f32\|f64\|i\d\+\)/ -syn match mlirType /\/ -syn match mlirType /\/ -syn match mlirType /\/ + +" Elemental types inside memref, tensor, or vector types. +syn match mlirType /x\s*\zs\(f16\|f32\|f64\|i\d\+\)/ + +" Shaped types. +syn match mlirType /\/ +syn match mlirType /\/ +syn match mlirType /\/ + +" vector types inside memref or tensor. +syn match mlirType /x\s*\zsvector/ " Operations. " Core ops (not exhaustive yet). " TODO: the list is not exhaustive. -syn keyword mlirOps alloc addf addi call call_indirect cmpi constant dealloc dma_start dma_wait dim extract_element getTensor load memref_cast mulf muli store select subf subi tensor_cast +syn keyword mlirOps alloc addf addi call call_indirect cmpi constant dealloc dma_start dma_wait dim extract_element for getTensor if load memref_cast mulf muli store select subf subi tensor_cast " Affine ops. syn match mlirOps /\/ @@ -36,6 +42,8 @@ syn match mlirOps /\/ syn match mlirOps /\/ syn match mlirOps /\/ +" TODO: dialect name prefixed ops (llvm or std). + " Keywords. syn keyword mlirKeyword \ else @@ -45,15 +53,20 @@ syn keyword mlirKeyword \ to " Misc syntax. -syn match mlirNoName /[%@!]\d\+\>/ + syn match mlirNumber /-\?\<\d\+\>/ +" Match numbers even in shaped types. +syn match mlirNumber /-\?\<\d\+\ze\s*x/ +syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/ + syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/ syn match mlirFloat /\<0x\x\+\>/ syn keyword mlirBoolean true false syn match mlirComment /\/\/.*$/ syn region mlirString start=/"/ skip=/\\"/ end=/"/ syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ -syn match mlirIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/ +syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/ +syn match mlirIdentifier /[%@!]\d\+\>/ syn match mlirMapSetOutline "#.*$" " Syntax-highlight lit test commands and bug numbers. @@ -84,7 +97,6 @@ if version >= 508 || !exists("did_c_syn_inits") HiLink mlirKeyword Keyword HiLink mlirBoolean Boolean HiLink mlirFloat Float - HiLink mlirNoName Identifier HiLink mlirConstant Constant HiLink mlirSpecialComment SpecialComment HiLink mlirIdentifier Identifier -- 2.7.4