Error messages in start label analysis of join operations were causing
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Wed, 9 Apr 2008 22:03:26 +0000 (22:03 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Wed, 9 Apr 2008 22:03:26 +0000 (22:03 +0000)
assertion failures because location info was not set. Fixed by adding
locations.

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

ragel/parsetree.cpp
ragel/parsetree.h
ragel/rlparse.kl

index 9450f74..6a97a28 100644 (file)
@@ -671,7 +671,7 @@ void Join::resolveNameRefs( ParseData *pd )
                        pd->curNameInst->start = resolved[0];
                        if ( resolved.length() > 1 ) {
                                /* Complain about the multiple references. */
-                               error(loc) << "multiple start labels" << endl;
+                               error(loc) << "join operation has multiple start labels" << endl;
                                errorStateLabels( resolved );
                        }
                }
@@ -682,9 +682,8 @@ void Join::resolveNameRefs( ParseData *pd )
                        pd->curNameInst->start->numRefs += 1;
                }
                else {
-                       /* No start label. Complain and recover by adding a label to the
-                        * adding one. Recover ignoring the problem. */
-                       error(loc) << "no start label" << endl;
+                       /* No start label. */
+                       error(loc) << "join operation has no start label" << endl;
                }
 
                /* Recurse into all expressions in the list. */
index fe0db4f..66a4d68 100644 (file)
@@ -330,9 +330,9 @@ struct JoinOrLm
        };
 
        JoinOrLm( Join *join ) : 
-               join(join), type(JoinType) {}
+               join(join), longestMatch(0), type(JoinType) {}
        JoinOrLm( LongestMatch *longestMatch ) :
-               longestMatch(longestMatch), type(LongestMatchType) {}
+               join(0), longestMatch(longestMatch), type(LongestMatchType) {}
 
        FsmAp *walk( ParseData *pd );
        void makeNameTree( ParseData *pd );
index 7490a81..782208e 100644 (file)
@@ -115,6 +115,8 @@ assignment:
 
                if ( $1->isSet )
                        exportContext.remove( exportContext.length()-1 );
+
+               $4->join->loc = $3->loc;
        };
 
 instantiation: 
@@ -124,6 +126,10 @@ instantiation:
 
                if ( $1->isSet )
                        exportContext.remove( exportContext.length()-1 );
+
+               /* Pass a location to join_or_lm */
+               if ( $4->joinOrLm->join != 0 )
+                       $4->joinOrLm->join->loc = $3->loc;
        };
 
 type token_type
@@ -250,13 +256,15 @@ nonterm lm_part_list
 };
 
 lm_part_list:
-       lm_part_list longest_match_part final {
+       lm_part_list longest_match_part
+       final {
                if ( $2->lmPart != 0 ) 
                        $1->lmPartList->append( $2->lmPart );
                $$->lmPartList = $1->lmPartList;
        };
 lm_part_list:
-       longest_match_part final {
+       longest_match_part
+       final {
                /* Create a new list with the part. */
                $$->lmPartList = new LmPartList;
                if ( $1->lmPart != 0 )
@@ -280,6 +288,10 @@ longest_match_part:
                        action->isLmAction = true;
                $$->lmPart = new LongestMatchPart( $1->join, action, 
                                $3->loc, pd->nextLongestMatchId++ );
+
+               /* Provide a location to join. Unfortunately We don't
+                * have the start of the join as in other occurances. Use the end. */
+               $1->join->loc = $3->loc;
        };
 
 nonterm opt_lm_part_action
@@ -1020,6 +1032,7 @@ factor:
        '(' join ')' final {
                /* Create a new factor going to a parenthesized join. */
                $$->factor = new Factor( $2->join );
+               $2->join->loc = $1->loc;
        };
 
 nonterm range_lit