Lines Matching refs:stream

15         stream = antlr3.StringStream('foo')
17 self.failUnlessEqual(stream.size(), 3)
23 stream = antlr3.StringStream('foo')
25 self.failUnlessEqual(stream.index(), 0)
31 stream = antlr3.StringStream('foo\nbar')
33 stream.consume() # f
34 self.failUnlessEqual(stream.index(), 1)
35 self.failUnlessEqual(stream.charPositionInLine, 1)
36 self.failUnlessEqual(stream.line, 1)
38 stream.consume() # o
39 self.failUnlessEqual(stream.index(), 2)
40 self.failUnlessEqual(stream.charPositionInLine, 2)
41 self.failUnlessEqual(stream.line, 1)
43 stream.consume() # o
44 self.failUnlessEqual(stream.index(), 3)
45 self.failUnlessEqual(stream.charPositionInLine, 3)
46 self.failUnlessEqual(stream.line, 1)
48 stream.consume() # \n
49 self.failUnlessEqual(stream.index(), 4)
50 self.failUnlessEqual(stream.charPositionInLine, 0)
51 self.failUnlessEqual(stream.line, 2)
53 stream.consume() # b
54 self.failUnlessEqual(stream.index(), 5)
55 self.failUnlessEqual(stream.charPositionInLine, 1)
56 self.failUnlessEqual(stream.line, 2)
58 stream.consume() # a
59 self.failUnlessEqual(stream.index(), 6)
60 self.failUnlessEqual(stream.charPositionInLine, 2)
61 self.failUnlessEqual(stream.line, 2)
63 stream.consume() # r
64 self.failUnlessEqual(stream.index(), 7)
65 self.failUnlessEqual(stream.charPositionInLine, 3)
66 self.failUnlessEqual(stream.line, 2)
68 stream.consume() # EOF
69 self.failUnlessEqual(stream.index(), 7)
70 self.failUnlessEqual(stream.charPositionInLine, 3)
71 self.failUnlessEqual(stream.line, 2)
73 stream.consume() # EOF
74 self.failUnlessEqual(stream.index(), 7)
75 self.failUnlessEqual(stream.charPositionInLine, 3)
76 self.failUnlessEqual(stream.line, 2)
82 stream = antlr3.StringStream('foo')
84 stream.consume()
85 stream.consume()
87 stream.reset()
88 self.failUnlessEqual(stream.index(), 0)
89 self.failUnlessEqual(stream.line, 1)
90 self.failUnlessEqual(stream.charPositionInLine, 0)
91 self.failUnlessEqual(stream.LT(1), 'f')
97 stream = antlr3.StringStream('foo')
99 self.failUnlessEqual(stream.LT(1), 'f')
100 self.failUnlessEqual(stream.LT(2), 'o')
101 self.failUnlessEqual(stream.LT(3), 'o')
103 stream.consume()
104 stream.consume()
106 self.failUnlessEqual(stream.LT(1), 'o')
107 self.failUnlessEqual(stream.LT(2), antlr3.EOF)
108 self.failUnlessEqual(stream.LT(3), antlr3.EOF)
114 stream = antlr3.StringStream('foobar')
116 self.failUnlessEqual(stream.substring(0, 0), 'f')
117 self.failUnlessEqual(stream.substring(0, 1), 'fo')
118 self.failUnlessEqual(stream.substring(0, 5), 'foobar')
119 self.failUnlessEqual(stream.substring(3, 5), 'bar')
125 stream = antlr3.StringStream('foo\nbar')
127 stream.seek(4)
129 self.failUnlessEqual(stream.index(), 4)
130 self.failUnlessEqual(stream.line, 2)
131 self.failUnlessEqual(stream.charPositionInLine, 0)
132 self.failUnlessEqual(stream.LT(1), 'b')
153 stream = antlr3.StringStream('foo\nbar')
155 stream.seek(4)
157 marker = stream.mark()
159 self.failUnlessEqual(stream.markDepth, 1)
161 stream.consume()
162 marker = stream.mark()
164 self.failUnlessEqual(stream.markDepth, 2)
170 stream = antlr3.StringStream('foo\nbar')
172 stream.seek(4)
173 marker1 = stream.mark()
175 stream.consume()
176 marker2 = stream.mark()
178 stream.release()
179 self.failUnlessEqual(stream.markDepth, 1)
182 stream.release()
183 self.failUnlessEqual(stream.markDepth, 1)
189 stream = antlr3.StringStream('foo\nbar')
191 stream.seek(4)
192 marker1 = stream.mark()
194 stream.consume()
195 marker2 = stream.mark()
197 stream.consume()
198 marker3 = stream.mark()
200 stream.release(marker2)
201 self.failUnlessEqual(stream.markDepth, 1)
207 stream = antlr3.StringStream('foo\nbar')
209 stream.seek(4)
211 marker = stream.mark()
212 stream.consume()
213 stream.consume()
215 stream.rewind()
216 self.failUnlessEqual(stream.markDepth, 0)
217 self.failUnlessEqual(stream.index(), 4)
218 self.failUnlessEqual(stream.line, 2)
219 self.failUnlessEqual(stream.charPositionInLine, 0)
220 self.failUnlessEqual(stream.LT(1), 'b')
226 stream = antlr3.StringStream('foo\nbar')
228 stream.seek(4)
229 marker1 = stream.mark()
231 stream.consume()
232 marker2 = stream.mark()
234 stream.consume()
235 marker3 = stream.mark()
237 stream.rewind(marker2)
238 self.failUnlessEqual(stream.markDepth, 1)
239 self.failUnlessEqual(stream.index(), 5)
240 self.failUnlessEqual(stream.line, 2)
241 self.failUnlessEqual(stream.charPositionInLine, 1)
242 self.failUnlessEqual(stream.LT(1), 'a')
252 stream = antlr3.FileStream(path)
254 stream.seek(4)
255 marker1 = stream.mark()
257 stream.consume()
258 marker2 = stream.mark()
260 stream.consume()
261 marker3 = stream.mark()
263 stream.rewind(marker2)
264 self.failUnlessEqual(stream.markDepth, 1)
265 self.failUnlessEqual(stream.index(), 5)
266 self.failUnlessEqual(stream.line, 2)
267 self.failUnlessEqual(stream.charPositionInLine, 1)
268 self.failUnlessEqual(stream.LT(1), 'a')
269 self.failUnlessEqual(stream.LA(1), ord('a'))
275 stream = antlr3.FileStream(path, 'utf-8')
277 stream.seek(4)
278 marker1 = stream.mark()
280 stream.consume()
281 marker2 = stream.mark()
283 stream.consume()
284 marker3 = stream.mark()
286 stream.rewind(marker2)
287 self.failUnlessEqual(stream.markDepth, 1)
288 self.failUnlessEqual(stream.index(), 5)
289 self.failUnlessEqual(stream.line, 2)
290 self.failUnlessEqual(stream.charPositionInLine, 1)
291 self.failUnlessEqual(stream.LT(1), u'ä')
292 self.failUnlessEqual(stream.LA(1), ord(u'ä'))
302 stream = antlr3.InputStream(file)
304 stream.seek(4)
305 marker1 = stream.mark()
307 stream.consume()
308 marker2 = stream.mark()
310 stream.consume()
311 marker3 = stream.mark()
313 stream.rewind(marker2)
314 self.failUnlessEqual(stream.markDepth, 1)
315 self.failUnlessEqual(stream.index(), 5)
316 self.failUnlessEqual(stream.line, 2)
317 self.failUnlessEqual(stream.charPositionInLine, 1)
318 self.failUnlessEqual(stream.LT(1), 'a')
319 self.failUnlessEqual(stream.LA(1), ord('a'))
325 stream = antlr3.InputStream(file, 'utf-8')
327 stream.seek(4)
328 marker1 = stream.mark()
330 stream.consume()
331 marker2 = stream.mark()
333 stream.consume()
334 marker3 = stream.mark()
336 stream.rewind(marker2)
337 self.failUnlessEqual(stream.markDepth, 1)
338 self.failUnlessEqual(stream.index(), 5)
339 self.failUnlessEqual(stream.line, 2)
340 self.failUnlessEqual(stream.charPositionInLine, 1)
341 self.failUnlessEqual(stream.LT(1), u'ä')
342 self.failUnlessEqual(stream.LA(1), ord(u'ä'))
375 stream = antlr3.CommonTokenStream(self.source)
376 self.failUnlessEqual(stream.index(), -1)
382 stream = antlr3.CommonTokenStream(None)
383 stream.setTokenSource(self.source)
384 self.failUnlessEqual(stream.index(), -1)
385 self.failUnlessEqual(stream.channel, antlr3.DEFAULT_CHANNEL)
391 stream = antlr3.CommonTokenStream(self.source)
393 lt1 = stream.LT(1)
404 stream = antlr3.CommonTokenStream(self.source)
406 lt1 = stream.LT(1)
421 stream = antlr3.CommonTokenStream(self.source)
423 lt1 = stream.LT(1)
438 stream = antlr3.CommonTokenStream(self.source)
440 lt1 = stream.LT(2)
456 stream = antlr3.CommonTokenStream(self.source)
457 stream.fillBuffer()
458 stream.consume()
460 lt1 = stream.LT(-1)
475 stream = antlr3.CommonTokenStream(self.source)
476 stream.fillBuffer()
477 stream.consume()
479 self.failUnlessEqual(stream.LB(1).type, 12)
493 stream = antlr3.CommonTokenStream(self.source)
495 lt1 = stream.LT(0)
518 stream = antlr3.CommonTokenStream(self.source)
519 self.failUnless(stream.LB(1) is None)
521 stream.consume()
522 stream.consume()
523 self.failUnless(stream.LB(3) is None)
545 stream = antlr3.CommonTokenStream(self.source)
546 stream.fillBuffer()
548 self.failUnlessEqual(len(stream.tokens), 3)
549 self.failUnlessEqual(stream.tokens[0].type, 12)
550 self.failUnlessEqual(stream.tokens[1].type, 13)
551 self.failUnlessEqual(stream.tokens[2].type, 14)
569 stream = antlr3.CommonTokenStream(self.source)
570 self.failUnlessEqual(stream.LA(1), 12)
572 stream.consume()
573 self.failUnlessEqual(stream.LA(1), 13)
575 stream.consume()
576 self.failUnlessEqual(stream.LA(1), antlr3.EOF)
578 stream.consume()
579 self.failUnlessEqual(stream.LA(1), antlr3.EOF)
597 stream = antlr3.CommonTokenStream(self.source)
598 self.failUnlessEqual(stream.LA(1), 12)
600 stream.seek(2)
601 self.failUnlessEqual(stream.LA(1), antlr3.EOF)
603 stream.seek(0)
604 self.failUnlessEqual(stream.LA(1), 12)
622 stream = antlr3.CommonTokenStream(self.source)
623 stream.fillBuffer()
625 stream.consume()
626 marker = stream.mark()
628 stream.consume()
629 stream.rewind(marker)
631 self.failUnlessEqual(stream.LA(1), 13)
653 stream = antlr3.CommonTokenStream(self.source)
655 assert stream.toString() == "foobargnurzblarz"
656 assert stream.toString(1, 2) == "bargnurz"
657 assert stream.toString(stream.tokens[1], stream.tokens[-2]) == "bargnurz"