1-- vim: set ft=lua ts=2 sw=2 et : 2-- Language definition for PDF files 3-- Author: Roland Hieber <rohieb@rohieb.name> 4-- Date: 2013-11-22 5-- Known Bugs: 6-- * Does not highlight files with MacOS (CR-only) line endings 7-- * Does not (yet) highlight inside streams due to limitations in the library 8-- 9 10Description="Portable Document Format" 11 12Categories = {"document"} 13 14IgnoreCase=false 15 16-- File Structure 17PreProcessor={ 18 Prefix=[[%PDF-[0-9]\.[0-9]|%%EOF|xref|startxref|trailer]] 19} 20 21-- Comments. But do not match file structure elements. 22Comments={ 23 { Block=false, 24 Delimiter={ [[%(?!PDF-[0-9]\.[0-9]|%EOF)]] }, 25 }, 26} 27 28-- Numbers: 0.45, +1.34, -.4, 123, 4., and so on. 29Digits=[[ [-+]?\.[0-9]+|[-+]?[0-9]+\.?[0-9]* ]] 30 31-- Strings: (string), <hex> and streams 32Strings={ 33 DelimiterPairs= { 34 { Open=[[ \( ]], Close=[[ \) ]] }, 35 { Open=[[ < ]], Close=[[ > ]] }, 36 { Open=[[ ^stream ]], Close=[[ ^endstream ]], Raw=true }, 37 } 38} 39 40-- Note: we highlight dictionary and array syntax as "keywords", so we have to 41-- include them in Identifiers. This definition basically matches the allowed 42-- characters for Names. Also, we do not want to match Numbers, Streams, 43-- References and file structure elements as identifiers 44Identifiers=[[ (?!%PDF-[0-9]\.[0-9]|%%EOF|xref|startxref|trailer|[0-9]+\s+[0-9]+\s+(R|obj)|[-+]?\.[0-9]+|[-+]?[0-9]+\.?[0-9]*)[^\s\[\]\(\){}<>/%]+ ]] 45 46Keywords={ 47 -- Indirect Objects 48 { Id=1, 49 Regex=[[ [0-9]+\s+[0-9]+\s+(obj|R)|endobj]], 50 Group=0 51 }, 52 -- Arrays and Dictionaries 53 { Id=2, 54 Regex=[[ \[|\]|<<|>> ]], 55 }, 56 -- Names 57 { Id=3, 58 Regex=[[ /[^\s\[\]\(\){}<>/%]+ ]], 59 }, 60 -- Constants 61 { Id=4, 62 --List={"true", "false", "null"}, 63 Regex=[[ true|false|null ]], 64 }, 65} 66