bool wantDupsRemoved = true;
bool printStatistics = false;
-bool frontendOnly = false;
+bool generateXML = false;
bool generateDot = false;
/* Target language and output style. */
void version()
{
cout << "Ragel State Machine Compiler version " VERSION << " " PUBDATE << endl <<
- "Copyright (c) 2001-2008 by Adrian Thurston" << endl;
+ "Copyright (c) 2001-2009 by Adrian Thurston" << endl;
exit(0);
}
break;
case 'x':
- frontendOnly = true;
+ generateXML = true;
break;
/* Output. */
printStatistics = true;
break;
case '-': {
- char *eq = strchr( pc.paramArg, '=' );
+ char *arg = strdup( pc.paramArg );
+ char *eq = strchr( arg, '=' );
if ( eq != 0 )
*eq++ = 0;
- if ( strcmp( pc.paramArg, "help" ) == 0 )
+ if ( strcmp( arg, "help" ) == 0 )
usage();
- else if ( strcmp( pc.paramArg, "version" ) == 0 )
+ else if ( strcmp( arg, "version" ) == 0 )
version();
- else if ( strcmp( pc.paramArg, "error-format" ) == 0 ) {
+ else if ( strcmp( arg, "error-format" ) == 0 ) {
if ( eq == 0 )
error() << "expecting '=value' for error-format" << endl;
else if ( strcmp( eq, "gnu" ) == 0 )
else
error() << "invalid value for error-format" << endl;
}
- else if ( strcmp( pc.paramArg, "rbx" ) == 0 )
+ else if ( strcmp( arg, "rbx" ) == 0 )
rubyImpl = Rubinius;
else {
error() << "--" << pc.paramArg <<
" is an invalid argument" << endl;
}
+ free( arg );
break;
}
/* Make the first input item. */
InputItem *firstInputItem = new InputItem;
firstInputItem->type = InputItem::HostData;
+ firstInputItem->loc.fileName = id.inputFileName;
firstInputItem->loc.line = 1;
firstInputItem->loc.col = 1;
id.inputItems.append( firstInputItem );
id.makeOutputStream();
/* Generates the reduced machine, which we use to write output. */
- id.generateReduced();
+ if ( !generateXML ) {
+ id.generateReduced();
+ if ( gblErrorCount > 0 )
+ exit(1);
+ }
+
+ id.verifyWritesHaveData();
if ( gblErrorCount > 0 )
exit(1);
-
+
/*
* From this point on we should not be reporting any errors.
*/
/* Close the input and the intermediate file. */
delete inFile;
- /* Bail on above error. */
- if ( gblErrorCount > 0 )
- exit(1);
-
/* If writing to a file, delete the ostream, causing it to flush.
* Standard out is flushed automatically. */
if ( id.outputFileName != 0 ) {
{
char *result = 0;
const char *templ = "ragel-XXXXXX.xml";
- char *lastSlash = strrchr( baseFileName, '/' );
+ const char *lastSlash = strrchr( baseFileName, '/' );
if ( lastSlash == 0 ) {
result = new char[strlen(templ)+1];
strcpy( result, templ );
processArgs( argc, argv, id );
- /* If -M or -S are given and we're not generating a dot file then invoke
- * the frontend. These options are not useful with code generators. */
- if ( machineName != 0 || machineSpec != 0 ) {
- if ( !generateDot )
- frontendOnly = true;
- }
-
/* Require an input file. If we use standard in then we won't have a file
* name on which to base the output. */
if ( id.inputFileName == 0 )