#include <climits>
#include "dlist.h"
+/* Location in an input file. */
+struct InputLoc
+{
+ const char *fileName;
+ long line;
+ long col;
+};
+
+
typedef unsigned long long Size;
struct Key
/* Used for just a few things. */
std::ostringstream hostData;
- if ( machineSpec == 0 && machineName == 0 )
- hostData << "<host line=\"1\" col=\"1\">";
-
- Scanner scanner( inputFileName, *inFile, hostData, 0, 0, 0, false );
+ /* Make the first input item. */
+ InputItem *firstInputItem = new InputItem;
+ firstInputItem->type = InputItem::HostData;
+ firstInputItem->loc.line = 1;
+ firstInputItem->loc.col = 1;
+ inputItems.append( firstInputItem );
+
+ Scanner scanner( inputFileName, *inFile, 0, 0, 0, false );
scanner.do_scan();
/* Finished, final check for errors.. */
if ( gblErrorCount > 0 )
exit(1);
- if ( machineSpec == 0 && machineName == 0 )
- hostData << "</host>\n";
-
- /* Open the XML file for writing. */
- ostream *xmlOutFile = new ofstream( xmlFileName );
-
- /* Open the XML file for reading. */
- ifstream *xmlInFile = new ifstream( xmlFileName );
- if ( ! xmlInFile->is_open() )
- error() << "could not open " << xmlFileName << " for reading" << endl;
-
/* Bail on above error. */
if ( gblErrorCount > 0 )
exit(1);
outputActive = false;
}
- XmlScanner xmlScanner( xmlFileName, *xmlInFile );
- XmlParser xmlParser( xmlFileName, outputActive, wantComplete );
+ XmlScanner xmlScanner( xmlFileName, cin );
+ XmlParser xmlParser( inputFileName, xmlFileName, outputActive, wantComplete );
xmlParser.init();
+ xmlParser.openOutput();
+
/* Write the machines, then the surrounding code. */
- //writeMachines( *xmlOutFile, hostData.str(), inputFileName, xmlParser );
- generate( *xmlOutFile, hostData.str(), inputFileName, xmlParser );
+ generate( xmlParser );
/* Close the input and the intermediate file. */
- delete xmlOutFile;
delete inFile;
/* Bail on above error. */
void cleanExit( const char *intermed, int status )
{
- unlink( intermed );
+ //unlink( intermed );
exit( status );
}
"\" is the same as the input file" << endp;
}
- const char *intermed = openIntermed( inputFileName, outputFileName );
+ const char *intermed = 0; //openIntermed( inputFileName, outputFileName );
process( inputFileName, intermed );
/* Clean up the intermediate. */
sectionGraph->setStateNumbers( 0 );
}
-void ParseData::generate( ostream &out, XmlParser &xmlParser )
+void ParseData::genBackend( XmlParser &xmlParser )
{
beginProcessing();
/* Make the generator. */
- XMLCodeGen codeGen( sectionName, this, sectionGraph, out, xmlParser );
+ BackendGen backendGen( sectionName, this, sectionGraph, xmlParser );
/* Write out with it. */
- codeGen.makeBackend();
+ backendGen.makeBackend();
if ( printStatistics ) {
cerr << "fsm name : " << sectionName << endl;
}
}
-void generate( std::ostream &out, std::string hostData,
- const char *inputFileName, XmlParser &xmlParser )
+void generate( XmlParser &xmlParser )
{
if ( machineSpec == 0 && machineName == 0 ) {
/* No machine spec or machine name given. Generate everything. */
}
if ( gblErrorCount == 0 ) {
- xmlParser.open_ragel( inputFileName );
for ( ParserDict::Iter parser = parserDict; parser.lte(); parser++ ) {
ParseData *pd = parser->value->pd;
if ( pd->instanceList.length() > 0 )
- pd->generate( out, xmlParser );
+ pd->genBackend( xmlParser );
}
- out << hostData;
}
}
else if ( parserDict.length() > 0 ) {
else {
/* Section/Machine to emit was found. Prepare and emit it. */
parseData->prepareMachineGen( graphDictEl );
- if ( gblErrorCount == 0 ) {
- xmlParser.open_ragel( inputFileName );
- parseData->generate( out, xmlParser );
- out << hostData;
- }
+ if ( gblErrorCount == 0 )
+ parseData->genBackend( xmlParser );
+ }
+ }
+
+
+ for ( InputItemList::Iter ii = inputItems; ii.lte(); ii++ ) {
+ if ( ii->type == InputItem::Write ) {
+ CodeGenMapEl *mapEl = xmlParser.codeGenMap.find( (char*)ii->name.c_str() );
+ xmlParser.cgd = mapEl->value;
+ ::keyOps = &xmlParser.cgd->thisKeyOps;
+
+ xmlParser.cgd->writeStatement( ii->loc, ii->writeArgs.length()-1, ii->writeArgs.data );
}
+ else
+ xmlParser.cgd->out << ii->data.str();
}
}
#include <iostream>
#include <limits.h>
+#include <sstream>
#include "avlmap.h"
#include "bstmap.h"
#include "vector.h"
void prepareMachineGen( GraphDictEl *graphDictEl );
void prepareMachineGenTBWrapped( GraphDictEl *graphDictEl );
void generateXML( ostream &out, XmlParser &xmlParser );
- void generate( ostream &out, XmlParser &xmlParser );
+ void genBackend( XmlParser &xmlParser );
FsmAp *sectionGraph;
bool generatingSectionSubset;
void errorStateLabels( const NameSet &locations );
-/* Data used by the parser specific to the current file. Supports the include
- * system, since a new parser is executed for each included file. */
-struct InputData
+struct InputItem
{
- InputData( char *fileName, char *includeSpec, char *includeTo ) :
- pd(0), sectionName(0), defaultParseData(0),
- first_line(1), first_column(1),
- last_line(1), last_column(0),
- fileName(fileName), includeSpec(includeSpec),
- includeTo(includeTo), active(true)
- {}
-
- /* For collecting a name references. */
- NameRef nameRef;
- NameRefList nameRefList;
-
- /* The parse data. For each fsm spec, the parser collects things that it parses
- * in data structures in here. */
- ParseData *pd;
+ enum Type {
+ HostData,
+ Write,
+ };
- char *sectionName;
- ParseData *defaultParseData;
-
- int first_line;
- int first_column;
- int last_line;
- int last_column;
-
- char *fileName;
+ Type type;
+ std::ostringstream data;
+ std::string name;
+ Vector<char *> writeArgs;
- /* If this is an included file, this contains the specification to search
- * for. IncludeTo will contain the spec name that does the includng. */
- char *includeSpec;
- char *includeTo;
+ InputLoc loc;
- bool active;
- InputLoc sectionLoc;
+ InputItem *prev, *next;
};
+/*
+ * Global data.
+ */
+
struct Parser;
typedef AvlMap<char*, Parser *, CmpStr> ParserDict;
typedef AvlMapEl<char*, Parser *> ParserDictEl;
-extern ParserDict parserDict;
+typedef DList<InputItem> InputItemList;
+extern ParserDict parserDict;
+extern InputItemList inputItems;
#endif /* _PARSEDATA_H */
#include <string>
#include "vector.h"
#include "config.h"
+#include "common.h"
#define PROGNAME "ragel"
extern int gblErrorCount;
extern char mainMachine[];
-/* Location in an input file. */
-struct InputLoc
-{
- const char *fileName;
- int line;
- int col;
-};
-
InputLoc makeInputLoc( const char *fileName, int line = 0, int col = 0 );
std::ostream &operator<<( std::ostream &out, const InputLoc &loc );
void terminateAllParsers( );
void writeMachines( std::ostream &out, std::string hostData,
const char *inputFileName, XmlParser &xmlParser );
-void generate( std::ostream &out, std::string hostData,
- const char *inputFileName, XmlParser &xmlParser );
+void generate( XmlParser &xmlParser );
void xmlEscapeHost( std::ostream &out, char *data, long len );
typedef Vector<const char *> ArgsVector;
using std::endl;
ParserDict parserDict;
+InputItemList inputItems;
%%{
struct Scanner
{
- Scanner( const char *fileName, istream &input, ostream &output,
+ Scanner( const char *fileName, istream &input,
Parser *inclToParser, char *inclSectionTarg,
int includeDepth, bool importMachines )
:
- fileName(fileName), input(input), output(output),
+ fileName(fileName), input(input),
inclToParser(inclToParser),
inclSectionTarg(inclSectionTarg),
includeDepth(includeDepth),
const char *fileName;
istream &input;
- ostream &output;
Parser *inclToParser;
char *inclSectionTarg;
int includeDepth;
/* If no errors and we are at the bottom of the include stack (the
* source file listed on the command line) then write out the data. */
if ( includeDepth == 0 && machineSpec == 0 && machineName == 0 )
- xmlEscapeHost( output, ts, te-ts );
+ inputItems.tail->data.write( ts, te-ts );
}
/*
parser->includeHistory.append( IncludeHistoryItem(
includeChecks[found], inclSectionName ) );
- Scanner scanner( includeChecks[found], *inFile, output, parser,
+ Scanner scanner( includeChecks[found], *inFile, parser,
inclSectionName, includeDepth+1, false );
scanner.do_scan( );
delete inFile;
scan_error() << "import: attempted: \"" << *tried++ << '\"' << endl;
}
- Scanner scanner( importChecks[found], *inFile, output, parser,
+ Scanner scanner( importChecks[found], *inFile, parser,
0, includeDepth+1, true );
scanner.do_scan( );
scanner.importToken( 0, 0, 0 );
action write_command
{
if ( active() && machineSpec == 0 && machineName == 0 ) {
- output << "<write"
- " def_name=\"" << parser->sectionName << "\""
- " line=\"" << line << "\""
- " col=\"" << column << "\""
- ">";
+ InputItem *inputItem = new InputItem;
+ inputItem->type = InputItem::Write;
+ inputItem->loc.line = line;
+ inputItem->loc.col = column;
+ inputItem->name = parser->sectionName;
+ inputItems.append( inputItem );
}
}
action write_arg
{
if ( active() && machineSpec == 0 && machineName == 0 )
- output << "<arg>" << tokdata << "</arg>";
+ inputItems.tail->writeArgs.append( strdup(tokdata) );
}
action write_close
{
if ( active() && machineSpec == 0 && machineName == 0 )
- output << "</write>\n";
+ inputItems.tail->writeArgs.append( 0 );
}
write_stmt =
{
parserExistsError = false;
- if ( includeDepth == 0 ) {
- if ( machineSpec == 0 && machineName == 0 )
- output << "</host>\n";
- }
-
sectionLoc.fileName = fileName;
sectionLoc.line = line;
- sectionLoc.col = 0;
+ sectionLoc.col = column;
}
void Scanner::endSection( )
InputLoc loc;
loc.fileName = fileName;
loc.line = line;
- loc.col = 0;
+ loc.col = column;
parser->token( loc, TK_EndSection, 0, 0 );
}
if ( machineSpec == 0 && machineName == 0 ) {
/* The end section may include a newline on the end, so
* we use the last line, which will count the newline. */
- output << "<host line=\"" << line << "\">";
+ InputItem *inputItem = new InputItem;
+ inputItem->type = InputItem::HostData;
+ inputItem->loc.line = line;
+ inputItem->loc.col = column;
+ inputItems.append( inputItem );
}
}
}
using namespace std;
-XMLCodeGen::XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm,
- std::ostream &out, XmlParser &xmlParser )
+GenBase::GenBase( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser )
:
fsmName(fsmName),
pd(pd),
fsm(fsm),
- out(out),
xmlParser(xmlParser),
nextActionTableId(0)
{
}
+void GenBase::appendTrans( TransListVect &outList, Key lowKey,
+ Key highKey, TransAp *trans )
+{
+ if ( trans->toState != 0 || trans->actionTable.length() > 0 )
+ outList.append( TransEl( lowKey, highKey, trans ) );
+}
+
+void GenBase::reduceActionTables()
+{
+ /* Reduce the actions tables to a set. */
+ for ( StateList::Iter st = fsm->stateList; st.lte(); st++ ) {
+ RedActionTable *actionTable = 0;
+
+ /* Reduce To State Actions. */
+ if ( st->toStateActionTable.length() > 0 ) {
+ if ( actionTableMap.insert( st->toStateActionTable, &actionTable ) )
+ actionTable->id = nextActionTableId++;
+ }
+
+ /* Reduce From State Actions. */
+ if ( st->fromStateActionTable.length() > 0 ) {
+ if ( actionTableMap.insert( st->fromStateActionTable, &actionTable ) )
+ actionTable->id = nextActionTableId++;
+ }
+
+ /* Reduce EOF actions. */
+ if ( st->eofActionTable.length() > 0 ) {
+ if ( actionTableMap.insert( st->eofActionTable, &actionTable ) )
+ actionTable->id = nextActionTableId++;
+ }
+
+ /* Loop the transitions and reduce their actions. */
+ for ( TransList::Iter trans = st->outList; trans.lte(); trans++ ) {
+ if ( trans->actionTable.length() > 0 ) {
+ if ( actionTableMap.insert( trans->actionTable, &actionTable ) )
+ actionTable->id = nextActionTableId++;
+ }
+ }
+ }
+}
+
+XMLCodeGen::XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm,
+ std::ostream &out, XmlParser &xmlParser )
+:
+ GenBase(fsmName, pd, fsm, xmlParser),
+ out(out)
+{
+}
+
void XMLCodeGen::writeActionList()
{
delete[] tables;
}
-void XMLCodeGen::reduceActionTables()
-{
- /* Reduce the actions tables to a set. */
- for ( StateList::Iter st = fsm->stateList; st.lte(); st++ ) {
- RedActionTable *actionTable = 0;
-
- /* Reduce To State Actions. */
- if ( st->toStateActionTable.length() > 0 ) {
- if ( actionTableMap.insert( st->toStateActionTable, &actionTable ) )
- actionTable->id = nextActionTableId++;
- }
-
- /* Reduce From State Actions. */
- if ( st->fromStateActionTable.length() > 0 ) {
- if ( actionTableMap.insert( st->fromStateActionTable, &actionTable ) )
- actionTable->id = nextActionTableId++;
- }
-
- /* Reduce EOF actions. */
- if ( st->eofActionTable.length() > 0 ) {
- if ( actionTableMap.insert( st->eofActionTable, &actionTable ) )
- actionTable->id = nextActionTableId++;
- }
-
- /* Loop the transitions and reduce their actions. */
- for ( TransList::Iter trans = st->outList; trans.lte(); trans++ ) {
- if ( trans->actionTable.length() > 0 ) {
- if ( actionTableMap.insert( trans->actionTable, &actionTable ) )
- actionTable->id = nextActionTableId++;
- }
- }
- }
-}
-
-void XMLCodeGen::appendTrans( TransListVect &outList, Key lowKey,
- Key highKey, TransAp *trans )
-{
- if ( trans->toState != 0 || trans->actionTable.length() > 0 )
- outList.append( TransEl( lowKey, highKey, trans ) );
-}
-
void XMLCodeGen::writeKey( Key key )
{
if ( keyOps->isSigned )
}
}
-void XMLCodeGen::makeKey( GenInlineList *outList, Key key )
+BackendGen::BackendGen( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser )
+:
+ GenBase(fsmName, pd, fsm, xmlParser)
{
}
-void XMLCodeGen::makeText( GenInlineList *outList, InlineItem *item )
+
+void BackendGen::makeText( GenInlineList *outList, InlineItem *item )
{
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Text );
+ GenInlineItem *inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Text );
inlineItem->data = item->data;
outList->append( inlineItem );
}
-void XMLCodeGen::makeTargetItem( GenInlineList *outList, long targetId, GenInlineItem::Type type )
+void BackendGen::makeTargetItem( GenInlineList *outList, long entryId, GenInlineItem::Type type )
{
long targetState;
if ( pd->generatingSectionSubset )
targetState = -1;
else {
- EntryMapEl *targ = fsm->entryPoints.find( targetId );
+ EntryMapEl *targ = fsm->entryPoints.find( entryId );
targetState = targ->value->alg.stateNum;
}
/* Make the item. */
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), type );
+ GenInlineItem *inlineItem = new GenInlineItem( InputLoc(), type );
inlineItem->targId = targetState;
outList->append( inlineItem );
}
/* Make a sublist item with a given type. */
-void XMLCodeGen::makeSubList( GenInlineList *outList,
+void BackendGen::makeSubList( GenInlineList *outList,
InlineList *inlineList, GenInlineItem::Type type )
{
/* Fill the sub list. */
makeGenInlineList( subList, inlineList );
/* Make the item. */
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), type );
+ GenInlineItem *inlineItem = new GenInlineItem( InputLoc(), type );
inlineItem->children = subList;
outList->append( inlineItem );
}
-void XMLCodeGen::makeLmOnLast( GenInlineList *outList, InlineItem *item )
+void BackendGen::makeLmOnLast( GenInlineList *outList, InlineItem *item )
{
makeSetTokend( outList, 1 );
}
}
-void XMLCodeGen::makeLmOnNext( GenInlineList *outList, InlineItem *item )
+void BackendGen::makeLmOnNext( GenInlineList *outList, InlineItem *item )
{
makeSetTokend( outList, 0 );
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Hold ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Hold ) );
if ( item->longestMatchPart->action != 0 ) {
makeSubList( outList,
}
}
-void XMLCodeGen::makeExecGetTokend( GenInlineList *outList )
+void BackendGen::makeExecGetTokend( GenInlineList *outList )
{
/* Make the Exec item. */
- GenInlineItem *execItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Exec );
+ GenInlineItem *execItem = new GenInlineItem( InputLoc(), GenInlineItem::Exec );
execItem->children = new GenInlineList;
/* Make the GetTokEnd */
- GenInlineItem *getTokend = new GenInlineItem( GenInputLoc(), GenInlineItem::LmGetTokEnd );
+ GenInlineItem *getTokend = new GenInlineItem( InputLoc(), GenInlineItem::LmGetTokEnd );
execItem->children->append( getTokend );
outList->append( execItem );
}
-void XMLCodeGen::makeLmOnLagBehind( GenInlineList *outList, InlineItem *item )
+void BackendGen::makeLmOnLagBehind( GenInlineList *outList, InlineItem *item )
{
/* Jump to the tokend. */
makeExecGetTokend( outList );
}
}
-void XMLCodeGen::makeLmSwitch( GenInlineList *outList, InlineItem *item )
+void BackendGen::makeLmSwitch( GenInlineList *outList, InlineItem *item )
{
- GenInlineItem *lmSwitch = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSwitch );
+ GenInlineItem *lmSwitch = new GenInlineItem( InputLoc(), GenInlineItem::LmSwitch );
GenInlineList *lmList = lmSwitch->children = new GenInlineList;
LongestMatch *longestMatch = item->longestMatch;
* error state. */
assert( fsm->errState != 0 );
- GenInlineItem *errCase = new GenInlineItem( GenInputLoc(), GenInlineItem::SubAction );
+ GenInlineItem *errCase = new GenInlineItem( InputLoc(), GenInlineItem::SubAction );
errCase->lmId = 0;
errCase->children = new GenInlineList;
- makeTargetItem( errCase->children,
- fsm->errState->alg.stateNum, GenInlineItem::Goto );
+ /* Make the item. */
+ GenInlineItem *gotoItem = new GenInlineItem( InputLoc(), GenInlineItem::Goto );
+ gotoItem->targId = fsm->errState->alg.stateNum;
+ errCase->children->append( gotoItem );
lmList->append( errCase );
}
else {
/* Open the action. Write it with the context that sets up _p
* when doing control flow changes from inside the machine. */
- GenInlineItem *lmCase = new GenInlineItem( GenInputLoc(),
+ GenInlineItem *lmCase = new GenInlineItem( InputLoc(),
GenInlineItem::SubAction );
lmCase->lmId = lmi->longestMatchId;
lmCase->children = new GenInlineList;
}
if ( needDefault ) {
- GenInlineItem *defCase = new GenInlineItem( GenInputLoc(),
+ GenInlineItem *defCase = new GenInlineItem( InputLoc(),
GenInlineItem::SubAction );
defCase->lmId = -1;
defCase->children = new GenInlineList;
outList->append( lmSwitch );
}
-void XMLCodeGen::makeSetTokend( GenInlineList *outList, long offset )
+void BackendGen::makeSetTokend( GenInlineList *outList, long offset )
{
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetTokEnd );
+ GenInlineItem *inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmSetTokEnd );
inlineItem->offset = offset;
outList->append( inlineItem );
}
-void XMLCodeGen::makeSetAct( GenInlineList *outList, long lmId )
+void BackendGen::makeSetAct( GenInlineList *outList, long lmId )
{
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetActId );
+ GenInlineItem *inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmSetActId );
inlineItem->lmId = lmId;
outList->append( inlineItem );
}
-void XMLCodeGen::makeGenInlineList( GenInlineList *outList, InlineList *inList )
+void BackendGen::makeGenInlineList( GenInlineList *outList, InlineList *inList )
{
for ( InlineList::Iter item = *inList; item.lte(); item++ ) {
switch ( item->type ) {
makeSubList( outList, item->children, GenInlineItem::NextExpr );
break;
case InlineItem::Break:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Break ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Break ) );
break;
case InlineItem::Ret:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Ret ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Ret ) );
break;
case InlineItem::PChar:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::PChar ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::PChar ) );
break;
case InlineItem::Char:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Char ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Char ) );
break;
case InlineItem::Curs:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Curs ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Curs ) );
break;
case InlineItem::Targs:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Targs ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Targs ) );
break;
case InlineItem::Entry:
makeTargetItem( outList, item->nameTarg->id, GenInlineItem::Entry );
break;
case InlineItem::Hold:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Hold ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Hold ) );
break;
case InlineItem::Exec:
makeSubList( outList, item->children, GenInlineItem::Exec );
break;
case InlineItem::LmInitAct:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::LmInitAct ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::LmInitAct ) );
break;
case InlineItem::LmInitTokStart:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::LmInitTokStart ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::LmInitTokStart ) );
break;
case InlineItem::LmSetTokStart:
- outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetTokStart ) );
+ outList->append( new GenInlineItem( InputLoc(), GenInlineItem::LmSetTokStart ) );
xmlParser.cgd->hasLongestMatch = true;
break;
}
"</ragel_def>\n";
}
-void XMLCodeGen::makeExports()
+void BackendGen::makeExports()
{
for ( ExportList::Iter exp = pd->exportList; exp.lte(); exp++ )
xmlParser.cgd->exportList.append( new Export( exp->name, exp->key ) );
}
-void XMLCodeGen::makeAction( Action *action )
+void BackendGen::makeAction( Action *action )
{
GenInlineList *genList = new GenInlineList;
makeGenInlineList( genList, action->inlineList );
}
-void XMLCodeGen::makeActionList()
+void BackendGen::makeActionList()
{
/* Determine which actions to write. */
int nextActionId = 0;
}
}
-void XMLCodeGen::makeActionTableList()
+void BackendGen::makeActionTableList()
{
/* Must first order the action tables based on their id. */
int numTables = nextActionTableId;
atel->value->actionId;
}
+ /* Insert into the action table map. */
+ xmlParser.cgd->redFsm->actionMap.insert( redAct );
+
xmlParser.curActionTable += 1;
}
delete[] tables;
}
-void XMLCodeGen::makeConditions()
+void BackendGen::makeConditions()
{
if ( condData->condSpaceMap.length() > 0 ) {
long nextCondSpaceId = 0;
}
}
-bool XMLCodeGen::makeNameInst( std::string &res, NameInst *nameInst )
+bool BackendGen::makeNameInst( std::string &res, NameInst *nameInst )
{
bool written = false;
if ( nameInst->parent != 0 )
return written;
}
-void XMLCodeGen::makeEntryPoints()
+void BackendGen::makeEntryPoints()
{
/* List of entry points other than start state. */
if ( fsm->entryPoints.length() > 0 || pd->lmRequiresErrorState ) {
}
}
-void XMLCodeGen::makeStateActions( StateAp *state )
+void BackendGen::makeStateActions( StateAp *state )
{
RedActionTable *toStateActions = 0;
if ( state->toStateActionTable.length() > 0 )
}
}
-void XMLCodeGen::makeEofTrans( StateAp *state )
+void BackendGen::makeEofTrans( StateAp *state )
{
RedActionTable *eofActions = 0;
if ( state->eofActionTable.length() > 0 )
}
}
-void XMLCodeGen::makeStateConditions( StateAp *state )
+void BackendGen::makeStateConditions( StateAp *state )
{
if ( state->stateCondList.length() > 0 ) {
long length = state->stateCondList.length();
}
}
-void XMLCodeGen::makeTrans( Key lowKey, Key highKey, TransAp *trans )
+void BackendGen::makeTrans( Key lowKey, Key highKey, TransAp *trans )
{
/* First reduce the action. */
RedActionTable *actionTable = 0;
xmlParser.cgd->newTrans( xmlParser.curState, xmlParser.curTrans++, lowKey, highKey, targ, action );
}
-
-void XMLCodeGen::makeTransList( StateAp *state )
+void BackendGen::makeTransList( StateAp *state )
{
TransListVect outList;
}
-void XMLCodeGen::makeStateList()
+void BackendGen::makeStateList()
{
/* Write the list of states. */
long length = fsm->stateList.length();
}
-void XMLCodeGen::makeMachine()
+void BackendGen::makeMachine()
{
xmlParser.cgd->createMachine();
makeEntryPoints();
makeStateList();
+
+ xmlParser.cgd->closeMachine();
}
-void XMLCodeGen::makeBackend()
+void BackendGen::makeBackend()
{
/* Open the definition. */
xmlParser.open_ragel_def( fsmName );
makeExports();
makeMachine();
+
+ xmlParser.close_ragel_def();
}
}
};
-class XMLCodeGen
+struct GenBase
+{
+ GenBase( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser );
+
+ void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
+ void reduceActionTables();
+
+ char *fsmName;
+ ParseData *pd;
+ FsmAp *fsm;
+ XmlParser &xmlParser;
+
+ ActionTableMap actionTableMap;
+ int nextActionTableId;
+};
+
+class XMLCodeGen : protected GenBase
{
public:
XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm,
std::ostream &out, XmlParser &xmlParser );
+
void writeXML( );
- void makeBackend( );
private:
- void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
void writeStateActions( StateAp *state );
void writeStateList();
void writeStateConditions( StateAp *state );
void writeActionList();
void writeActionTableList();
void reduceTrans( TransAp *trans );
- void reduceActionTables();
void writeTransList( StateAp *state );
void writeEofTrans( StateAp *state );
void writeTrans( Key lowKey, Key highKey, TransAp *defTrans );
void writeMachine();
void writeActionExec( InlineItem *item );
+ std::ostream &out;
+};
+
+class BackendGen : protected GenBase
+{
+public:
+ BackendGen( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser );
+ void makeBackend( );
+
+private:
void makeGenInlineList( GenInlineList *outList, InlineList *inList );
void makeKey( GenInlineList *outList, Key key );
void makeText( GenInlineList *outList, InlineItem *item );
void makeStateConditions( StateAp *state );
void makeTransList( StateAp *state );
void makeTrans( Key lowKey, Key highKey, TransAp *trans );
-
- char *fsmName;
- ParseData *pd;
- FsmAp *fsm;
- std::ostream &out;
- XmlParser &xmlParser;
-
- ActionTableMap actionTableMap;
- int nextActionTableId;
};
setValueLimits();
}
-void CodeGenData::writeStatement( GenInputLoc &loc, int nargs, char **args )
+void CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args )
{
/* FIXME: This should be moved to the virtual functions in the code
* generators.
}
}
-ostream &CodeGenData::source_warning( const GenInputLoc &loc )
+ostream &CodeGenData::source_warning( const InputLoc &loc )
{
cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: ";
return cerr;
}
-ostream &CodeGenData::source_error( const GenInputLoc &loc )
+ostream &CodeGenData::source_error( const InputLoc &loc )
{
gblErrorCount += 1;
assert( sourceFileName != 0 );
/* This can also be overwridden to modify the processing of write
* statements. */
- virtual void writeStatement( GenInputLoc &loc, int nargs, char **args );
+ virtual void writeStatement( InputLoc &loc, int nargs, char **args );
/********************/
void setValueLimits();
void assignActionIds();
- ostream &source_warning( const GenInputLoc &loc );
- ostream &source_error( const GenInputLoc &loc );
+ ostream &source_warning( const InputLoc &loc );
+ ostream &source_error( const InputLoc &loc );
};
#include "sbstset.h"
#include "sbsttable.h"
+
#define TRANS_ERR_TRANS 0
#define STATE_ERR_STATE 0
#define FUNC_NO_FUNC 0
struct GenInlineList;
struct GenAction;
-/* Location in an input file. */
-struct GenInputLoc
-{
- int line;
- int col;
-};
-
/*
* Inline code tree
*/
LmInitAct, LmSetTokStart, SubAction, Break
};
- GenInlineItem( const GenInputLoc &loc, Type type ) :
+ GenInlineItem( const InputLoc &loc, Type type ) :
loc(loc), data(0), targId(0), targState(0),
lmId(0), children(0), offset(0),
type(type) { }
- GenInputLoc loc;
+ InputLoc loc;
char *data;
int targId;
RedStateAp *targState;
}
/* Data collected during parse. */
- GenInputLoc loc;
+ InputLoc loc;
const char *name;
GenInlineList *inlineList;
int actionId;
void init();
int parseLangEl( int type, const Token *token );
- XmlParser( const char *fileName, bool outputActive, bool wantComplete ) :
- fileName(fileName), sourceFileName(0), outStream(0),
- outputActive(outputActive), wantComplete(wantComplete),
+ XmlParser( const char *sourceFileName, const char *xmlFileName, bool outputActive, bool wantComplete ) :
+ sourceFileName(sourceFileName),
+ fileName(xmlFileName),
+ outStream(0),
+ outputActive(outputActive),
+ wantComplete(wantComplete),
cgd(0) { }
int token( int tokenId, Token &token );
int token( int tokenId, int col, int line );
int token( XMLTag *tag, int col, int line );
- void open_ragel( const char *fileName );
void open_ragel_def( char *fsmName );
+ void close_ragel_def();
+
+ void openOutput();
/* Report an error encountered by the parser. */
- ostream &warning( const GenInputLoc &loc );
+ ostream &warning( const InputLoc &loc );
ostream &error();
- ostream &error( const GenInputLoc &loc );
+ ostream &error( const InputLoc &loc );
ostream &parser_error( int tokId, Token &token );
- ostream &source_error( const GenInputLoc &loc );
+ ostream &source_error( const InputLoc &loc );
/* The name of the root section, this does not change during an include. */
- const char *fileName;
const char *sourceFileName;
+ const char *fileName;
ostream *outStream;
bool outputActive;
bool wantComplete;
struct Token
{
XMLTag *tag;
- GenInputLoc loc;
+ InputLoc loc;
};
CodeGenData *makeCodeGen( const char *sourceFileName, const char *fsmName,
lineDirective( out, filter->fileName, filter->line + 1 );
}
-void XmlParser::open_ragel( const char *fileName )
+void XmlParser::openOutput()
{
- /* Check for file name attribute. */
- sourceFileName = fileName;
-
if ( generateDot )
outStream = dotOpenOutput( sourceFileName );
- else if ( hostLang->lang == HostLang::C ) {
- hostLang = &hostLangC;
+ else if ( hostLang->lang == HostLang::C )
outStream = cdOpenOutput( sourceFileName );
- }
- else if ( hostLang->lang == HostLang::D ) {
- hostLang = &hostLangD;
+ else if ( hostLang->lang == HostLang::D )
outStream = cdOpenOutput( sourceFileName );
- }
- else if ( hostLang->lang == HostLang::Java ) {
- hostLang = &hostLangJava;
+ else if ( hostLang->lang == HostLang::Java )
outStream = javaOpenOutput( sourceFileName );
- }
- else if ( hostLang->lang == HostLang::Ruby ) {
- hostLang = &hostLangRuby;
+ else if ( hostLang->lang == HostLang::Ruby )
outStream = rubyOpenOutput( sourceFileName );
- }
- else if ( hostLang->lang == HostLang::CSharp ) {
- hostLang = &hostLangCSharp;
+ else if ( hostLang->lang == HostLang::CSharp )
outStream = csharpOpenOutput( sourceFileName );
- }
else {
assert( false );
}
}
}
+void XmlParser::close_ragel_def()
+{
+ /* Do this before distributing transitions out to singles and defaults
+ * makes life easier. */
+ cgd->redFsm->maxKey = cgd->findMaxKey();
+
+ cgd->redFsm->assignActionLocs();
+
+ /* Find the first final state (The final state with the lowest id). */
+ cgd->redFsm->findFirstFinState();
+
+ /* Call the user's callback. */
+ cgd->finishRagelDef();
+}
+
%%{
parser XmlParser;
nonterm tag_write_head
{
- GenInputLoc loc;
+ InputLoc loc;
};
tag_write_head: TAG_write
tag_text: TAG_text '/' TAG_text
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Text );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Text );
$$->inlineItem->data = $3->tag->content;
};
tag_goto: TAG_goto '/' TAG_goto
final {
int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Goto );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Goto );
$$->inlineItem->targId = targ;
};
tag_call: TAG_call '/' TAG_call
final {
int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Call );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Call );
$$->inlineItem->targId = targ;
};
tag_next: TAG_next '/' TAG_next
final {
int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Next );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Next );
$$->inlineItem->targId = targ;
};
tag_goto_expr: TAG_goto_expr inline_list '/' TAG_goto_expr
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::GotoExpr );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::GotoExpr );
$$->inlineItem->children = $2->inlineList;
};
tag_call_expr: TAG_call_expr inline_list '/' TAG_call_expr
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::CallExpr );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::CallExpr );
$$->inlineItem->children = $2->inlineList;
};
tag_next_expr: TAG_next_expr inline_list '/' TAG_next_expr
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::NextExpr );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::NextExpr );
$$->inlineItem->children = $2->inlineList;
};
tag_ret: TAG_ret '/' TAG_ret
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Ret );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Ret );
};
tag_break: TAG_break '/' TAG_break
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Break );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Break );
};
tag_pchar: TAG_pchar '/' TAG_pchar
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::PChar );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::PChar );
};
tag_char: TAG_char '/' TAG_char
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Char );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Char );
};
tag_hold: TAG_hold '/' TAG_hold
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Hold );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Hold );
};
tag_exec: TAG_exec inline_list '/' TAG_exec
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Exec );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Exec );
$$->inlineItem->children = $2->inlineList;
};
tag_curs: TAG_curs '/' TAG_curs
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Curs );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Curs );
};
tag_targs: TAG_targs '/' TAG_targs
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Targs );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Targs );
};
tag_il_entry: TAG_entry '/' TAG_entry
final {
int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Entry );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::Entry );
$$->inlineItem->targId = targ;
};
tag_init_tokstart: TAG_init_tokstart '/' TAG_init_tokstart
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmInitTokStart );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmInitTokStart );
};
tag_init_act: TAG_init_act '/' TAG_init_act
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmInitAct );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmInitAct );
};
tag_get_tokend: TAG_get_tokend '/' TAG_get_tokend
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmGetTokEnd );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmGetTokEnd );
};
tag_set_tokstart: TAG_set_tokstart '/' TAG_set_tokstart
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetTokStart );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmSetTokStart );
cgd->hasLongestMatch = true;
};
tag_set_tokend: TAG_set_tokend '/' TAG_set_tokend
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetTokEnd );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmSetTokEnd );
$$->inlineItem->offset = strtol( $3->tag->content, 0, 10 );
};
tag_set_act: TAG_set_act '/' TAG_set_act
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetActId );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmSetActId );
$$->inlineItem->lmId = strtol( $3->tag->content, 0, 10 );
};
tag_sub_action: TAG_sub_action inline_list '/' TAG_sub_action
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::SubAction );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::SubAction );
$$->inlineItem->children = $2->inlineList;
};
# Action switches.
tag_lm_switch: TAG_lm_switch lm_action_list '/' TAG_lm_switch
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSwitch );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::LmSwitch );
$$->inlineItem->children = $2->inlineList;
};
tag_inline_action: TAG_sub_action inline_list '/' TAG_sub_action
final {
- $$->inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::SubAction );
+ $$->inlineItem = new GenInlineItem( InputLoc(), GenInlineItem::SubAction );
$$->inlineItem->children = $2->inlineList;
Attribute *idAttr = $1->tag->findAttr( "id" );
return strtol( td, end, 10 );
}
-ostream &XmlParser::warning( const GenInputLoc &loc )
+ostream &XmlParser::warning( const InputLoc &loc )
{
cerr << fileName << ":" << loc.line << ":" << loc.col << ": warning: ";
return cerr;
}
-ostream &XmlParser::error( const GenInputLoc &loc )
+ostream &XmlParser::error( const InputLoc &loc )
{
gblErrorCount += 1;
assert( fileName != 0 );
return cerr;
}
-ostream &XmlParser::source_error( const GenInputLoc &loc )
+ostream &XmlParser::source_error( const InputLoc &loc )
{
gblErrorCount += 1;
assert( sourceFileName != 0 );
calcIndexSize();
}
-ostream &FsmCodeGen::source_warning( const GenInputLoc &loc )
+ostream &FsmCodeGen::source_warning( const InputLoc &loc )
{
cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: ";
return cerr;
}
-ostream &FsmCodeGen::source_error( const GenInputLoc &loc )
+ostream &FsmCodeGen::source_error( const InputLoc &loc )
{
gblErrorCount += 1;
assert( sourceFileName != 0 );
virtual string CTRL_FLOW() = 0;
- ostream &source_warning(const GenInputLoc &loc);
- ostream &source_error(const GenInputLoc &loc);
+ ostream &source_warning(const InputLoc &loc);
+ ostream &source_error(const InputLoc &loc);
unsigned int arrayTypeSize( unsigned long maxVal );
#include "config.h"
#include "common.h"
-#define PROGNAME "rlgen-cd"
-
extern CodeStyleEnum codeStyle;
/* IO filenames and stream. */
calcIndexSize();
}
-ostream &CSharpFsmCodeGen::source_warning( const GenInputLoc &loc )
+ostream &CSharpFsmCodeGen::source_warning( const InputLoc &loc )
{
cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: ";
return cerr;
}
-ostream &CSharpFsmCodeGen::source_error( const GenInputLoc &loc )
+ostream &CSharpFsmCodeGen::source_error( const InputLoc &loc )
{
gblErrorCount += 1;
assert( sourceFileName != 0 );
virtual string CTRL_FLOW() = 0;
- ostream &source_warning(const GenInputLoc &loc);
- ostream &source_error(const GenInputLoc &loc);
+ ostream &source_warning(const InputLoc &loc);
+ ostream &source_error(const InputLoc &loc);
unsigned int arrayTypeSize( unsigned long maxVal );
extern int numSplitPartitions;
extern bool noLineDirectives;
-/* Print a summary of the options. */
-void csharp_usage()
-{
- cout <<
-"usage: " PROGNAME " [options] file\n"
-"general:\n"
-" -h, -H, -?, --help Print this usage and exit\n"
-" -v, --version Print version information and exit\n"
-" -o <file> Write output to <file>\n"
-"code generation options:\n"
-" -L Inhibit writing of #line directives\n"
-"generated code style:\n"
-" -T0 Table driven FSM (default)\n"
-" -T1 Faster table driven FSM\n"
-" -F0 Flat table driven FSM\n"
-" -F1 Faster flat table-driven FSM\n"
-" -G0 Goto-driven FSM\n"
-" -G1 Faster goto-driven FSM\n"
- ;
-}
-
-/* Print version information. */
-void csharp_version()
-{
- cout << "Ragel Code Generator for C#" << endl <<
- "Version " VERSION << ", " PUBDATE << endl <<
- "Copyright (c) 2001-2007 by Adrian Thurston" << endl;
-}
-
-ostream &csharp_error()
-{
- gblErrorCount += 1;
- cerr << PROGNAME ": ";
- return cerr;
-}
-
/*
* Callbacks invoked by the XML data parser.
*/
ostream *csharpOpenOutput( const char *inputFile )
{
if ( hostLang->lang != HostLang::CSharp ) {
- csharp_error() << "this code generator is for C# only" << endl;
+ error() << "this code generator is for C# only" << endl;
exit(1);
}
/* Make sure we are not writing to the same file as the input file. */
if ( outputFileName != 0 && strcmp( inputFile, outputFileName ) == 0 ) {
- csharp_error() << "output file \"" << outputFileName <<
+ error() << "output file \"" << outputFileName <<
"\" is the same as the input file" << endl;
}
outFilter = new output_filter( outputFileName );
outFilter->open( outputFileName, ios::out|ios::trunc );
if ( !outFilter->is_open() ) {
- csharp_error() << "error opening " << outputFileName << " for writing" << endl;
+ error() << "error opening " << outputFileName << " for writing" << endl;
exit(1);
}
#include "config.h"
#include "common.h"
-#define PROGNAME "rlgen-csharp"
-
extern CodeStyleEnum codeStyle;
using namespace std;
/* Override this so that write statement processing is ignored */
-void GraphvizDotGen::writeStatement( GenInputLoc &, int, char ** )
+void GraphvizDotGen::writeStatement( InputLoc &, int, char ** )
{
}
void writeDotFile( );
virtual void finishRagelDef();
- virtual void writeStatement( GenInputLoc &, int, char ** );
+ virtual void writeStatement( InputLoc &, int, char ** );
private:
/* Writing labels and actions. */
#include "vector.h"
#include "config.h"
-#define PROGNAME "rlgen-dot"
-
/* IO filenames and stream. */
extern bool displayPrintables;
extern bool graphvizDone;
calcIndexSize();
}
-ostream &JavaTabCodeGen::source_warning( const GenInputLoc &loc )
+ostream &JavaTabCodeGen::source_warning( const InputLoc &loc )
{
cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: ";
return cerr;
}
-ostream &JavaTabCodeGen::source_error( const GenInputLoc &loc )
+ostream &JavaTabCodeGen::source_error( const InputLoc &loc )
{
gblErrorCount += 1;
assert( sourceFileName != 0 );
string ERROR_STATE();
string FIRST_FINAL_STATE();
- ostream &source_warning(const GenInputLoc &loc);
- ostream &source_error(const GenInputLoc &loc);
+ ostream &source_warning(const InputLoc &loc);
+ ostream &source_error(const InputLoc &loc);
unsigned int arrayTypeSize( unsigned long maxVal );
#include <iostream>
#include "config.h"
-#define PROGNAME "rlgen-java"
-
extern int gblErrorCount;
std::ostream &error();
#include "config.h"
#include "common.h"
-#define PROGNAME "rlgen-ruby"
-
extern RubyImplEnum rubyImpl;
extern CodeStyleEnum codeStyle;
return act;
}
-ostream &RubyCodeGen::source_warning( const GenInputLoc &loc )
+ostream &RubyCodeGen::source_warning( const InputLoc &loc )
{
cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: ";
return cerr;
}
-ostream &RubyCodeGen::source_error( const GenInputLoc &loc )
+ostream &RubyCodeGen::source_error( const InputLoc &loc )
{
gblErrorCount += 1;
assert( sourceFileName != 0 );
void SUB_ACTION( ostream &ret, GenInlineItem *item, int targState, bool inFinish );
protected:
- ostream &source_warning(const GenInputLoc &loc);
- ostream &source_error(const GenInputLoc &loc);
+ ostream &source_warning(const InputLoc &loc);
+ ostream &source_error(const InputLoc &loc);
/* fields */