source: branches/pyyaml3000/lib/yaml/events.py @ 51

Revision 51, 1.3 KB checked in by xi, 9 years ago (diff)

Parser is done. Add iterator interfaces for Scanner and Parser.

Line 
1
2class Event:
3    def __init__(self, start_marker, end_marker):
4        self.start_marker = start_marker
5        self.end_marker = end_marker
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)
13
14class NodeEvent(Event):
15    def __init__(self, anchor, tag, start_marker, end_marker):
16        self.anchor = anchor
17        self.tag = tag
18        self.start_marker = start_marker
19        self.end_marker = end_marker
20
21class AliasEvent(NodeEvent):
22    def __init__(self, name, start_marker, end_marker):
23        self.name = name
24        self.start_marker = start_marker
25        self.end_marker = end_marker
26
27class ScalarEvent(NodeEvent):
28    def __init__(self, anchor, tag, value, start_marker, end_marker):
29        self.anchor = anchor
30        self.tag = tag
31        self.value = value
32        self.start_marker = start_marker
33        self.end_marker = end_marker
34
35class CollectionEvent(NodeEvent):
36    pass
37
38class SequenceEvent(CollectionEvent):
39    pass
40
41class MappingEvent(CollectionEvent):
42    pass
43
44class CollectionEndEvent(Event):
45    pass
46
47class StreamEndEvent(Event):
48    pass
49
Note: See TracBrowser for help on using the repository browser.