[ragel-users] How to process a block of random sized data

thurston at colm.net thurston at colm.net
Thu Nov 1 10:08:55 UTC 2018


That's what the pre exec and post exec functions are for. Call them on either side of the write-exec of your ragel program. 




Get Outlook for Android







On Thu, Nov 1, 2018 at 10:27 AM -0300, "Ming Fu" <Ming.Fu at esentire.com> wrote:




















Hi Adrian,


 


I was worried about the case when the input is not in contiguous memory. I will need to call the finish when the input is at the end
 of a block and restart class at the beginning of next block. Is there a way to know the current *p is the last byte of a block?


 


Thanks


Ming


 




From: Adrian Thurston <thurston at colm.net>


Sent: November 1, 2018 7:53 AM

To: ragel-users at colm.net

Cc: Ming Fu <Ming.Fu at esentire.com>

Subject: Re: [ragel-users] How to process a block of random sized data




 


Hi Ming,


Ragel has no support for this built in. I use a class for this that tracks the start of the interesting input and flushes it out when necessary. The start and finish functions are called from
 ragel actions. The preExec and postExec functions are called before and after the ragel write exec. See attached example.


In my uses I expand it to include start and finish functions on the expensive thing (also a stream processor), and I can also pause it to skip over some data that shouldn't go to expensive thing.


I've often thought about building this support into ragel, but once you've got the class made it's super easy to reuse it in many different cases.


Regards,


 Adrian


On 2018-10-31 16:48, Ming Fu wrote:




Hi,


 


I have the following ragel rule:


 


any* $(


                Some_expensive_call(*p)


}


 


However, I do not necessary have to make the some_expensive_call per input char, I can call some_less_expensive_call(*p,
 len) to be more efficient.


How do I figure out the len and adjust pe. Consider the input may not be in contiguous memory block.


 


Thanks,


Ming



 
_______________________________________________
ragel-users mailing list
ragel-users at colm.net
http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users









-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20181101/8ebc0a95/attachment.html>


More information about the ragel-users mailing list