1

Topic: Analysis of a flow of messages from the HTTP-answer in the browser

Hello. Advise, please, generators of parcers for JavaScript in the browser that following requirements could be fulfilled: the Parcer should be able to work in a streaming mode and not to demand all document before the analysis beginning. The reason: it is expected arrivals of parts of the document asynchronously through XMLHttpRequest.onprogress. It is important, that each part of the document arriving on an input to a parcer, did not break a parcer state as it is expected that in the part which have come from XMLHttpRequest.onprogress can be and a part of the current message, and the end previous and the following beginning (i.e., the server can not guarantee an accurate fragmentation of messages in a flow). The parcer should be able to work with messages indulgently (approximately as Gson for Java and its lenient-mode): i.e., to be able to understand that in a current part of a flow some message is already completed and the new can begin. Proceeding from last, it is necessary, that the parcer was able to "forget" the processed messages, instead of accumulated them. I.e. was able to organize some kind of queue. Perhaps something forgot. The flow broken into the messages in format Server Sent Events is expected, but to use EventSource or  there is no possibility. From with what had possibility while to work, I can name nearley.js and PEG.js. nearley.js item 1 (there is a method feed) and even somewhat item 2, but not able item 3 and item 4 is able, at least. Besides, nearley.js for ambiguous  does the full search of all possible variants that very badly affects productivity. PEG.js, on the contrary, offers the first best variant, but if I am not mistaken, generally anything from subitem 1-4 is not able. Thanks.

2

Re: Analysis of a flow of messages from the HTTP-answer in the browser

Understood. Casually noted in the documentation that PEG.js, with the help - trace, allows to create a follow-up parcer. They can process events of analysis of a flow, receiving the information on the rule, result of its analysis and character range in assorted input. It is enough of it to organize reading from  with which it is possible to fill asynchronously. At each addition of the content  it is necessary simply to try to disassemble leaking  about an interesting rule and result, and if those are to produce convolution  "to the left" on an amount of the characters necessary for successful analysis of a rule. All thanks.