source: pyyaml/trunk/lib/yaml/events.py @ 118

Revision 118, 1.4 KB checked in by xi, 9 years ago (diff)
  • Add the token STREAM-START.
  • Add parsing events: STREAM-START, DOCUMENT-START, DOCUMENT-END.
RevLine 
[51]1
2class Event:
[116]3    def __init__(self, start_mark, end_mark):
4        self.start_mark = start_mark
5        self.end_mark = end_mark
[51]6    def __repr__(self):
7        attributes = [key for key in self.__dict__
[116]8                if not key.endswith('_mark')]
[51]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):
[116]15    def __init__(self, anchor, start_mark, end_mark):
[51]16        self.anchor = anchor
[116]17        self.start_mark = start_mark
18        self.end_mark = end_mark
[51]19
20class AliasEvent(NodeEvent):
[53]21    pass
[51]22
23class ScalarEvent(NodeEvent):
[116]24    def __init__(self, anchor, tag, value, start_mark, end_mark):
[51]25        self.anchor = anchor
26        self.tag = tag
27        self.value = value
[116]28        self.start_mark = start_mark
29        self.end_mark = end_mark
[51]30
31class CollectionEvent(NodeEvent):
[116]32    def __init__(self, anchor, tag, start_mark, end_mark):
[53]33        self.anchor = anchor
34        self.tag = tag
[116]35        self.start_mark = start_mark
36        self.end_mark = end_mark
[51]37
38class SequenceEvent(CollectionEvent):
39    pass
40
41class MappingEvent(CollectionEvent):
42    pass
43
44class CollectionEndEvent(Event):
45    pass
46
[118]47class DocumentStartEvent(Event):
48    pass
49
50class DocumentEndEvent(Event):
51    pass
52
53class StreamStartEvent(Event):
54    pass
55
[51]56class StreamEndEvent(Event):
57    pass
58
Note: See TracBrowser for help on using the repository browser.