Line directives need to use the fileName stored in the InputLoc stuctures from
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sat, 1 Aug 2009 02:20:09 +0000 (02:20 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sat, 1 Aug 2009 02:20:09 +0000 (02:20 +0000)
the parse trees, not the root source file, otherwise actions in included files
will have the wrong source file names associated with the text.

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

ragel/cdcodegen.cpp
ragel/cscodegen.cpp
ragel/gendata.cpp
ragel/gendata.h
ragel/javacodegen.cpp
ragel/parsedata.cpp
ragel/parsetree.cpp
ragel/rlscan.rl
ragel/rubycodegen.cpp
ragel/xmlcodegen.cpp

index a7d51be..a0a882c 100644 (file)
@@ -516,7 +516,7 @@ void FsmCodeGen::ACTION( ostream &ret, GenAction *action, int targState,
                bool inFinish, bool csForced )
 {
        /* Write the preprocessor line info for going into the source file. */
-       cdLineDirective( ret, sourceFileName, action->loc.line );
+       cdLineDirective( ret, action->loc.fileName, action->loc.line );
 
        /* Write the block and close it off. */
        ret << "\t{";
@@ -527,7 +527,7 @@ void FsmCodeGen::ACTION( ostream &ret, GenAction *action, int targState,
 void FsmCodeGen::CONDITION( ostream &ret, GenAction *condition )
 {
        ret << "\n";
-       cdLineDirective( ret, sourceFileName, condition->loc.line );
+       cdLineDirective( ret, condition->loc.fileName, condition->loc.line );
        INLINE_LIST( ret, condition->inlineList, 0, false, false );
 }
 
index fe1c64a..c04511a 100644 (file)
@@ -527,7 +527,7 @@ string CSharpFsmCodeGen::LDIR_PATH( char *path )
 void CSharpFsmCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish )
 {
        /* Write the preprocessor line info for going into the source file. */
-       csharpLineDirective( ret, sourceFileName, action->loc.line );
+       csharpLineDirective( ret, action->loc.fileName, action->loc.line );
 
        /* Write the block and close it off. */
        ret << "\t{";
@@ -538,7 +538,7 @@ void CSharpFsmCodeGen::ACTION( ostream &ret, GenAction *action, int targState, b
 void CSharpFsmCodeGen::CONDITION( ostream &ret, GenAction *condition )
 {
        ret << "\n";
-       csharpLineDirective( ret, sourceFileName, condition->loc.line );
+       csharpLineDirective( ret, condition->loc.fileName, condition->loc.line );
        INLINE_LIST( ret, condition->inlineList, 0, false );
 }
 
index cbe98d8..8c57e2c 100644 (file)
@@ -338,13 +338,12 @@ void CodeGenData::initActionList( unsigned long length )
                actionList.append( allActions+a );
 }
 
-void CodeGenData::newAction( int anum, const char *name, int line, 
-               int col, GenInlineList *inlineList )
+void CodeGenData::newAction( int anum, const char *name,
+               const InputLoc &loc, GenInlineList *inlineList )
 {
        allActions[anum].actionId = anum;
        allActions[anum].name = name;
-       allActions[anum].loc.line = line;
-       allActions[anum].loc.col = col;
+       allActions[anum].loc = loc;
        allActions[anum].inlineList = inlineList;
 }
 
index 3cdd407..4d21820 100644 (file)
@@ -131,7 +131,7 @@ struct CodeGenData
 
        void createMachine();
        void initActionList( unsigned long length );
-       void newAction( int anum, const char *name, int line, int col, GenInlineList *inlineList );
+       void newAction( int anum, const char *name, const InputLoc &loc, GenInlineList *inlineList );
        void initActionTableList( unsigned long length );
        void initStateList( unsigned long length );
        void setStartState( unsigned long startState );
index a04dc31..adff67e 100644 (file)
@@ -1586,7 +1586,7 @@ void JavaTabCodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item,
 void JavaTabCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish )
 {
        /* Write the preprocessor line info for going into the source file. */
-       javaLineDirective( ret, sourceFileName, action->loc.line );
+       javaLineDirective( ret, action->loc.fileName, action->loc.line );
 
        /* Write the block and close it off. */
        ret << "\t{";
@@ -1597,7 +1597,7 @@ void JavaTabCodeGen::ACTION( ostream &ret, GenAction *action, int targState, boo
 void JavaTabCodeGen::CONDITION( ostream &ret, GenAction *condition )
 {
        ret << "\n";
-       javaLineDirective( ret, sourceFileName, condition->loc.line );
+       javaLineDirective( ret, condition->loc.fileName, condition->loc.line );
        INLINE_LIST( ret, condition->inlineList, 0, false );
 }
 
index 125e9f7..8ce89db 100644 (file)
@@ -971,7 +971,7 @@ Action *ParseData::newAction( const char *name, InlineList *inlineList )
        InputLoc loc;
        loc.line = 1;
        loc.col = 1;
-       loc.fileName = "<NONE>";
+       loc.fileName = "NONE";
 
        Action *action = new Action( loc, name, inlineList, nextCondId++ );
        action->actionRefs.append( rootName );
index b1ce8b7..3245a54 100644 (file)
@@ -229,6 +229,7 @@ void LongestMatch::makeActions( ParseData *pd )
        InputLoc loc;
        loc.line = 1;
        loc.col = 1;
+       loc.fileName = "NONE";
 
        /* Create the error action. */
        InlineList *il6 = new InlineList;
index 5b95468..3c325c3 100644 (file)
@@ -485,7 +485,6 @@ void Scanner::token( int type, char *start, char *end )
 void Scanner::processToken( int type, char *tokdata, int toklen )
 {
        int *p, *pe, *eof;
-       
 
        if ( type < 0 )
                p = pe = eof = 0;
index 3e61fe8..5117823 100644 (file)
@@ -271,13 +271,12 @@ string RubyCodeGen::FSM_NAME()
 void RubyCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish )
 {
        /* Write the preprocessor line info for going into the source file. */
-       rubyLineDirective( ret, sourceFileName, action->loc.line );
+       rubyLineDirective( ret, action->loc.fileName, action->loc.line );
 
        /* Write the block and close it off. */
        ret << "                begin\n";
        INLINE_LIST( ret, action->inlineList, targState, inFinish );
        ret << "                end\n";
-       rubyLineDirective( ret, sourceFileName, action->loc.line );
 }
 
 
@@ -345,7 +344,7 @@ string RubyCodeGen::INT( int i )
 void RubyCodeGen::CONDITION( ostream &ret, GenAction *condition )
 {
        ret << "\n";
-       rubyLineDirective( ret, sourceFileName, condition->loc.line );
+       rubyLineDirective( ret, condition->loc.fileName, condition->loc.line );
        INLINE_LIST( ret, condition->inlineList, 0, false );
 }
 
index 994fec7..9a9c388 100644 (file)
@@ -1027,8 +1027,7 @@ void BackendGen::makeAction( Action *action )
        GenInlineList *genList = new GenInlineList;
        makeGenInlineList( genList, action->inlineList );
 
-       cgd->newAction( curAction++, action->name, 
-                       action->loc.line, action->loc.col, genList );
+       cgd->newAction( curAction++, action->name, action->loc, genList );
 }