Skip to content

Commit

Permalink
sparql syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
fsouza committed Jun 15, 2011
1 parent 51f6e5a commit 52366fb
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions ftdetect/sparql.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
au BufRead,BufNewFile *.sparql set filetype=sparql
86 changes: 86 additions & 0 deletions syntax/sparql.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
" Vim syntax file
" Language: SPARQL
" Maintainer: Jeroen Pulles <[email protected]>
" Last Change: 2006 Dec 26
" Remark: This syntax file only supports the query language,
" not the protocol or result. See reference at
" http://www.w3.org/TR/rdf-sparql-query/#grammar

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif

" A.3 Keywords are matched in a case-insensitive manner. (only keywords)
syntax case ignore
syntax keyword rqKeyword BASE PREFIX SELECT DISTINCT CONSTRUCT DESCRIBE ASK FROM NAMED WHERE ORDER BY ASC DESC LIMIT OFFSET OPTIONAL GRAPH FILTER REGEX
syntax case match
" case sensitive:
syntax keyword rqRdfType a
syntax keyword rqBuiltinCall STR LANG LANGMATCHES DATATYPE BOUND isIRI isURI isBLANK isLITERAL
syntax keyword rqBoolean true false
syntax keyword Todo TODO FIXME XXX
" A.4 Comments
syntax match rqComment /\#.*$/ contains=Todo,rqCodepointEscape

" A.5 & A.6 Escape sequences
syntax match rqCodepointEscape /\(\\U\x\{8\}\|\\u\x\{4\}\)/ contained contains=NONE
syntax match rqStringEscape +\\[tnrbf\"']\++ contained contains=NONE

" Strings
" [63], [78], [79], [80], [81]
syntax match rqStringSingle +'\([^\u0027\u005C\u000A\u000D]\|\\[tnrbf\\"']\+\|\\U\x\{8\}\|\\u\x\{4\}\)*'+ contains=rqStringEscape,rqCodepointEscape,@Spell
syntax match rqStringDouble +"\([^\u0022\u005C\u000A\u000D]\|\\[tnrbf\\"']\+\|\\U\x\{8\}\|\\u\x\{4\}\)*"+ contains=rqStringEscape,rqCodepointEscape,@Spell
syntax region rqStringLongSingle start=+'''+ end=+'''+ contains=rqStringEscape,rqCodepointEscape,@Spell
syntax region rqStringLongDouble start=+"""+ end=+"""+ contains=rqStringEscape,rqCodepointEscape,@Spell
syntax cluster rqString contains=rqStringSingle,rqStringDouble,rqStringLongSingle

" Names
" [69] Qname
syntax match rqQnamePrefix /\(\w\|\\U\x\{8\}\|\\u\x\{4\}\)\+:/he=e-1 contains=rqCodepointEscape
" [67] Q_IRI_REF
syntax match rqQIRIREF /<[^<>'{}|^`\u00-\u20]*>/hs=s+1,he=e-1 contains=rqCodepointEscape
" [71], [72], [88-90] Variables
" (JPU: High code points crash my vim, too many character classes SEGV my vim
" I'll just keep it simple for now: recognize word-class characters plus
" escapes: )
syntax match rqVar /[?$]\{1\}\(\w\|\\U\x\{8\}\|\\u\x\{4\}\)\+/ contains=rqCodepointEscape



highlight link rqKeyword Keyword
highlight link rqBuiltinCall Keyword
highlight link rqVar Identifier
highlight link rqStringSingle String
highlight link rqStringLongSingle String
highlight link rqStringDouble String
highlight link rqStringLongDouble String
highlight link rqComment Comment
highlight link rqRdfType Constant
highlight link rqQIRIREF Constant
highlight link rqBoolean Constant
highlight link rqQnamePrefix Macro
highlight link rqCodepointEscape SpecialChar
highlight link rqStringEscape SpecialChar


" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_sparql_syn_inits")
if version < 508
let did_sparql_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif

" HiLink mysqlKeyword Statement

delcommand HiLink
endif

let b:current_syntax = "sparql"

0 comments on commit 52366fb

Please sign in to comment.