Added a section on recursion.
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Thu, 21 Jun 2007 00:02:01 +0000 (00:02 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Thu, 21 Jun 2007 00:02:01 +0000 (00:02 +0000)
git-svn-id: http://svn.complang.org/ragel/trunk@255 052ea7fc-9027-0410-9066-f65837a77df0

doc/ragel-guide.tex

index 7dc0e4a..946c88d 100644 (file)
@@ -3528,4 +3528,22 @@ cautious of combining the resulting machine with another in such a way that the
 transition on which the current position is adjusted is not combined with a
 transition from the other machine.
 
+\section{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 which increment
+and decrement counters or otherwise recognise the entry to and exit from
+recursive structures and then jump to the appropriate machine defnition using
+\verb|fcall| and \verb|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 language) when a recursive structure is entered, then later return
+when the end is recognized.
+
 \end{document}