Am 12.11.2013 um 23:02 schrieb Sean P. DeNigris <s...@clipperadams.com>:
> Federico.Balaguer wrote >> Hello, >> >> I am developing a parser with PetitParser and one of the options I would >> like to try is to get my parser to read from an external stream (file) and >> produce the output to another external stream (another file) >> >> Is this possible? I found that Stream>>asPetitParser do this: >> asPetitStream >> ^ self contents asPetitStream >> >> Thanks! Federico > Reading from a stream is the normal way to use petit parser. On the output side it isn’t that easy. The parser builds a hierarchical structure with a lot of backtracking so writing sequentially to a stream needs eventually to be postponed until everything has been read. Producing the output immediately often has the drawback that it is hard to alter the stream in between. So the usual case will be that you make an object representation of your input format. Then you have a hierarchical object structure that you can write on an output stream. You could use the #printOn: method on all your model objects. Your task would then be accomplished by doing (MyParser parse: inputStream) printOn: outputStream hope this helps, Norbert