Browse Source

vim: import peg.vim from https://github.com/gf3/peg.vim

Signed-off-by: Alejandro Mery <amery@hanoverdisplays.com>
master
Alejandro Mery 5 years ago
committed by Alejandro Mery
parent
commit
26cd8a7274
2 changed files with 48 additions and 0 deletions
  1. +1
    -0
      files/.vim/ftdetect/peg.vim
  2. +47
    -0
      files/.vim/syntax/peg.vim

+ 1
- 0
files/.vim/ftdetect/peg.vim

@ -0,0 +1 @@
au BufRead,BufNewFile *.peg set ft=peg

+ 47
- 0
files/.vim/syntax/peg.vim

@ -0,0 +1,47 @@
" Vim syntax file
" Language: Parser Expression Grammars (PEG)
" Maintainer: Gianni Chiappetta
" Latest Revision: 2011-02-08
if exists("b:current_syntax")
finish
endif
syn match pegRuleIdentifier /^\a\+/ skipwhite nextgroup=pegSeperator
syn match pegSeperator "<-" skipwhite contained nextgroup=pegExpression
syn match pegSeperator "←" skipwhite contained nextgroup=pegExpression
syn match pegExpression /.*/ contained skipwhite contains=pegDelimiter,pegGrouping,pegSpecial,pegRange,pegTerminal,pegOrderedChoice,pegNonTerminal,pegQuantifier
syn match pegDelimiter /[§]/ contained display
syn region pegGrouping matchgroup=pegDelimiter start=/(/ end=/)/ contained skipwhite keepend contains=pegExpression display
syn match pegSpecial /[!&ϵ^]/ contained display
syn match pegOrderedChoice /\// contained display
syn region pegRange matchgroup=pegDelimiter start=/\[^/ start=/\[/ end=/\]/ contained skipwhite contains=pegRangeValue,pegUnicode display
syn match pegRangeValue /\d\+-\d\+/ contained display
syn match pegRangeValue /\a\+-\a\+/ contained display
syn region pegTerminal matchgroup=pegDelimiter start=/"/ end=/"/ contained display
syn region pegTerminal matchgroup=pegDelimiter start=/'/ end=/'/ contained display
syn match pegUnicode /U+[A-F0-9]\{4,6}/ contained display
syn match pegNonTerminal /\a+/ contained display
syn match pegQuantifier /[+\*?]/ contained display
syn match pegQuantifier /{\d\+,\d\+}/ contained display
syn match pegQuantifier /{\d\+}/ contained display
syn match pegComment /;.*$/ contains=pegTodo
syn keyword pegTodo TODO FIXME XXX NOTE contained
hi link pegRuleIdentifier Identifier
hi link pegSeperator Conditional
hi link pegDelimiter Delimiter
hi link pegSpecial Special
hi link pegOrderedChoice Conditional
hi link pegComment Comment
hi link pegRangeValue Constant
hi link pegTerminal String
hi link pegUnicode Constant
hi link pegQuantifier Function
hi link pegTodo Todo
let b:current_syntax = "peg"

Loading…
Cancel
Save