"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/inputdata.cc" between
ragel-7.0.0.11.tar.gz and ragel-7.0.0.12.tar.gz

About: Ragel compiles executable finite state machines from regular languages (C, C++, Obj-C, C#, D, Java, Go and Ruby). Development version.

inputdata.cc  (ragel-7.0.0.11):inputdata.cc  (ragel-7.0.0.12)
skipping to change at line 230 skipping to change at line 230
switch ( ii->type ) { switch ( ii->type ) {
case InputItem::Write: { case InputItem::Write: {
CodeGenData *cgd = ii->pd->cgd; CodeGenData *cgd = ii->pd->cgd;
cgd->writeStatement( ii->loc, ii->writeArgs.size(), cgd->writeStatement( ii->loc, ii->writeArgs.size(),
ii->writeArgs, generateDot, hostLang ); ii->writeArgs, generateDot, hostLang );
break; break;
} }
case InputItem::HostData: { case InputItem::HostData: {
switch ( hostLang->backend ) { switch ( hostLang->backend ) {
case Direct: case Direct:
if ( hostLang->_lang == HostLang::C ) { if ( ii->loc.fileName != 0 ) {
if ( ii->loc.fileName != 0 ) { if ( ii->prev != 0 )
if ( !noLineDirectives ) *outStream << "\n";
{ (*hostLang->genLineDirective)( *o
*outStream << "\n utStream, !noLineDirectives, ii->loc.line, ii->loc.fileName );
#line " << ii->loc.line <<
"
\"" << ii->loc.fileName << "\"\n";
}
}
} }
*outStream << ii->data.str(); *outStream << ii->data.str();
break; break;
case Translated: case Translated:
openHostBlock( '@', this, *outStream, inp utFileName, ii->loc.line ); openHostBlock( '@', this, *outStream, inp utFileName, ii->loc.line );
translatedHostData( *outStream, ii->data. str() ); translatedHostData( *outStream, ii->data. str() );
*outStream << "}@"; *outStream << "}@";
break; break;
} }
skipping to change at line 479 skipping to change at line 476
assert( errorCount == 0 ); assert( errorCount == 0 );
} }
#endif #endif
bool InputData::parseReduce() bool InputData::parseReduce()
{ {
/* /*
* Colm-based reduction parser introduced in ragel 7. * Colm-based reduction parser introduced in ragel 7.
*/ */
TopLevel *topLevel = new TopLevel( this, hostLang, TopLevel *topLevel = new TopLevel( frontendSections, this, hostLang,
minimizeLevel, minimizeOpt ); minimizeLevel, minimizeOpt );
/* Check input file. File is actually opened by colm code. We don't /* Check input file. File is actually opened by colm code. We don't
* need to perform the check if in libragel since it comes in via a * need to perform the check if in libragel since it comes in via a
* string. */ * string. */
if ( input == 0 ) { if ( input == 0 ) {
ifstream *inFile = new ifstream( inputFileName ); ifstream *inFile = new ifstream( inputFileName );
if ( ! inFile->is_open() ) if ( ! inFile->is_open() )
error() << "could not open " << inputFileName << " for re ading" << endp; error() << "could not open " << inputFileName << " for re ading" << endp;
delete inFile; delete inFile;
skipping to change at line 629 skipping to change at line 626
" --breadth-check=E1,E2,.. Report breadth cost of named entry points and\n " " --breadth-check=E1,E2,.. Report breadth cost of named entry points and\n "
" the start state.\n" " the start state.\n"
" --input-histogram=FN Input char histogram for breadth check. If\n" " --input-histogram=FN Input char histogram for breadth check. If\n"
" unspecified a flat histogram is used.\n" " unspecified a flat histogram is used.\n"
"testing:\n" "testing:\n"
" --kelbt-frontend Compile using original ragel + kelbt frontend\n" " --kelbt-frontend Compile using original ragel + kelbt frontend\n"
" Requires ragel be built with ragel + kelbt support\n " " Requires ragel be built with ragel + kelbt support\n "
" --colm-frontend Compile using a colm-based recursive descent\n" " --colm-frontend Compile using a colm-based recursive descent\n"
" frontend\n" " frontend\n"
" --reduce-frontend Compile using a colm-based reducer (default)\n" " --reduce-frontend Compile using a colm-based reducer (default)\n"
" --direct-backend Use the direct backend for supported langs (default) " --var-backend Use the variable-based backend even if the host lang
\n" \n"
" --colm-backend Use the translation backed for C\n" " supports goto-based\n"
" --var-backend Use the variable-based backend for langs that\n"
" support goto-based\n"
" --goto-backend Use the goto-based backend for supported langs\n"
" (default)\n"
" --supported-host-langs Show supported host languages by command line arg\n" " --supported-host-langs Show supported host languages by command line arg\n"
" --supported-frontends Show supported frontends\n" " --supported-frontends Show supported frontends\n"
" --supported-backends Show supported backends\n" " --supported-backends Show supported backends\n"
" --force-libragel Cause mainline to behave like libragel\n" " --force-libragel Cause mainline to behave like libragel\n"
; ;
abortCompile( 0 ); abortCompile( 0 );
} }
/* Print version information and exit. */ /* Print version information and exit. */
void InputData::version() void InputData::version()
{ {
info() << "Ragel State Machine Compiler version " VERSION << " " PUBDATE << endl << info() << "Ragel State Machine Compiler version " VERSION << " " PUBDATE << endl <<
"Copyright (c) 2001-2018 by Adrian Thurston" << endl; "Copyright (c) 2001-2019 by Adrian Thurston" << endl;
abortCompile( 0 );
}
void InputData::showHostLangNames()
{
ostream &out = info();
for ( int i = 0; i < numHostLangs; i++ ) {
if ( i > 0 )
out << " ";
out << hostLangs[i]->name;
}
out << endl;
abortCompile( 0 );
}
void InputData::showHostLangArgs()
{
ostream &out = info();
for ( int i = 0; i < numHostLangs; i++ ) {
if ( i > 0 )
out << " ";
out << hostLangs[i]->arg;
}
out << endl;
abortCompile( 0 ); abortCompile( 0 );
} }
void InputData::showFrontends() void InputData::showFrontends()
{ {
ostream &out = info(); ostream &out = info();
out << "--colm-frontend"; out << "--colm-frontend";
out << " --reduce-frontend"; out << " --reduce-frontend";
#ifdef WITH_RAGEL_KELBT #ifdef WITH_RAGEL_KELBT
out << " --kelbt-frontend"; out << " --kelbt-frontend";
skipping to change at line 713 skipping to change at line 682
for ( char *pc = path; *pc != 0; pc++ ) { for ( char *pc = path; *pc != 0; pc++ ) {
if ( *pc == '\\' ) if ( *pc == '\\' )
out << "\\\\"; out << "\\\\";
else else
out << *pc; out << *pc;
} }
} }
void InputData::parseArgs( int argc, const char **argv ) void InputData::parseArgs( int argc, const char **argv )
{ {
ParamCheck pc( "r:o:dnmleabjkS:M:I:CEJZRAOKUYvHh?-:sT:F:G:LpV", argc, arg v ); ParamCheck pc( "o:dnmleabjkS:M:I:vHh?-:sT:F:W:G:LpV", argc, argv );
/* Decide if we were invoked using a path variable, or with an explicit p ath. */ /* Decide if we were invoked using a path variable, or with an explicit p ath. */
const char *lastSlash = strrchr( argv[0], '/' ); const char *lastSlash = strrchr( argv[0], '/' );
if ( lastSlash == 0 ) { if ( lastSlash == 0 ) {
/* Defualt to the the binary install location. */ /* Defualt to the the binary install location. */
dirName = BINDIR; dirName = BINDIR;
} }
else { else {
/* Compute dirName from argv0. */ /* Compute dirName from argv0. */
dirName = string( argv[0], lastSlash - argv[0] ); dirName = string( argv[0], lastSlash - argv[0] );
skipping to change at line 820 skipping to change at line 789
break; break;
case 'I': case 'I':
if ( *pc.paramArg == 0 ) if ( *pc.paramArg == 0 )
error() << "please specify an argument to -I" << endl; error() << "please specify an argument to -I" << endl;
else { else {
includePaths.append( pc.paramArg ); includePaths.append( pc.paramArg );
} }
break; break;
/* Host language types. */
case 'C':
hostLang = &hostLangC;
break;
// case 'D':
// hostLang = &hostLangD;
// break;
// case 'Z':
// hostLang = &hostLangGo;
// break;
// case 'J':
// hostLang = &hostLangJava;
// break;
// case 'R':
// hostLang = &hostLangRuby;
// break;
// case 'A':
// hostLang = &hostLangCSharp;
// break;
// case 'O':
// hostLang = &hostLangOCaml;
// break;
// case 'K':
// hostLang = &hostLangCrack;
// break;
// case 'U':
// hostLang = &hostLangRust;
// break;
// case 'Y':
// hostLang = &hostLangJulia;
// break;
// case 'P':
// hostLang = &hostLangJS;
// break;
/* Version and help. */ /* Version and help. */
case 'v': case 'v':
version(); version();
break; break;
case 'H': case 'h': case '?': case 'H': case 'h': case '?':
usage(); usage();
break; break;
case 's': case 's':
printStatistics = true; printStatistics = true;
break; break;
skipping to change at line 886 skipping to change at line 820
else if ( strcmp( arg, "error-format" ) == 0 ) { else if ( strcmp( arg, "error-format" ) == 0 ) {
if ( eq == 0 ) if ( eq == 0 )
error() << "expecting '=value' fo r error-format" << endl; error() << "expecting '=value' fo r error-format" << endl;
else if ( strcmp( eq, "gnu" ) == 0 ) else if ( strcmp( eq, "gnu" ) == 0 )
errorFormat = ErrorFormatGNU; errorFormat = ErrorFormatGNU;
else if ( strcmp( eq, "msvc" ) == 0 ) else if ( strcmp( eq, "msvc" ) == 0 )
errorFormat = ErrorFormatMSVC; errorFormat = ErrorFormatMSVC;
else else
error() << "invalid value for err or-format" << endl; error() << "invalid value for err or-format" << endl;
} }
else if ( strcmp( arg, "rbx" ) == 0 )
rubyImpl = Rubinius;
else if ( strcmp( arg, "rlhc" ) == 0 ) else if ( strcmp( arg, "rlhc" ) == 0 )
rlhc = true; rlhc = true;
else if ( strcmp( arg, "no-intermediate" ) == 0 ) else if ( strcmp( arg, "no-intermediate" ) == 0 )
noIntermediate = true; noIntermediate = true;
#ifdef WITH_RAGEL_KELBT #ifdef WITH_RAGEL_KELBT
else if ( strcmp( arg, "kelbt-frontend" ) == 0 ) { else if ( strcmp( arg, "kelbt-frontend" ) == 0 ) {
frontend = KelbtBased; frontend = KelbtBased;
frontendSpecified = true; frontendSpecified = true;
} }
#else #else
skipping to change at line 911 skipping to change at line 843
} }
#endif #endif
else if ( strcmp( arg, "reduce-frontend" ) == 0 ) { else if ( strcmp( arg, "reduce-frontend" ) == 0 ) {
frontend = ReduceBased; frontend = ReduceBased;
frontendSpecified = true; frontendSpecified = true;
} }
else if ( strcmp( arg, "string-tables" ) == 0 ) else if ( strcmp( arg, "string-tables" ) == 0 )
stringTables = true; stringTables = true;
else if ( strcmp( arg, "integral-tables" ) == 0 ) else if ( strcmp( arg, "integral-tables" ) == 0 )
stringTables = false; stringTables = false;
else if ( strcmp( arg, "host-lang-names" ) == 0 )
showHostLangNames();
else if ( strcmp( arg, "host-lang-args" ) == 0 ||
strcmp( arg, "supported-host-lang
s" ) == 0 )
showHostLangArgs();
else if ( strcmp( arg, "supported-frontends" ) == 0 ) else if ( strcmp( arg, "supported-frontends" ) == 0 )
showFrontends(); showFrontends();
else if ( strcmp( arg, "supported-backends" ) == 0 ) else if ( strcmp( arg, "supported-backends" ) == 0 )
showBackends(); showBackends();
else if ( strcmp( arg, "save-temps" ) == 0 ) else if ( strcmp( arg, "save-temps" ) == 0 )
saveTemps = true; saveTemps = true;
else if ( strcmp( arg, "prior-interaction" ) == 0 ) else if ( strcmp( arg, "prior-interaction" ) == 0 )
checkPriorInteraction = true; checkPriorInteraction = true;
else if ( strcmp( arg, "conds-depth" ) == 0 ) else if ( strcmp( arg, "conds-depth" ) == 0 )
condsCheckDepth = strtol( eq, 0, 10 ); condsCheckDepth = strtol( eq, 0, 10 );
else if ( strcmp( arg, "state-limit" ) == 0 ) else if ( strcmp( arg, "state-limit" ) == 0 )
stateLimit = strtol( eq, 0, 10 ); stateLimit = strtol( eq, 0, 10 );
else if ( strcmp( arg, "breadth-check" ) == 0 ) { else if ( strcmp( arg, "breadth-check" ) == 0 ) {
char *ptr = 0; char *ptr = 0;
while ( true ) { while ( true ) {
char *label = strtok_r( eq, ",", &ptr ); char *label = strtok_r( eq, ",", &ptr );
eq = NULL; eq = NULL;
if ( label == NULL ) if ( label == NULL )
break; break;
breadthLabels.append( strdup( lab el ) ); breadthLabels.append( strdup( lab el ) );
} }
checkBreadth = true; checkBreadth = true;
} }
else if ( strcmp( arg, "input-histogram" ) == 0 ) else if ( strcmp( arg, "input-histogram" ) == 0 )
histogramFn = strdup(eq); histogramFn = strdup(eq);
else if ( strcmp( arg, "force-libragel" ) == 0 ) else if ( strcmp( arg, "var-backend" ) == 0 )
forceLibRagel = true; forceVar = true;
else { else {
error() << "--" << pc.paramArg << error() << "--" << pc.paramArg <<
" is an invalid argument" << endl; " is an invalid argument" << endl;
} }
free( arg ); free( arg );
break; break;
} }
/* Passthrough args. */ /* Passthrough args. */
case 'T': case 'T':
skipping to change at line 976 skipping to change at line 905
else if ( pc.paramArg[0] == '1' ) else if ( pc.paramArg[0] == '1' )
codeStyle = GenFlatExp; codeStyle = GenFlatExp;
else { else {
error() << "-F" << pc.paramArg[0] << error() << "-F" << pc.paramArg[0] <<
" is an invalid argument" << endl; " is an invalid argument" << endl;
abortCompile( 1 ); abortCompile( 1 );
} }
break; break;
case 'G': case 'G':
if ( pc.paramArg[0] == '0' ) if ( pc.paramArg[0] == '0' )
codeStyle = GenSwitchLoop; codeStyle = GenGotoLoop;
else if ( pc.paramArg[0] == '1' ) else if ( pc.paramArg[0] == '1' )
codeStyle = GenSwitchExp; codeStyle = GenGotoExp;
else if ( pc.paramArg[0] == '2' ) else if ( pc.paramArg[0] == '2' )
codeStyle = GenIpGoto; codeStyle = GenIpGoto;
else if ( pc.paramArg[0] == 'T' && pc.paramArg[1] == '2' ) { else if ( pc.paramArg[0] == 'T' && pc.paramArg[1] == '2' ) {
codeStyle = GenIpGoto; codeStyle = GenIpGoto;
maxTransitions = 32; maxTransitions = 32;
} else { } else {
error() << "-G" << pc.paramArg[0] << error() << "-G" << pc.paramArg[0] <<
" is an invalid argument" << endl; " is an invalid argument" << endl;
abortCompile( 1 ); abortCompile( 1 );
} }
break; break;
case 'W':
if ( pc.paramArg[0] == '0' )
codeStyle = GenSwitchLoop;
else if ( pc.paramArg[0] == '1' )
codeStyle = GenSwitchExp;
else {
error() << "-G" << pc.paramArg[0] <<
" is an invalid argument"
<< endl;
abortCompile( 1 );
}
break;
case 'p': case 'p':
displayPrintables = true; displayPrintables = true;
break; break;
case 'L': case 'L':
noLineDirectives = true; noLineDirectives = true;
break; break;
} }
break; break;
skipping to change at line 1156 skipping to change at line 1096
struct colm_program *prg; struct colm_program *prg;
int exit_status; int exit_status;
prg = colm_new_program( rlhcSections ); prg = colm_new_program( rlhcSections );
colm_set_debug( prg, 0 ); colm_set_debug( prg, 0 );
colm_run_program( prg, argc, argv ); colm_run_program( prg, argc, argv );
exit_status = colm_delete_program( prg ); exit_status = colm_delete_program( prg );
return exit_status; return exit_status;
} }
int InputData::rlhcMain( int argc, const char **argv ) void InputData::wait( const char *what, pid_t pid )
{ {
int status = 0; int status = 0;
waitpid( pid, &status, 0 );
if ( WIFSIGNALED(status) )
error() << what << " stopped by signal: " << WTERMSIG(status) <<
std::endl;
}
int InputData::rlhcMain( int argc, const char **argv )
{
pid_t pid = 0; pid_t pid = 0;
parseArgs( argc, argv ); parseArgs( argc, argv );
checkArgs(); checkArgs();
makeDefaultFileName(); makeDefaultFileName();
makeTranslateOutputFileName(); makeTranslateOutputFileName();
pid = fork(); pid = fork();
if ( pid == 0 ) { if ( pid == 0 ) {
/* Child. */ /* Child. */
if ( !process() ) if ( !process() )
abortCompile( 1 ); abortCompile( 1 );
exit( 0 ); exit( 0 );
} }
waitpid( pid, &status, 0 ); wait( "frontend", pid );
pid = fork(); pid = fork();
if ( pid == 0 ) { if ( pid == 0 ) {
/* rlhc <input> <output> */ /* rlhc <input> <output> */
const char *_argv[] = { "rlhc", const char *_argv[] = { "rlhc",
genOutputFileName.c_str(), genOutputFileName.c_str(),
origOutputFileName.c_str(), 0 }; origOutputFileName.c_str(), 0 };
rlhcRun( 3, _argv ); rlhcRun( 3, _argv );
} }
waitpid( pid, &status, 0 ); wait( "rlhc", pid );
return 0; return 0;
} }
 End of changes. 18 change blocks. 
94 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)