source: branches/pyyaml3000/lib/yaml/tokens.py @ 52

Revision 52, 2.3 KB checked in by xi, 9 years ago (diff)

Cleanup error messages.

RevLine 
[46]1
2class Token:
3    def __init__(self, start_marker, end_marker):
4        self.start_marker = start_marker
5        self.end_marker = end_marker
[51]6    def __repr__(self):
7        attributes = [key for key in self.__dict__
8                if not key.endswith('_marker')]
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)
[46]13
[51]14#class BOMToken(Token):
15#    id = '<byte order mark>'
16
[46]17class DirectiveToken(Token):
[51]18    id = '<directive>'
[48]19    def __init__(self, name, value, start_marker, end_marker):
[46]20        self.name = name
[48]21        self.value = value
[46]22        self.start_marker = start_marker
23        self.end_marker = end_marker
24
25class DocumentStartToken(Token):
[51]26    id = '<document start>'
[46]27
28class DocumentEndToken(Token):
[51]29    id = '<document end>'
[46]30
[47]31class StreamEndToken(Token):
[51]32    id = '<stream end>'
[46]33
34class BlockSequenceStartToken(Token):
[51]35    id = '<block sequence start>'
[46]36
37class BlockMappingStartToken(Token):
[52]38    id = '<block mapping start>'
[46]39
40class BlockEndToken(Token):
[51]41    id = '<block end>'
[46]42
43class FlowSequenceStartToken(Token):
[51]44    id = '['
[46]45
46class FlowMappingStartToken(Token):
[51]47    id = '{'
[46]48
49class FlowSequenceEndToken(Token):
[51]50    id = ']'
[46]51
52class FlowMappingEndToken(Token):
[51]53    id = '}'
[46]54
55class KeyToken(Token):
[51]56    id = '?'
[46]57
58class ValueToken(Token):
[51]59    id = ':'
[46]60
[51]61class BlockEntryToken(Token):
62    id = '-'
[46]63
[51]64class FlowEntryToken(Token):
65    id = ','
66
[46]67class AliasToken(Token):
[51]68    id = '<alias>'
[46]69    def __init__(self, value, start_marker, end_marker):
70        self.value = value
71        self.start_marker = start_marker
72        self.end_marker = end_marker
73
74class AnchorToken(Token):
[51]75    id = '<anchor>'
[46]76    def __init__(self, value, start_marker, end_marker):
77        self.value = value
78        self.start_marker = start_marker
79        self.end_marker = end_marker
80
81class TagToken(Token):
[51]82    id = '<tag>'
[46]83    def __init__(self, value, start_marker, end_marker):
84        self.value = value
85        self.start_marker = start_marker
86        self.end_marker = end_marker
87
88class ScalarToken(Token):
[51]89    id = '<scalar>'
[46]90    def __init__(self, value, plain, start_marker, end_marker):
91        self.value = value
92        self.plain = plain
93        self.start_marker = start_marker
94        self.end_marker = end_marker
95
Note: See TracBrowser for help on using the repository browser.