Prevent the left machine from persisting through :>> via an empty string on the
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Fri, 11 Jan 2008 03:26:36 +0000 (03:26 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Fri, 11 Jan 2008 03:26:36 +0000 (03:26 +0000)
right.

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

doc/ragel-guide.tex
ragel/parsetree.cpp

index 4777840..f7c9b07 100644 (file)
@@ -2355,7 +2355,10 @@ main := any* :>> 'FIN';
 \end{center}
 \graphspace
 
-Finish-guarded concatenation is equivalent to the following:
+Finish-guarded concatenation is equivalent to the following, with one
+exception. If the right machine's start state is final, the higher priority is
+also embedded into it as a leaving priority. This prevents the left machine
+from persisting via the zero-length string.
 
 \verbspace
 \begin{verbatim}
index c95921f..f31d8bc 100644 (file)
@@ -840,8 +840,8 @@ FsmAp *Term::walk( ParseData *pd, bool lastInSeq )
                        priorDescs[0].priority = 0;
                        rtnVal->allTransPrior( pd->curPriorOrd++, &priorDescs[0] );
 
-                       /* The start transitions right machine get the higher priority.
-                        * Use the same unique key. */
+                       /* The start transitions of the right machine gets the higher
+                        * priority. Use the same unique key. */
                        priorDescs[1].key = priorDescs[0].key;
                        priorDescs[1].priority = 1;
                        rhs->startFsmPrior( pd->curPriorOrd++, &priorDescs[1] );
@@ -871,6 +871,14 @@ FsmAp *Term::walk( ParseData *pd, bool lastInSeq )
                        priorDescs[1].priority = 1;
                        rhs->finishFsmPrior( pd->curPriorOrd++, &priorDescs[1] );
 
+                       /* If the right machine's start state is final we need to guard
+                        * against the left machine persisting by moving through the empty
+                        * string. */
+                       if ( rhs->startState->isFinState() ) {
+                               rhs->startState->outPriorTable.setPrior( 
+                                               pd->curPriorOrd++, &priorDescs[1] );
+                       }
+
                        /* Perform concatenation. */
                        rtnVal->concatOp( rhs );
                        afterOpMinimize( rtnVal, lastInSeq );