Fixed crash on failed lookup of goto/call/etc target.
[external/ragel.git] / ragel / parsedata.cpp
index 3fae998..6e2558b 100644 (file)
@@ -735,21 +735,25 @@ void ParseData::resolveNameRefs( InlineList *inlineList, Action *action )
                                /* Resolve, pass action for local search. */
                                NameInst *target = resolveStateRef( *item->nameRef, item->loc, action );
 
-                               /* Check if the target goes into a longest match. */
-                               NameInst *search = target->parent;
-                               while ( search != 0 ) {
-                                       if ( search->isLongestMatch ) {
-                                               error(item->loc) << "cannot enter inside a longest "
-                                                               "match construction as an entry point" << endl;
-                                               break;
+                               /* Name lookup error reporting is handled by resolveStateRef. */
+                               if ( target != 0 ) {
+                                       /* Check if the target goes into a longest match. */
+                                       NameInst *search = target->parent;
+                                       while ( search != 0 ) {
+                                               if ( search->isLongestMatch ) {
+                                                       error(item->loc) << "cannot enter inside a longest "
+                                                                       "match construction as an entry point" << endl;
+                                                       break;
+                                               }
+                                               search = search->parent;
                                        }
-                                       search = search->parent;
-                               }
 
-                               /* Note the reference in the name. This will cause the entry
-                                * point to survive to the end of the graph generating walk. */
-                               if ( target != 0 )
+                                       /* Record the reference in the name. This will cause the
+                                        * entry point to survive to the end of the graph
+                                        * generating walk. */
                                        target->numRefs += 1;
+                               }
+
                                item->nameTarg = target;
                                break;
                        }
@@ -889,9 +893,9 @@ bool ParseData::setVariable( char *var, InlineList *inlineList )
                stackExpr = inlineList;
        else if ( strcmp( var, "act" ) == 0 )
                actExpr = inlineList;
-       else if ( strcmp( var, "tokstart" ) == 0 )
+       else if ( strcmp( var, "ts" ) == 0 )
                tokstartExpr = inlineList;
-       else if ( strcmp( var, "tokend" ) == 0 )
+       else if ( strcmp( var, "te" ) == 0 )
                tokendExpr = inlineList;
        else
                set = false;
@@ -991,13 +995,13 @@ void ParseData::initLongestMatchData()
                /* The setTokStart action sets tokstart. */
                InlineList *il5 = new InlineList;
                il5->append( new InlineItem( InputLoc(), InlineItem::LmSetTokStart ) );
-               setTokStart = newAction( "tokstart", il5 );
+               setTokStart = newAction( "ts", il5 );
                setTokStart->isLmAction = true;
 
                /* The setTokEnd action sets tokend. */
                InlineList *il3 = new InlineList;
                il3->append( new InlineItem( InputLoc(), InlineItem::LmSetTokEnd ) );
-               setTokEnd = newAction( "tokend", il3 );
+               setTokEnd = newAction( "te", il3 );
                setTokEnd->isLmAction = true;
 
                /* The action will also need an ordering: ahead of all user action
@@ -1072,7 +1076,8 @@ FsmAp *ParseData::makeInstance( GraphDictEl *gdNode )
        for ( StateList::Iter state = graph->stateList; state.lte(); state++ )
                graph->transferErrorActions( state, 0 );
        
-       removeActionDups( graph );
+       if ( ::wantDupsRemoved )
+               removeActionDups( graph );
 
        /* Remove unreachable states. There should be no dead end states. The
         * subtract and intersection operators are the only places where they may
@@ -1459,6 +1464,7 @@ void writeLanguage( std::ostream &out )
                case HostLang::D:    out << "D"; break;
                case HostLang::Java: out << "Java"; break;
                case HostLang::Ruby: out << "Ruby"; break;
+               case HostLang::CSharp: out << "C#"; break;
        }
        out << "\"";