[ragel-users] Acting when EOF

Iñaki Baz Castillo ibc at aliax.net
Tue Jan 27 10:40:09 UTC 2009


Hi, I've done a simple parser for a SIP URI ("sip:user at domain.org")
but I can't get the last field ("host"):

--------------------------------------------------------
%%{
	machine sip_uri;
	
	action _tag { mark_tag = p }
	action protocol { @uri.user = data[mark_tag..p-1].pack('c*') }
	action user { @uri.protocol = data[mark_tag..p-1].pack('c*') }
	action host { @uri.host = data[mark_tag..p-1].pack('c*') }
	
	protocol = ('sip'i|'sips'i) >_tag %protocol ;
	user = [a-zA-Z0-9]+ >_tag %user ;
	host = [.a-zA-Z0-9]+ >_tag %host ;

	main := protocol ':' user '@' host ;
}%%

run_machine "sip:user at domain.org"
-------------------------------------------------------

The actions "protocol" and "user" are executed, storing the parsed
data into a Ruby attribute, but the action "host" is not executed. I
assume this occurs because leaving action (%) doesn't take place but
EOF action. So I try to use a EOF action:

	host = [.a-zA-Z0-9]+ >_tag %/host ;

But it doesn't work. I can't imagine how to get this "host" field, any
help please?

Thanks a lot.

-- 
Iñaki Baz Castillo
<ibc at aliax.net>




More information about the ragel-users mailing list