Ok, check. Good.

I'd like to wrap this up by thanking both of you. Kasper answered my question, but Nigel said what i needed to hear.

It turns out that i had confused processing one piece at a time with parsing one piece at a time.

I am quite fine with having the .repeat (list) approach and then just processing one item at a time.

I just say this as it may be a common issue, that confusion i mean.

So all is well, and per request:

I love that operator (infix ?) stuff

Torsten
Torsten Ruger <mailto:[email protected]>
9. toukokuuta 2014 23.06
Thanks Kasper,

that sounds exactly like what i am looking for. I'll check it out.

>constructing your own Parslet::Source.

And who can resist that: Create your own source! Call me Luke :-)



All messages here should end like this ;)

ps, Did you get the personal mail i sent you?

Torsten


regards,
kaspar

PS: I recently snuck 1.6 onto Rubygems. Didn't tell you guys about it,
but that's probably because I feel this is a small release with minor
changes.
Torsten Ruger <mailto:[email protected]>
9 May 2014 13:23
Thanks nigel,

that is a good description of how i also understood things to be.

And yes, i need what you call stream functionality.

So the question remains, how do i get Parslet to parse only a part of a file ?

Tosrten

Kaspar Schiess <mailto:[email protected]>
9. toukokuuta 2014 13.32
Heya,

Just a detail adding to what Nigel already said: What you might be
looking for is a prefix parse - one that parses only the valid prefix of
the input and that leaves the rest untouched. This would allow you to
consume one line at a time, transforming and processing, and then just
call the parser again.

Look for :prefix option on #parse and for various options around
constructing your own Parslet::Source.


All messages here should end like this ;)

regards,
kaspar

PS: I recently snuck 1.6 onto Rubygems. Didn't tell you guys about it,
but that's probably because I feel this is a small release with minor
changes.
Torsten Ruger <mailto:[email protected]>
9. toukokuuta 2014 13.23
Thanks nigel,

that is a good description of how i also understood things to be.

And yes, i need what you call stream functionality.

So the question remains, how do i get Parslet to parse only a part of a file ?

Tosrten

Nigel Thorne <mailto:[email protected]>
9. toukokuuta 2014 11.51
Oh I see.

It sounds like you want to parse your input as a stream instead of as a file. If not, then the answer is.. yes you parse the whole document at once. It isn't until the whole file has been matched against your grammar that you know the whole document is valid. I have not yet needed to write a parser with Parslet to process a stream. It would only be valuable for very large files.

By default a Parslet parser parses a whole document at a time into your parse tree. Parsing converts a text document into data structure that represents the meaning of the file. Once your data is in a tree structure you then traverse that tree in some way to "interpret" or "transform" the data into "behaviour" or some other data structure.

Does this make sense?

Cheers
Nigel







---
"Man, I'm going to have so many chickens when this lot hatch!"



Torsten Ruger <mailto:[email protected]>
9. toukokuuta 2014 11.09
Hi Nigel,

thank you, but that is not what i was asking. Maybe i was unclear.

In your example, let's say i do have lines. I understand your :doc, and how to parse many lines _at once_

But i want to parse one line at a time. Parse, do my processing, parse more, more processing until end of file.

I know how to loop through files. But obviously i can't split my input into files, as that involves parsing it.

Torsten

Reply via email to