[ragel-users] recursion with ragel

Adrian Thurston thurston at complang.org
Tue Dec 2 14:51:26 UTC 2008


Hi Gaspard,

You can find the old messages in the archive of the new list. I imported
the messages from google groups. We just need the search engines to
catch on.

-Adrian

Gaspard Bucher wrote:
> Hi list !
> 
> I am sure this question has been answered a thousand times, but I
> could not find the list archives (all pages from google point to
> "group not found").
> 
> Anyway: I am implementing a json like parser and want to use recursion:
> 
> This is what I want to parse:
> "{ url:'foo' opts:{ bar:4.5 }}"
> 
> To cope with the hash in the hash, I want to open a new parser after each key:
> 
> "{ url:" ===> new parser with "'foo' opts:{ bar:4.5 }}", returns
> number of eaten chars
> 
> I then want to update the position of *p. This is the code:
> 
> action hash_value {
>   p++;
>   p += tmp_val.from_string(p);
>   tmp_h.set(key, tmp_val);
>   key = "";
> }
> 
> My problem: closing '}' is not parsed correctly and then "@hash" is
> never executed.
> 
> Regex:
>   ...
>   hash      = '{' (ws* string ':' >hash_value)* ws* '}';
>   main     := ws* (string @string | number @number | hash @hash);
> 
> Many thanks for your help !
> 
> Gaspard
> 
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users




More information about the ragel-users mailing list