Hi, note this simple machine:

%%{

machine sip_uri;

action _start { start = p }
action _stop { stop = p-1 ; value = data[start..stop].pack('c*') ; }

action set_userinfo { @userinfo = value ; puts "---userinfo...@userinfo}---" }
action set_host { @host = value ; puts "---host...@host}---" }
action set_port { @port = value ; puts "---port...@port}---" }

user = [a-z]+ ;
password = [a-z]+ ;
userinfo = ( user ( ":" password )? "@" ) >_start %_stop %set_userinfo ;
host = [a-z]+ >_start %_stop %set_host ;
port = [0-9]+ >_start %_stop %set_port ;
uri = "sip:" userinfo? host ( ":" port )? ;
main := uri '\0' ;

}%%


When I parse:  "sip:ibc:x...@mydomain" I get this result:

-------------
Parsing 'sip:ibc:x...@mydomain'...
---host=ibc---          <-------- WRONG !!!
---userinfo=ibc:x...@---
---host=mydomain---

Finished: cs: 13  p: 22  pe: 22
Parsing OK !
-------------

I really don't know why 'host' is set twice. I know that it's due to ( ":" 
port )?. In case it doesn't exist in the grammar then 'host' is set just once 
(with 'ibc:xxxx' value).

Is there any trick to avoid this duplicate result? I've tryed everything I 
know with no success.

Thanks a lot foir any help.


-- 
Iñaki Baz Castillo

_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to