[ragel-users] Problem with long alphabet type

Adrian Thurston thurs... at cs.queensu.ca
Thu Sep 13 15:19:16 UTC 2007


Hi,

Semantic conditions don't work with the long type. If this isn't already
documented somewhere it should be. Also, there should be an error
emitted. Sorry about that.

The semantic condition feature requires that Ragel be able to allocate
characters from the alphabet space. Ragel uses these allocated
characters to express "character c with cond1 true" or "c with cond1
false." But internally Ragel uses longs to store characters and so if
your alphabet type is long there is no more room left in the alphabet
space to allocate from.

Adrian

Elmin wrote:
> Hi,
> 
> I'm working on a project where I need to run tests on Unicode code
> points -- my idea was to decode them from UTF-8 first, then store them
> in an array of long integers and run that array through the FSM to
> validate/parse it.  I'm using semantic conditions to check the
> categories of the symbols.  The problem is that when I set the
> alphabet type to "long" or "unsigned long" I get compiler warnings:
> 
> longtest.c:109: warning: this decimal constant is unsigned only in ISO
> C90
> longtest.c:109: warning: this decimal constant is unsigned only in ISO
> C90
> longtest.rl:9: warning: integer constant is too large for 'long' type
> 
> Also, the FSMs don't seem to work as expected.  Here's the sample
> program I wrote to isolate the issue somewhat, which is pretty similar
> to the semantic conditions example from the guide:
> 
> #include <stdio.h>
> 
> %%{
>   machine longtest;
> 
> action rec_num { i = 0; n = fc-'0'; }
> action test_len { i++ < n }
>   main := (
> 'd'
> [0-9] @rec_num
> ':'
> ( [a-z] when test_len )*
> )**;
> 
>   write data;
> }%%
> 
> int main(int argc, char *argv[])
> {
>   long data[] = {'d', '2', ':', 'c', 'z'};
>   long *p = data, *pe = data+5;
>   int cs, i, n;
> 
>   %% write init;
>   %% write exec;
> 
>   if (cs == longtest_error && *p != 0)
>     {
>       printf("Error: %i\n", (int)*p);
>     }
>   else
>     printf("No Error!\n");
> 
>   return 0;
> }
> 
> It should print "No Error!"  It does, if the alphabet type is set to
> anything smaller than "long", but in the form above it always prints
> "Error: 99" -- anyone have any ideas?  It almost seems like Ragel is
> using the wrong limits or something.  This is on OS X 10.4 on PPC, and
> I saw the same behavior with Ragel versions 5.19 and 5.23.  The
> compiler is GCC 4.0.1.
> 
> Thanks,
> Elmin
> 
> 
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "ragel-users" group.
> To post to this group, send email to ragel-users at googlegroups.com
> To unsubscribe from this group, send email to ragel-users-unsubscribe at googlegroups.com
> For more options, visit this group at http://groups.google.com/group/ragel-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20070913/c5c3971a/attachment-0001.sig>


More information about the ragel-users mailing list