[ragel-users] getNextToken() : how to return ?

Maël Nison nison.mael at gmail.com
Thu Jan 5 15:18:59 UTC 2012


Hi,
I would like to write a very basic function taking a c++ char const
*&, and returning the first token type.The reference would imply that
the cstring pointer's target is, afterthe function call, the very next
character of the returned token.
Then I would be able to make :while ( token = getNextToken( foo ) )
std::cout << token << std::endl;
I've tried to use something like that (example, probably does
notcompile),  but the value of 'p' is not modified when
returning(infinite loop) :
#include "Token.hh"%%machine foo;%%write data;
int getNextToken( char const * & p ) {   %%{       foo = "foo";
main := |* foo => { return Foo; }; *|;   }%%;
   int cs;   int act;   char const * ts;   char const * te;   char const * eof;
   %% write init;   %% write exec noend;}
Additionnaly, I've seen in the documentation that getkey could
beemployed to change the buffer input. Is there an example
usingstandard c++ istreams ?

Thanks : )
-- 
Maël Nison
Epitech 2014, Paris - Astek

_______________________________________________
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