From 9f3c2baa91083bb5b33b4f3ec07f58d900157e32 Mon Sep 17 00:00:00 2001 From: thurston Date: Sat, 1 Aug 2009 02:20:09 +0000 Subject: [PATCH 1/1] Line directives need to use the fileName stored in the InputLoc stuctures from 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 | 4 ++-- ragel/cscodegen.cpp | 4 ++-- ragel/gendata.cpp | 7 +++---- ragel/gendata.h | 2 +- ragel/javacodegen.cpp | 4 ++-- ragel/parsedata.cpp | 2 +- ragel/parsetree.cpp | 1 + ragel/rlscan.rl | 1 - ragel/rubycodegen.cpp | 5 ++--- ragel/xmlcodegen.cpp | 3 +-- 10 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ragel/cdcodegen.cpp b/ragel/cdcodegen.cpp index a7d51be..a0a882c 100644 --- a/ragel/cdcodegen.cpp +++ b/ragel/cdcodegen.cpp @@ -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 ); } diff --git a/ragel/cscodegen.cpp b/ragel/cscodegen.cpp index fe1c64a..c04511a 100644 --- a/ragel/cscodegen.cpp +++ b/ragel/cscodegen.cpp @@ -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 ); } diff --git a/ragel/gendata.cpp b/ragel/gendata.cpp index cbe98d8..8c57e2c 100644 --- a/ragel/gendata.cpp +++ b/ragel/gendata.cpp @@ -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; } diff --git a/ragel/gendata.h b/ragel/gendata.h index 3cdd407..4d21820 100644 --- a/ragel/gendata.h +++ b/ragel/gendata.h @@ -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 ); diff --git a/ragel/javacodegen.cpp b/ragel/javacodegen.cpp index a04dc31..adff67e 100644 --- a/ragel/javacodegen.cpp +++ b/ragel/javacodegen.cpp @@ -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 ); } diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp index 125e9f7..8ce89db 100644 --- a/ragel/parsedata.cpp +++ b/ragel/parsedata.cpp @@ -971,7 +971,7 @@ Action *ParseData::newAction( const char *name, InlineList *inlineList ) InputLoc loc; loc.line = 1; loc.col = 1; - loc.fileName = ""; + loc.fileName = "NONE"; Action *action = new Action( loc, name, inlineList, nextCondId++ ); action->actionRefs.append( rootName ); diff --git a/ragel/parsetree.cpp b/ragel/parsetree.cpp index b1ce8b7..3245a54 100644 --- a/ragel/parsetree.cpp +++ b/ragel/parsetree.cpp @@ -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; diff --git a/ragel/rlscan.rl b/ragel/rlscan.rl index 5b95468..3c325c3 100644 --- a/ragel/rlscan.rl +++ b/ragel/rlscan.rl @@ -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; diff --git a/ragel/rubycodegen.cpp b/ragel/rubycodegen.cpp index 3e61fe8..5117823 100644 --- a/ragel/rubycodegen.cpp +++ b/ragel/rubycodegen.cpp @@ -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 ); } diff --git a/ragel/xmlcodegen.cpp b/ragel/xmlcodegen.cpp index 994fec7..9a9c388 100644 --- a/ragel/xmlcodegen.cpp +++ b/ragel/xmlcodegen.cpp @@ -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 ); } -- 2.7.4