[ragel-users] recursion with ragel
Gaspard Bucher
gaspard at teti.ch
Tue Dec 2 12:50:41 UTC 2008
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
More information about the ragel-users
mailing list