On Monday, December 20, 2010, Nick Voronin <elfy...@gmail.com> wrote:

On Mon, 20 Dec 2010 10:26:16 +0100
"Johannes Pfau" <s...@example.com> wrote:

Hi,
I'm currently patching Ragel (http://www.complang.org/ragel/) to generate
D2 compatible code.

Interesting. Ragel-generated code works fine for me in D2. I suppose it mostly uses such a restricted C-like subset of language that it didn't change much from D1 to D2.
The most important change is const correctness. Because of that table based output didn't work with D2. And you couldn't directly pass const data (like string.ptr) to Ragel.

But if you are going to patch it, please make it add extra {} around action code! The thing is that when there is a label before {} block (and in ragel generated code I saw it's always so) the block isn't considered as a new scope which causes problems when you have local variables declaration inside actions.

You mean like this code:
---------------------------------
tr15:
#line 228 "jpf/http/parser.rl"
    {
        if(start != p)
        {
            key = line[(start - line.ptr) .. (p - line.ptr)];
        }
    }
---------------------------------
should become: ?
---------------------------------
tr15:
#line 228 "jpf/http/parser.rl"
    {{
        if(start != p)
        {
            key = line[(start - line.ptr) .. (p - line.ptr)];
        }
    }}
---------------------------------

One is fixed size array and other is dynamic. Honestly I doubt that it matters for code generated by Ragel, since this is constant and won't be passed around. If it's harder to make it fixed-size then don't bother.

Could a dynamic array cause heap allocations, even if it's data is never changed? If not, dynamic arrays would work fine.

--
Johannes Pfau

Reply via email to