[ragel-users] Re: Simple URL parser

Horacio Sanson hsan... at gmail.com
Sat May 24 15:09:34 UTC 2008

On Sat, May 24, 2008 at 3:24 AM, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
> Hey
> hsanson wrote:
>> 1 - If you see my code (attached) you will see I parse the scheme,
>> hostname, port and path parts of the URL using almost identical
>>      actions. The only difference is the variables used to store the
>> parsed strings. Is there a way to pass the actions some variables?
>>      So I can create a single function and pass the variable to store as
>> a parameter?
> Not currently, this is the single most requested feature for Ragel and
> I'm hoping to do something about it soon.
>> 2 - For some reason the last parsing never finishes. If I pass an URL
>> like "http://hostname" the parser gives me the scheme "http" but
>>      not the hostname. If I pass an URL like "http://hostname:8080" the
>> parser outputs the scheme and hostname but not the port. And if
>>      I provide a path like "http://hostname:8080/file.html" the parser
>> gives me all except for the path. As you see the last string never get's
>>      parsed and I don't know why??.
> If you're using 5.X (which you seem to be) then you should do one of the
> following:
> 1. Also embed the *_write actions as EOF actions and add a "write eof"
> following all the processing.
> 2. Send an additional character (such as 0) after the url.
> If you're using 6.X then just add "char *eof = pe;" after the
> declarations of p and pe.

Strange, I installed ragel 6.2 and tried your last recommendation (use
char *eof = pe) but I get the same behavior. The last write action
never gets executed....

BTW, this new version of ragel directly generates the C code (no xml
in between) is this correct behavior or am I doing something wrong??

>> 3 - Is there a better/cleaner way to do this??
> Looks good to me. One thing to be aware of is that RFCs are sometimes
> ambiguous so if you work directly from them you sometimes run into
> problems. See chapter four of the manual for more info on resolving
> ambiguities.
> -Adrian
> >

More information about the ragel-users mailing list