3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
4 " Last Change: 2007 Dec 16
6 if exists("b:current_syntax")
10 if !exists("main_syntax")
11 let main_syntax = 'pdf'
14 syn include @pdfXML syntax/xml.vim
18 syn cluster pdfObjects contains=pdfBoolean,pdfConstant,pdfNumber,pdfFloat,pdfName,pdfHexString,pdfString,pdfArray,pdfHash,pdfReference,pdfComment
19 syn keyword pdfBoolean true false contained
20 syn keyword pdfConstant null contained
21 syn match pdfNumber "[+-]\=\<\d\+\>"
22 syn match pdfFloat "[+-]\=\<\%(\d\+\.\|\d*\.\d\+\)\>" contained
24 syn match pdfNameError "#\X\|#\x\X\|#00" contained containedin=pdfName
25 syn match pdfSpecialChar "#\x\x" contained containedin=pdfName
26 syn match pdfName "/[^[:space:]\[\](){}<>/]*" contained
27 syn match pdfHexError "[^[:space:][:xdigit:]<>]" contained
28 "syn match pdfHexString "<\s*\x[^<>]*\x\s*>" contained contains=pdfHexError
29 "syn match pdfHexString "<\s*\x\=\s*>" contained
30 syn region pdfHexString matchgroup=pdfDelimiter start="<<\@!" end=">" contained contains=pdfHexError
31 syn match pdfStringError "\\." contained containedin=pdfString
32 syn match pdfSpecialChar "\\\%(\o\{1,3\}\|[nrtbf()\\]\)" contained containedin=pdfString
33 syn region pdfString matchgroup=pdfDelimiter start="\\\@<!(" end="\\\@<!)" contains=pdfString
35 syn region pdfArray matchgroup=pdfOperator start="\[" end="\]" contains=@pdfObjects contained
36 syn region pdfHash matchgroup=pdfOperator start="<<" end=">>" contains=@pdfObjects contained
37 syn match pdfReference "\<\d\+\s\+\d\+\s\+R\>"
38 "syn keyword pdfOperator R contained containedin=pdfReference
40 syn region pdfObject matchgroup=pdfType start="\<obj\>" end="\<endobj\>" contains=@pdfObjects
41 syn region pdfObject matchgroup=pdfType start="\<obj\r\=\n" end="\<endobj\>" contains=@pdfObjects fold
43 " Do these twice. The ones with only newlines are foldable
44 syn region pdfStream matchgroup=pdfType start="\<stream\r\=\n" end="endstream\s*\%(\r\|\n\|\r\n\)" contained containedin=pdfObject
45 syn region pdfXMLStream matchgroup=pdfType start="\<stream\r\=\n\_s*\%(<?\)\@=" end="endstream\s*\%(\r\|\n\|\r\n\)" contained containedin=pdfObject contains=@pdfXML
46 syn region pdfStream matchgroup=pdfType start="\<stream\n" end="endstream\s*\%(\r\|\n\|\r\n\)" contained containedin=pdfObject fold
47 syn region pdfXMLStream matchgroup=pdfType start="\<stream\n\_s*\%(<?\)\@=" end="endstream\s*\%(\r\|\n\|\r\n\)" contained containedin=pdfObject contains=@pdfXML fold
49 syn region pdfPreProc start="\<xref\%(\r\|\n\|\r\n\)" end="^trailer\%(\r\|\n\|\r\n\)" skipwhite skipempty nextgroup=pdfHash contains=pdfNumber fold
50 syn keyword pdfPreProc startxref
51 syn match pdfComment "%.*\%(\r\|\n\)" contains=pdfPreProc
52 syn match pdfPreProc "^%\%(%EOF\|PDF-\d\.\d\)\(\r\|\n\)"
54 hi def link pdfOperator Operator
55 hi def link pdfNumber Number
56 hi def link pdfFloat Float
57 hi def link pdfBoolean Boolean
58 hi def link pdfConstant Constant
59 hi def link pdfName Identifier
60 hi def link pdfNameError pdfStringError
61 hi def link pdfHexString pdfString
62 hi def link pdfHexError pdfStringError
63 hi def link pdfString String
64 hi def link pdfStringError Error
65 hi def link pdfSpecialChar SpecialChar
66 hi def link pdfDelimiter Delimiter
67 hi def link pdfType Type
68 hi def link pdfReference Tag
69 hi def link pdfStream NonText
70 hi def link pdfPreProc PreProc
71 hi def link pdfComment Comment
73 let b:current_syntax = "pdf"