Parsing From Ring Buffers

William Ahern will... at 25thandClement.com
Fri Aug 1 00:13:20 UTC 2008


Cursorily looking at the generated code, it appears to be deceptively easy
to turn `p', `pe', and `eof' into indexes, rather than pointers, given the
`fpc' macro. Perhaps by simply adding a second macro to increment and
decrement the index?

Am I missing anything that would throw a monkey wrench into such a patch?
This could make scanners more efficient, because there would be no need to
use memmove().

It might even work without a patch, but technically it's undefined behavior
in C to derive pointer values outside arrays or malloc'd blocks. Compilers
like TinyCC have the ability to catch such errors, which can be useful when
tracking down bugs. But to keep from having to re-adjust `ts' and `te', and
so that Ragel sees a linear input space during scanning, the indexing would
have to extend beyond the ring buffer (and fpc would just be a simple
modulus operation).



More information about the ragel-users mailing list