Eleanor McHugh
3/16/2008 1:30:00 AM
On 15 Mar 2008, at 23:21, I=F1aki Baz Castillo wrote:
> Hi, I'm new in this maillist so hello to all.
>
> I want to do a SIP protocol parser in Ruby (SIP protocol is very =20
> similar to
> HTTP) so I'm looking for the most appropiate parser in Ruby. Also, =20
> it's the
> first time I try to do something like this so I need first lot of =20
> doc reading
> (yacc, lex, LARL, LL, BNF...).
>
> I'd just like to know with parser is a good option for my purpose =20
> since I've
> found "too much" of them:
>
> - rex
> - ruby-lex
> - racc
> - ruby-yacc
> - coco-rb
> - TreeTop
> - Ragel
>
> For now I don't look for the fastest and most efficient parser, =20
> maybe just for
> the easiest one. I will read those days about Yacc and Lex since I =20
> assume
> they are the base of all of them, and I know that typically Yacc is =20=
> used in
> conjunction with Lex so:
> If I choose Racc, will I need Rex?
> If I choose Ruby-Yacc, will I need Ruby-Lex?
> Note that I want to get Ruby code, not C, C++ or others.
>
> My purpose is just receiving SIP requests (similar to HTTP requests) =20=
> and parse
> them (maybe into Ruby objects) to work with them (implement a SIP =20
> stack).
>
> They are lots of options and I'm getting a little "lost" with so =20
> many doc to
> read. Any orientation please?
The SIP protocol is in principle simple enough that you could probably =20=
get by rolling your own custom parser by hand. My colleague =20
implemented a console-driven SIP stack this way and whilst the code is =20=
inefficient compared to a table-driven parser it's eminently more =20
readable.
However if you do want to go down the parser-generator route for =20
performance reasons then look at the Ragel parser in Mongrel as that's =20=
very efficient and highly conformant with the HTTP RFC specs (given =20
some of the boundary cases in SIP conformance is probably high on your =20=
list of priorities). As far as I'm aware Ragel produces parsers in C, =20=
but the Mongrel code will show you how to turn that into a Ruby native =20=
extension.
Ellie
Eleanor McHugh
Games With Brains
----
raise ArgumentError unless @reality.responds_to? :reason