source: trunk/packages/pyyaml/lib/yaml/tokens.py @ 1675

Last change on this file since 1675 was 898, checked in by hartmans, 16 years ago

Add pyyaml and libyaml packages
backported from lenny.
There is discussion about how these should go in the repository; these are added in this form
in order to make forward progress.

File size: 2.5 KB
RevLine 
[898]1
2class 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)
13
14#class BOMToken(Token):
15#    id = '<byte order mark>'
16
17class 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
24
25class DocumentStartToken(Token):
26    id = '<document start>'
27
28class DocumentEndToken(Token):
29    id = '<document end>'
30
31class 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
38
39class StreamEndToken(Token):
40    id = '<stream end>'
41
42class BlockSequenceStartToken(Token):
43    id = '<block sequence start>'
44
45class BlockMappingStartToken(Token):
46    id = '<block mapping start>'
47
48class BlockEndToken(Token):
49    id = '<block end>'
50
51class FlowSequenceStartToken(Token):
52    id = '['
53
54class FlowMappingStartToken(Token):
55    id = '{'
56
57class FlowSequenceEndToken(Token):
58    id = ']'
59
60class FlowMappingEndToken(Token):
61    id = '}'
62
63class KeyToken(Token):
64    id = '?'
65
66class ValueToken(Token):
67    id = ':'
68
69class BlockEntryToken(Token):
70    id = '-'
71
72class FlowEntryToken(Token):
73    id = ','
74
75class 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
81
82class 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
88
89class 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
95
96class 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
104
Note: See TracBrowser for help on using the repository browser.