[ragel-users] [PATCH] D2 support

Johannes Pfau johannespfau at googlemail.com
Mon Dec 20 11:03:15 UTC 2010

I attached a patch to add D2 support to Ragel. D2 is quite different
from D1 so I created new D2 subclasses in the cd* files. I chose -E for
the commandline switch, but it could be changed to something else. D2
also needs a special syntax for const pointers: const(uint)* is a
mutable pointer to a const uint. I introduced a PTR_CONST_END function
to generate that D2 output. The generated D2 code is entirely correct
now and I tested it with some HTML header parsers.

There's one performance related problem though: In D2 a ubyte[] is
different from a ubyte[n], even if both arrays are initialized at
compile time. The ubyte[] generates a resizeable array at runtime, which
causes a performance problem. The ubyte[n] syntax should instead be used
for static constant arrays. But as ragel doesn't pass the number of
array entries to the OPEN_ARRAY function, there's no easy way to fix
that. So I wanted to ask for advice on how to implement that properly.

Johannes Pfau

-------------- next part --------------
A non-text attachment was scrubbed...
Name: d2.patch
Type: text/x-patch
Size: 18965 bytes
Desc: not available
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20101220/bbca977b/attachment-0001.bin>
-------------- next part --------------
ragel-users mailing list
ragel-users at complang.org

More information about the ragel-users mailing list