[ragel-users] Split ragel source files to several and include one to other

Oleg Tsarev zabivator at gmail.com
Tue Feb 15 10:54:04 UTC 2011


Hello guys,

I try to use ragel in the open-source project "Percona-Playback":
https://code.launchpad.net/~tsarev/percona-playback/alpha
Ragel is great compliant to my targets.

But I have trouble what can't solve and documentation not answer to my
question.
So I read parts 2.1.4, but don't understand how its work

Suppose I have one machine (thread_id.rl file):
{{%
    machine thread_id;
    action thread_id_begin { thread_id= 0; }
    action thread_id_step  { thread_id= thread_id * 10 + (fc - '0'); }
    action thread_id_end   { set_thread_id(thread_id); }
    key   = 'Thread_id: ';
    value = ([0-9] @thread_id_step;)+ %thread_id_end;
    main := (key @thread_id_begin) . value;
%}}

Now i want two things:
1) Write unit test to this machine
2) Use this machine to another, more complex machine.

I tried to include this machine in another file:
%%{
    machine thread_id_test;
    error = [^\n]* '\n'
      >{ std::cout << "start skip: '"; }
      ${ std::cout << fc; }
      @{ std::cout < "'\n" << std::flush; fgoto main; };
    thread_id= include thread_id "../../src/parser/thread_id.rl";
    main := (thread_id | error)*;
    write data;
}%%

but receive error:
[ 69%] Generating thread_id_test.cc
/storage/project/playback/head/test/parser/thread_id_test.rl:39:10: at token
TK_ColonEquals: parse error

I tried another way:
%%{
    machine thread_id_test;
    include thread_id "../../src/parser/thread_id.rl";
    error = [^\n]* '\n'
      >{ std::cout << "start skip: '"; }
      ${ std::cout << fc; }
      @{ std::cout < "'\n" << std::flush; fgoto main; };
    main := (thread_id | error)*;
    write data;
}%%

but get another error:
[ 69%] Generating thread_id_test.cc
/storage/project/playback/head/test/parser/thread_id_test.rl:39:14: graph
lookup of "thread_id" failed

Thank you very much for any help.

Best regards, Oleg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20110215/331fbecb/attachment-0001.html>
-------------- next part --------------
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users


More information about the ragel-users mailing list