Hello,

Including files does not seem to work properly on Ragel compiled for Windows using mingw.

Everything works fine with both files in the same directory:

C:\Documents and Settings\jose>w:\ragel-6.3\ragel\ragel.exe atoi-actions.rl

Move one of the files into a  subdirectory:

C:\Documents and Settings\jose>move atoi-machine.rl subdir

Ragel complains correctly if we forget to add the subdirectory to the search path:

C:\Documents and Settings\jose>w:\ragel-6.3\ragel\ragel.exe atoi-actions.rl
atoi-actions.rl:20:27: include: failed to locate file
atoi-actions.rl:20:27: include: attempted: "atoi-machine.rl"


However, if we do add the directory to the search path, ragel finds the file but fails to import anything from it!

C:\Documents and Settings\jose>w:\ragel-6.3\ragel\ragel.exe -Isubdir atoi-actions.rl atoi-actions.rl:22:2: write statement given but there are no machine instantiations


I suspect this is an MinGW bug as it's not reproducible on Mac OS X. I figured people might want to know anyway, since MinGW is listed on the home page as an option.

Saludos,
Jose.
/*
 * Convert a string to an integer.
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

%%{
        machine atoi;

        action see_neg {
                neg = true;
        }

        action add_digit { 
                val = val * 10 + (fc - '0');
        }

        include "atoi-machine.rl";

        write data;
}%%

long long atoi( char *str )
{
        char *p = str, *pe = str + strlen( str );
        int cs;
        long long val = 0;
        bool neg = false;

        %% write init;
        %% write exec;

        if ( neg )
                val = -1 * val;

        if ( cs < atoi_first_final )
                fprintf( stderr, "atoi: there was an error\n" );

        return val;
};


#define BUFSIZE 1024

int main()
{
        char buf[BUFSIZE];
        while ( fgets( buf, sizeof(buf), stdin ) != 0 ) {
                long long value = atoi( buf );
                printf( "%lld\n", value );
        }
        return 0;
}

%%{
        machine atoi;

        main := ( '-'@see_neg | '+' )? ( digit @add_digit )+ 
                ( '-'@see_neg | '+' )? ( digit @add_digit )+ '\n';
}%%
_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to