5712:f0d08bdeacf4 | 5713:6762afd9f963 |
---|---|
3 pygments.lexers.rdf | 3 pygments.lexers.rdf |
4 ~~~~~~~~~~~~~~~~~~~ | 4 ~~~~~~~~~~~~~~~~~~~ |
5 | 5 |
6 Lexers for semantic web and RDF query languages and markup. | 6 Lexers for semantic web and RDF query languages and markup. |
7 | 7 |
8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. | 8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. | 9 :license: BSD, see LICENSE for details. |
10 """ | 10 """ |
11 | 11 |
12 import re | 12 import re |
13 | 13 |
40 u'\u200c-\u200d' | 40 u'\u200c-\u200d' |
41 u'\u2070-\u218f' | 41 u'\u2070-\u218f' |
42 u'\u2c00-\u2fef' | 42 u'\u2c00-\u2fef' |
43 u'\u3001-\ud7ff' | 43 u'\u3001-\ud7ff' |
44 u'\uf900-\ufdcf' | 44 u'\uf900-\ufdcf' |
45 u'\ufdf0-\ufffd' | 45 u'\ufdf0-\ufffd') |
46 u'\U00010000-\U000effff') | |
47 | 46 |
48 PN_CHARS_U_GRP = (PN_CHARS_BASE_GRP + '_') | 47 PN_CHARS_U_GRP = (PN_CHARS_BASE_GRP + '_') |
49 | 48 |
50 PN_CHARS_GRP = (PN_CHARS_U_GRP + | 49 PN_CHARS_GRP = (PN_CHARS_U_GRP + |
51 r'\-' + | 50 r'\-' + |
54 u'\u0300-\u036f' + | 53 u'\u0300-\u036f' + |
55 u'\u203f-\u2040') | 54 u'\u203f-\u2040') |
56 | 55 |
57 HEX_GRP = '0-9A-Fa-f' | 56 HEX_GRP = '0-9A-Fa-f' |
58 | 57 |
59 PN_LOCAL_ESC_CHARS_GRP = r' _~.\-!$&""()*+,;=/?#@%' | 58 PN_LOCAL_ESC_CHARS_GRP = r' _~.\-!$&"()*+,;=/?#@%' |
60 | 59 |
61 # terminal productions :: | 60 # terminal productions :: |
62 | 61 |
63 PN_CHARS_BASE = '[' + PN_CHARS_BASE_GRP + ']' | 62 PN_CHARS_BASE = '[' + PN_CHARS_BASE_GRP + ']' |
64 | 63 |
189 mimetypes = ['text/turtle', 'application/x-turtle'] | 188 mimetypes = ['text/turtle', 'application/x-turtle'] |
190 | 189 |
191 flags = re.IGNORECASE | 190 flags = re.IGNORECASE |
192 | 191 |
193 patterns = { | 192 patterns = { |
194 'PNAME_NS': r'((?:[a-zA-Z][\w-]*)?\:)', # Simplified character range | 193 'PNAME_NS': r'((?:[a-z][\w-]*)?\:)', # Simplified character range |
195 'IRIREF': r'(<[^<>"{}|^`\\\x00-\x20]*>)' | 194 'IRIREF': r'(<[^<>"{}|^`\\\x00-\x20]*>)' |
196 } | 195 } |
197 | 196 |
198 # PNAME_NS PN_LOCAL (with simplified character range) | 197 # PNAME_NS PN_LOCAL (with simplified character range) |
199 patterns['PrefixedName'] = r'%(PNAME_NS)s([a-z][\w-]*)' % patterns | 198 patterns['PrefixedName'] = r'%(PNAME_NS)s([a-z][\w-]*)' % patterns |
256 ], | 255 ], |
257 'string-escape': [ | 256 'string-escape': [ |
258 (r'.', String, '#pop'), | 257 (r'.', String, '#pop'), |
259 ], | 258 ], |
260 'end-of-string': [ | 259 'end-of-string': [ |
261 | 260 (r'(@)([a-z]+(:?-[a-z0-9]+)*)', |
262 (r'(@)([a-zA-Z]+(:?-[a-zA-Z0-9]+)*)', | |
263 bygroups(Operator, Generic.Emph), '#pop:2'), | 261 bygroups(Operator, Generic.Emph), '#pop:2'), |
264 | 262 |
265 (r'(\^\^)%(IRIREF)s' % patterns, bygroups(Operator, Generic.Emph), '#pop:2'), | 263 (r'(\^\^)%(IRIREF)s' % patterns, bygroups(Operator, Generic.Emph), '#pop:2'), |
266 (r'(\^\^)%(PrefixedName)s' % patterns, | 264 (r'(\^\^)%(PrefixedName)s' % patterns, |
267 bygroups(Operator, Generic.Emph, Generic.Emph), '#pop:2'), | 265 bygroups(Operator, Generic.Emph, Generic.Emph), '#pop:2'), |