[ragel-users] Re: two state machines

massimiliano cialdi cia... at gmail.com
Fri Jun 6 11:04:42 UTC 2008


On Fri, Jun 6, 2008 at 12:49 PM, Arne Goedeke <la... at laramies.com> wrote:
> In case you cannot put both state machines together.. I would put the
> second state-machine into a new function and call that one. Thats how
> I did the parsing of JSON (which has recursions).
and how can I put the second FSM in new function?

I would like to have something like this:

#include <string.h>
#include <stdio.h>
%%{
	machine FSM;
	
	FMS1 := ????          <- this parse a part of the string
	main := ????           <- this verify the string to match a pattern
and extract a substring to pass to FSM1
	
}%%
%% write data;


void parse(char *buf)
{
	int cs;
	char *p = buf;
	char *pe = p + strlen(p) + 1;
	char FN[16];

	%% write init;
	%% write exec;     <- main

	%% write exec;     <- FSM1
}

int main( int argc, char **argv )
{
	if ( argc > 1 ) {
		parse(argv[1]);
	}
	return 0;
}



otherwise what vcan I do and how? I need fgoto, fcall or other?

thanks
-- 
Et nunc, auxilium solis, vincam!
Oppugnatio solaris!
VIS!

Massimiliano Cialdi
cia... at gmail.com
massimiliano.cia... at powersoft.it



More information about the ragel-users mailing list