Open jecisc opened 4 years ago
This should definitely work, I will look into this asap.
Indeed, there is no extension for ZnCharacaterStream
. But you can build your own stream on top of ZincStream:
| byteStream stream |
byteStream := ZnClient new
url: 'http://pharo.org';
streaming: true;
get.
stream := PP2CharacterStream on: byteStream encoder: ZnUTF8Encoder new.
^ PP2HtmlHeaderGrammar new optimize parse: stream
See PP2HtmlHeader class>>example
Which version of Pharo are you using? It seems there is an implementation of asPetit2Stream in Pharo 6.1:
ZnCharacterReadStream>>asPetit2Stream
^ PP2BufferStream on: self
As a workaround, consider creating your own PP2BufferStream on ZnCharacterReadStream by simply wrapping to PP2BufferStream
.
I also improved the documentation of PP2 related streams in https://github.com/kursjan/petitparser2/commit/1e20acad0febb34a798e9ac44404a83d300b17c9
I am on Pharo 8.
In the end I cannot use this feature but I was repporting it in case you want to add syntactic suggar.
In the doc it is written that PP now works on stream. I tried to parse a file but it failed. I suppose it is because file stream implementation of Pharo changed to use Zinc now.