[ragel-users] getNextToken() : how to return ?
Maël Nison
nison.mael at gmail.com
Thu Jan 5 15:20:57 UTC 2012
Epic formatting fail. I hope it will be better this time. Sorry ..
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, after
the 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 not
compile), 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;
}
Additionally, I've seen in the documentation that getkey could be
employed to change the buffer input. Is there an example using
standard c++ istreams ?
--
Maël Nison
Epitech 2014, Paris - Astek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20120105/6cbdf01a/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