A single dot is not a float value (fixes #62).
[pyyaml/python3.git] / lib / yaml / tokens.py
blob4d0b48a394ac8c019b401516a12f688df361cf90
2 class Token(object):
3 def __init__(self, start_mark, end_mark):
4 self.start_mark = start_mark
5 self.end_mark = end_mark
6 def __repr__(self):
7 attributes = [key for key in self.__dict__
8 if not key.endswith('_mark')]
9 attributes.sort()
10 arguments = ', '.join(['%s=%r' % (key, getattr(self, key))
11 for key in attributes])
12 return '%s(%s)' % (self.__class__.__name__, arguments)
14 #class BOMToken(Token):
15 # id = '<byte order mark>'
17 class DirectiveToken(Token):
18 id = '<directive>'
19 def __init__(self, name, value, start_mark, end_mark):
20 self.name = name
21 self.value = value
22 self.start_mark = start_mark
23 self.end_mark = end_mark
25 class DocumentStartToken(Token):
26 id = '<document start>'
28 class DocumentEndToken(Token):
29 id = '<document end>'
31 class StreamStartToken(Token):
32 id = '<stream start>'
33 def __init__(self, start_mark=None, end_mark=None,
34 encoding=None):
35 self.start_mark = start_mark
36 self.end_mark = end_mark
37 self.encoding = encoding
39 class StreamEndToken(Token):
40 id = '<stream end>'
42 class BlockSequenceStartToken(Token):
43 id = '<block sequence start>'
45 class BlockMappingStartToken(Token):
46 id = '<block mapping start>'
48 class BlockEndToken(Token):
49 id = '<block end>'
51 class FlowSequenceStartToken(Token):
52 id = '['
54 class FlowMappingStartToken(Token):
55 id = '{'
57 class FlowSequenceEndToken(Token):
58 id = ']'
60 class FlowMappingEndToken(Token):
61 id = '}'
63 class KeyToken(Token):
64 id = '?'
66 class ValueToken(Token):
67 id = ':'
69 class BlockEntryToken(Token):
70 id = '-'
72 class FlowEntryToken(Token):
73 id = ','
75 class AliasToken(Token):
76 id = '<alias>'
77 def __init__(self, value, start_mark, end_mark):
78 self.value = value
79 self.start_mark = start_mark
80 self.end_mark = end_mark
82 class AnchorToken(Token):
83 id = '<anchor>'
84 def __init__(self, value, start_mark, end_mark):
85 self.value = value
86 self.start_mark = start_mark
87 self.end_mark = end_mark
89 class TagToken(Token):
90 id = '<tag>'
91 def __init__(self, value, start_mark, end_mark):
92 self.value = value
93 self.start_mark = start_mark
94 self.end_mark = end_mark
96 class ScalarToken(Token):
97 id = '<scalar>'
98 def __init__(self, value, plain, start_mark, end_mark, style=None):
99 self.value = value
100 self.plain = plain
101 self.start_mark = start_mark
102 self.end_mark = end_mark
103 self.style = style