From 8ad7d9d07aeea660b63947d23c953fec42ba79d6 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Wed, 20 Feb 2019 14:45:14 +0000 Subject: [PATCH] vim: import leg.vim from https://github.com/Qix-/leg.vim Signed-off-by: Alejandro Mery --- files/.vim/ftdetect/leg.vim | 1 + files/.vim/syntax/leg.vim | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 files/.vim/ftdetect/leg.vim create mode 100644 files/.vim/syntax/leg.vim diff --git a/files/.vim/ftdetect/leg.vim b/files/.vim/ftdetect/leg.vim new file mode 100644 index 0000000..dc5835e --- /dev/null +++ b/files/.vim/ftdetect/leg.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.leg set ft=leg diff --git a/files/.vim/syntax/leg.vim b/files/.vim/syntax/leg.vim new file mode 100644 index 0000000..e9b23c9 --- /dev/null +++ b/files/.vim/syntax/leg.vim @@ -0,0 +1,55 @@ +" Vim syntax file +" Language: Parser Expression Grammars (PEG) -- LEG dialect +" Maintainer: Gianni Chiappetta, Josh Junon +" Latest Revision: 2016-10-06 + +if exists("b:current_syntax") + finish +endif + +syn include @c syntax/cpp.vim + +syn match legRuleIdentifier /^\v[-a-zA-Z_][-a-zA-Z_0-9]*/ skipwhite skipnl nextgroup=legSeperator + +syn match legSeperator "=" skipwhite skipnl contained nextgroup=legExpression + +syn match legExpression /\v[^\;]*/ contained skipwhite skipnl contains=legDelimiter,legOrderedChoice,legGrouping,legSpecial,legRange,legTerminal,legNonTerminal,legQuantifier,legRuleBody +syn match legDelimiter /[§]/ contained display +syn region legGrouping matchgroup=legDelimiter start=/(/ end=/)/ contained skipwhite keepend contains=legExpression display +syn match legSpecial /[!&ϵ^]/ contained display +syn match legOrderedChoice /\v\|/ display +syn region legRange matchgroup=legDelimiter start=/\[^/ start=/\[/ end=/\]/ contained skipwhite contains=legRangeValue,legUnicode display +syn match legRangeValue /\d\+-\d\+/ contained display +syn match legRangeValue /\a\+-\a\+/ contained display +syn region legTerminal matchgroup=legDelimiter start=/"/ end=/"/ contained display +syn region legTerminal matchgroup=legDelimiter start=/'/ end=/'/ contained display +syn match legUnicode /U+[A-F0-9]\{4,6}/ contained display +syn match legNonTerminal /\a+/ contained display +syn match legQuantifier /[+\*?]/ contained display +syn match legQuantifier /{\d\+,\d\+}/ contained display +syn match legQuantifier /{\d\+}/ contained display +syn match legSpecialSymbol /\v\$\$/ contained display +syn region legRuleBody matchgroup=legCDelimiter start=/\v([@~]\s*)?\{/ end=/}/ contains=legSpecialSymbol,@c + +syn match legComment /#.*$/ contains=legTodo +syn keyword legTodo TODO FIXME XXX NOTE contained + +syn region legCBlock matchgroup=legCDelimiter start=/\v^\%\{/ end=/\v\%\}$/ keepend contains=@c +syn region legCBlock matchgroup=legCDelimiter start=/\v\%\%/ skip=/\v.*/ end=/$/ excludenl contains=@c + +hi link legOrderedChoice legSeperator + +hi link legRuleIdentifier Statement +hi link legSeperator Conditional +hi link legDelimiter Delimiter +hi link legCDelimiter Conditional +hi link legSpecial Special +hi link legComment Comment +hi link legRangeValue Constant +hi link legTerminal String +hi link legUnicode Constant +hi link legQuantifier Function +hi link legTodo Todo +hi link legSpecialSymbol Special + +let b:current_syntax = "leg"