summaryrefslogtreecommitdiffstats
path: root/powerline/lint/markedjson/tokens.py
blob: 6fa8bf18ca1dbfcf852da42fc1169d24d2ca0d66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)


class Token(object):
	def __init__(self, start_mark, end_mark):
		self.start_mark = start_mark
		self.end_mark = end_mark

	def __repr__(self):
		attributes = [
			key for key in self.__dict__
			if not key.endswith('_mark')
		]
		attributes.sort()
		arguments = ', '.join([
			'%s=%r' % (key, getattr(self, key))
			for key in attributes
		])
		return '%s(%s)' % (self.__class__.__name__, arguments)


class StreamStartToken(Token):
	id = '<stream start>'

	def __init__(self, start_mark=None, end_mark=None, encoding=None):
		self.start_mark = start_mark
		self.end_mark = end_mark
		self.encoding = encoding


class StreamEndToken(Token):
	id = '<stream end>'


class FlowSequenceStartToken(Token):
	id = '['


class FlowMappingStartToken(Token):
	id = '{'


class FlowSequenceEndToken(Token):
	id = ']'


class FlowMappingEndToken(Token):
	id = '}'


class KeyToken(Token):
	id = '?'


class ValueToken(Token):
	id = ':'


class FlowEntryToken(Token):
	id = ','


class ScalarToken(Token):
	id = '<scalar>'

	def __init__(self, value, plain, start_mark, end_mark, style=None):
		self.value = value
		self.plain = plain
		self.start_mark = start_mark
		self.end_mark = end_mark
		self.style = style