[ragel-users] Re: Matching characters written as hex codes

Adrian Thurston thurs... at cs.queensu.ca
Mon Jun 2 00:44:05 UTC 2008


That's odd, everything works fine for me, even graphviz (2.12). Running
it I get:

Got BOM UTF16 be

What kind of machine architecture and OS are you on?

-Adrian

Macy wrote:
> 
> 
> On Jun 1, 10:13 pm, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
>> Macy wrote:
>>> bom = 0xFE 0xFF @{ fprintf(stderr, "\nGot BOM UTF16"); };  -> doesn't
>>> match
>> This one should work.
>>
> 
> This example doesn't work for me. Perhaps I'm doing something wrong...
> 
> -------------
> (begin)-----------------------------------------------------
> #include <stdio.h>
> 
> %%{
> 
> machine test;
> 
> action error { fprintf(stderr,"\nError!\n"); }
> bom_utf16_le = 0xFE 0xFF @{ fprintf(stderr, "\nGot BOM UTF16 le"); };
> bom_utf16_be = 0xFF 0xFE @{ fprintf(stderr, "\nGot BOM UTF16 be"); };
> 
> }%%
> 
> int main()
> {
> 	int cs;
> 	char* buf = "\xFF\xFE";
> 	char* p = buf;
> 	char* pe = buf + 2;
> 	char* eof = pe;
> 
> 	%%{
> 		write data;
> 		write init;
> 		main := (bom_utf16_le | bom_utf16_be) $err(error);
> 		write exec;
> 	}%%
> 
>     return 0;
> }
> -------------
> (end)-----------------------------------------------------
> 
> $ ragel -C test.rl && gcc test.c -o test && ./test
> 
> Error!
> $
> 
> rlgen-dot doesn't work for some reason, it crashes.
> 
> $ ragel -x test.rl > test.xml && rlgen-dot test.xml
> digraph test {
>         rankdir=LR;
>         node [ shape = point ];
>         ENTRY;
>         en_1;
>         eof_1;
>         eof_2;
>         eof_3;
>         node [ shape = circle, height = 0.2 ];
>         err_1 [ label=""];
>         err_2 [ label=""];
>         err_3 [ label=""];
>         err_4 [ label=""];
>         node [ fixedsize = true, height = 0.65, shape =
> doublecircle ];
>         4;
>         node [ shape = circle ];
> Segmentation fault (core dumped)
> 
> $ gdb `which rlgen-dot` core
> [.............]
> [New process 18840]
> #0  0x0000000000404474 in Key (this=0x7fffc4b4b5d0, key=@0x0) at ../
> common/common.h:52
> 52      ../common/common.h: No such file or directory.
>         in ../common/common.h
> (gdb) bt
> #0  0x0000000000404474 in Key (this=0x7fffc4b4b5d0, key=@0x0) at ../
> common/common.h:52
> #1  0x000000000040311b in GraphvizDotGen::ONCHAR (this=0x1b6e270,
> lowKey=@0x7fffc4b4b850, highKey=@0x7fffc4b4b840) at gvdotgen.cpp:136
> #2  0x0000000000403924 in GraphvizDotGen::writeTransList
> (this=0x1b6e270, state=0x1b6ea68) at gvdotgen.cpp:188
> #3  0x0000000000404015 in GraphvizDotGen::writeDotFile
> (this=0x1b6e270) at gvdotgen.cpp:284
> #4  0x00000000004043e3 in GraphvizDotGen::finishRagelDef
> (this=0x1b6e270) at gvdotgen.cpp:325
> #5  0x0000000000412ea7 in Parser::parseLangEl (this=0x7fffc4b4d1d0,
> type=195, token=0x7fffc4b4c0d0) at xmlparse.kl:132
> #6  0x00000000004159ff in Parser::token (this=0x7fffc4b4d1d0,
> tokenId=195, tok=@0x7fffc4b4c0d0) at xmlparse.kl:960
> #7  0x0000000000415b0d in Parser::token (this=0x7fffc4b4d1d0,
> tokenId=195, col=1, line=84) at xmlparse.kl:972
> #8  0x0000000000410f47 in xml_parse (input=@0x1b68010,
> fileName=0x7fffc4b4ec8e "test.xml", outputActive=false,
> wantComplete=false) at xmlscan.rl:265
> #9  0x0000000000402821 in main (argc=2, argv=0x7fffc4b4d488) at
> main.cpp:225
> 
> $ ragel -v
> Ragel State Machine Compiler version 6.2 March 2008
> Copyright (c) 2001-2007 by Adrian Thurston
> 
> 
> Any ideas?
> > 
> 



More information about the ragel-users mailing list