So I had to look this one up too, but from the documentation: 6.7 Parsing Recursive Language Structures In general Ragel cannot handle recursive structures because the grammar is interpreted as a regular language. However, depending on what needs to be parsed it is sometimes practical to implement the recursive parts using manual coding techniques. This often works in cases where the recursive structures are simple and easy to recognize, such as in the balancing of parentheses One approach to parsing recursive structures is to use actions that increment and decrement counters or otherwise recognize the entry to and exit from recursive structures and then jump to the appropriate machine defnition using fcall and fret. Alternatively, semantic conditions can be used to test counter variables. A more traditional approach is to call a separate parsing function (expressed in the host lan- guage) when a recursive structure is entered, then later return when the end is recognized.
Hope this helps. On Tue, Mar 29, 2011 at 4:15 PM, Gordeev Vladimir < [email protected]> wrote: > Hi everyone, > > Actually I just started to work with Ragel and probably don't understand > right the concept. > > I'm trying to write parser for toy programming language. All was ok, before > I mess with recursive > definitions. > > I want to read lisp-like expressions, e.g. ((((one)) (two)) three), and try > to write recursive definition for it. > > the same at gist: https://gist.github.com/893142 > > %%{ > machine lisp; > integer = '-'? . ('0'|[1-9][0-9]*); > string = '"' . (any - '"') . '"'; > list = '(' . (integer|string|list)* . ')'; > main := list; > }%% > %% write data; > %% write init; > %% write exec; > > > So I got following error: > > test.rl:7:32: graph lookup of "list" failed > > So, the question is: How to define parser for such language. > > Yea, sorry my bad English. > > _______________________________________________ > ragel-users mailing list > [email protected] > http://www.complang.org/mailman/listinfo/ragel-users >
_______________________________________________ ragel-users mailing list [email protected] http://www.complang.org/mailman/listinfo/ragel-users
