eric6/ThirdParty/Pygments/pygments/lexers/data.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.lexers.data 3 pygments.lexers.data
4 ~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for data file format. 6 Lexers for data file format.
7 7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2020 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
21 21
22 class YamlLexerContext(LexerContext): 22 class YamlLexerContext(LexerContext):
23 """Indentation context for the YAML lexer.""" 23 """Indentation context for the YAML lexer."""
24 24
25 def __init__(self, *args, **kwds): 25 def __init__(self, *args, **kwds):
26 super(YamlLexerContext, self).__init__(*args, **kwds) 26 super().__init__(*args, **kwds)
27 self.indent_stack = [] 27 self.indent_stack = []
28 self.indent = -1 28 self.indent = -1
29 self.next_indent = 0 29 self.next_indent = 0
30 self.block_scalar_indent = None 30 self.block_scalar_indent = None
31 31
431 } 431 }
432 432
433 def get_tokens_unprocessed(self, text=None, context=None): 433 def get_tokens_unprocessed(self, text=None, context=None):
434 if context is None: 434 if context is None:
435 context = YamlLexerContext(text, 0) 435 context = YamlLexerContext(text, 0)
436 return super(YamlLexer, self).get_tokens_unprocessed(text, context) 436 return super().get_tokens_unprocessed(text, context)
437 437
438 438
439 class JsonLexer(RegexLexer): 439 class JsonLexer(RegexLexer):
440 """ 440 """
441 For JSON data structures. 441 For JSON data structures.
469 (r'(true|false|null)\b', Keyword.Constant), 469 (r'(true|false|null)\b', Keyword.Constant),
470 (('%(int_part)s(%(frac_part)s%(exp_part)s|' 470 (('%(int_part)s(%(frac_part)s%(exp_part)s|'
471 '%(exp_part)s|%(frac_part)s)') % vars(), 471 '%(exp_part)s|%(frac_part)s)') % vars(),
472 Number.Float), 472 Number.Float),
473 (int_part, Number.Integer), 473 (int_part, Number.Integer),
474 (r'"(\\\\|\\"|[^"])*"', String.Double), 474 (r'"(\\(["\\/bfnrt]|u[a-fA-F0-9]]{4})|[^\\"])*"', String.Double),
475 ], 475 ],
476 476
477 477
478 # the right hand side of an object, after the attribute name 478 # the right hand side of an object, after the attribute name
479 'objectattribute': [ 479 'objectattribute': [
486 ], 486 ],
487 487
488 # a json object - { attr, attr, ... } 488 # a json object - { attr, attr, ... }
489 'objectvalue': [ 489 'objectvalue': [
490 include('whitespace'), 490 include('whitespace'),
491 (r'"(\\\\|\\"|[^"])*"', Name.Tag, 'objectattribute'), 491 (r'"(\\(["\\/bfnrt]|u[a-fA-F0-9]]{4})|[^\\"])*"', Name.Tag, 'objectattribute'),
492 (r'\}', Punctuation, '#pop'), 492 (r'\}', Punctuation, '#pop'),
493 ], 493 ],
494 494
495 # json array - [ value, value, ... } 495 # json array - [ value, value, ... }
496 'arrayvalue': [ 496 'arrayvalue': [

eric ide

mercurial