All tests passed! Scanner and Parser seem to be correct.
[pyyaml/python3.git] / lib / yaml / stream.py
blob47f72a2581a08351435053ca9dc0df28f416dd7d
2 from marker import Marker
4 class Stream:
6 def __init__(self, source, data):
7 self.source = source
8 self.data = unicode(data, 'utf-8')+u'\0'
9 self.index = 0
10 self.line = 0
11 self.column = 0
13 def peek(self, k=1):
14 return self.data[self.index:self.index+k]
16 def read(self, k=1):
17 value = self.data[self.index:self.index+k]
18 for i in range(k):
19 if self.index >= len(self.data):
20 break
21 if self.data[self.index] in u'\r\n\x85\u2028\u2029':
22 self.line += 1
23 self.column = 0
24 else:
25 self.column += 1
26 self.index += 1
27 return value
29 def get_marker(self):
30 return Marker(self.source, self.data, self.index, self.line, self.column)