[ragel-users] How to solve this Indetermination

Iñaki Baz Castillo ibc at aliax.net
Wed Feb 18 22:28:12 UTC 2009


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:xxxx at mydomain" I get this result:

-------------
Parsing 'sip:ibc:xxxx at mydomain'...
---host=ibc---          <-------- WRONG !!!
---userinfo=ibc:xxxx at ---
---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




More information about the ragel-users mailing list