The null character is specified in the grammar.

On 13-10-15 06:27 PM, dinesh rtp wrote:
I have a struct,

typedef struct {
   char* start_add;
   char* end_add;
} string_def;

I used the example from the documentation,

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

%%{
    machine foo;
    main :=
         ( 'foo' | 'bar' )
         0 @{ res = 1; };
}%%

%% write data;


int main()
{
   int cs, res = 0;
char *p = "foo";
   char *pe = p + strlen(p) + 1;
   %% write init;
   %% write exec;
   printf("result = %i\n", res );
   return 0;
}

This works fine : " result = 1" is the output.

If I tweak this a little to work the way my struct is.

extern string_def new_string(char* str, int len) {
   string_def s;
   s.start_add = str;
   s.end_add = str + len;
   return s;
}

int main()
{
   string_def str = new_string("foo\0", 4); ==> Works
   // string_def str = new_string("foo", 3); ==> does not work, I WANT
THIS TO WORK
   int cs, res = 0;
   char *p = str.start_add;
   char *pe = str.end_add;
   %% write init;
   %% write exec;
   printf("result = %i\n", res );
   return 0;
}

Is ragel looking for a null character? How to override this behavior??


_______________________________________________
ragel-users mailing list
ragel-users@complang.org
http://www.complang.org/mailman/listinfo/ragel-users


_______________________________________________
ragel-users mailing list
ragel-users@complang.org
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to