The first example that appears in the manual uses the special-purpose 'noend'
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Thu, 13 Sep 2007 00:49:49 +0000 (00:49 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Thu, 13 Sep 2007 00:49:49 +0000 (00:49 +0000)
write option. This tends to trip people up. Added a basic example which appears
first.

git-svn-id: http://svn.complang.org/ragel/trunk@277 052ea7fc-9027-0410-9066-f65837a77df0

TODO
doc/ragel-guide.tex

diff --git a/TODO b/TODO
index e5304cf..a8068eb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -40,8 +40,6 @@ eof action execution is moved into the main loop.
 ================
 END 6.0 Features
 
-Early example in docs should not use the noend option.
-
 Check initts on calls to scanners, may be necessary to stuff the initts into
 the call.
 
index aa19ca5..03672a7 100644 (file)
@@ -506,7 +506,6 @@ int main( int argc, char **argv )
 \label{cmd-line-parsing}
 \end{figure}
 
-
 \subsection{Naming Ragel Blocks}
 
 \begin{verbatim}
@@ -2500,6 +2499,41 @@ parsing, care must be taken to not use a pointer that has been invalidated by
 movement to a subsequent block.  If the current input data pointer is moved
 backwards it must not be moved past the beginning of the current block.
 
+Figure \ref{basic-example} shows a simple Ragel program that does not have any
+actions. The example tests the first argument of the program against a number
+pattern and then prints the machine's acceptance status.
+
+\begin{figure}
+\small
+\begin{verbatim}
+#include <stdio.h>
+#include <string.h>
+%%{
+    machine foo;
+    write data;
+}%%
+int main( int argc, char **argv )
+{
+    int cs;
+    if ( argc > 1 ) {
+        char *p = argv[1];
+        char *pe = p + strlen( p );
+        %%{ 
+            main := [0-9]+ ( '.' [0-9]+ )?;
+
+            write init;
+            write exec;
+            write eof;
+        }%%
+    }
+    printf("result = %i\n", cs >= foo_first_final );
+    return 0;
+}
+\end{verbatim}
+\caption{A basic Ragel example without any actions.}
+\label{basic-example}
+\end{figure}
+
 \section{Variables Used by Ragel}
 
 There are a number of variables which Ragel expects the user to declare. At a
@@ -2574,7 +2608,7 @@ may be used. The getkey statement may be used for looking into element
 structures or for translating the character to process. The getkey expression
 defaults to \verb|(*p)|. In goto-driven machines the getkey expression may be
 evaluated more than once per element processed, therefore it should not incur a
-large cost and preclude optimization.
+large cost nor preclude optimization.
 
 \section{Access Statement}