"Fossies" - the Fresh Open Source Software Archive  

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

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

reducer.cc  (ragel-7.0.0.10):reducer.cc  (ragel-7.0.0.11)
/* /*
* Copyright 2015 Adrian Thurston <thurston@colm.net> * Copyright 2015-2018 Adrian Thurston <thurston@colm.net>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the * deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is * sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in al l * The above copyright notice and this permission notice shall be included in al l
* copies or substantial portions of the Software. * copies or substantial portions of the Software.
skipping to change at line 32 skipping to change at line 32
#include "reducer.h" #include "reducer.h"
#include <colm/colm.h> #include <colm/colm.h>
#include <colm/tree.h> #include <colm/tree.h>
#include <errno.h> #include <errno.h>
using std::endl; using std::endl;
using std::ifstream; using std::ifstream;
extern colm_sections rlparse_object; extern colm_sections rl_parse;
void TopLevel::loadMachineName( string data ) void TopLevel::loadMachineName( string data )
{ {
/* Make/get the priority key. The name may have already been referenced /* Make/get the priority key. The name may have already been referenced
* and therefore exist. */ * and therefore exist. */
PriorDictEl *priorDictEl; PriorDictEl *priorDictEl;
if ( pd->priorDict.insert( data, pd->fsmCtx->nextPriorKey, &priorDictEl ) ) if ( pd->priorDict.insert( data, pd->fsmCtx->nextPriorKey, &priorDictEl ) )
pd->fsmCtx->nextPriorKey += 1; pd->fsmCtx->nextPriorKey += 1;
pd->curDefPriorKey = priorDictEl->value; pd->curDefPriorKey = priorDictEl->value;
skipping to change at line 109 skipping to change at line 109
{ {
/* Stash the current section name and pd. */ /* Stash the current section name and pd. */
string sectionName = pd->sectionName; string sectionName = pd->sectionName;
ParseData *pd0 = pd; ParseData *pd0 = pd;
const char **includeChecks = 0; const char **includeChecks = 0;
long found = 0; long found = 0;
const char *inclSectionName = machine.c_str(); const char *inclSectionName = machine.c_str();
/* Implement defaults for the input file and section name. */ /* Default the section name to the current section name. */
if ( inclSectionName == 0 ) if ( inclSectionName == 0 )
inclSectionName = sectionName.c_str(); inclSectionName = sectionName.c_str();
/* Build the include checks. */ /* Build the include checks. */
if ( fileSpecified ) if ( fileSpecified )
includeChecks = pd->id->makeIncludePathChecks( curFileName, fileN ame.c_str() ); includeChecks = pd->id->makeIncludePathChecks( curFileName, fileN ame.c_str() );
else { else {
char *test = new char[strlen(curFileName)+1]; char *test = new char[strlen(curFileName)+1];
strcpy( test, curFileName ); strcpy( test, curFileName );
skipping to change at line 158 skipping to change at line 158
const char *targetMachine0 = targetMachine; const char *targetMachine0 = targetMachine;
const char *searchMachine0 = searchMachine; const char *searchMachine0 = searchMachine;
includeDepth += 1; includeDepth += 1;
pd = 0; pd = 0;
targetMachine = sectionName.c_str(); targetMachine = sectionName.c_str();
searchMachine = machine.c_str(); searchMachine = machine.c_str();
reduceFile( includeChecks[found], false ); // reduceFile( includeChecks[found] );
// if ( includePass.incItems.length() == 0 ) { // if ( includePass.incItems.length() == 0 ) {
// pd->id->error(incLoc) << "could not find machine " << machine << // pd->id->error(incLoc) << "could not find machine " << machine <<
// " in " << fileName << endp; // " in " << fileName << endp;
// } // }
// else { // else {
// /* Load the data into include el. Save in the dict. */ // /* Load the data into include el. Save in the dict. */
// loadIncludeData( el, includePass, includeChecks[found] ); // loadIncludeData( el, includePass, includeChecks[found] );
// id->includeDict.insert( el ); // id->includeDict.insert( el );
// includePass.incItems.empty(); // includePass.incItems.empty();
// } // }
pd = pd0; pd = pd0;
includeDepth -= 1; includeDepth -= 1;
targetMachine = targetMachine0; targetMachine = targetMachine0;
searchMachine = searchMachine0; searchMachine = searchMachine0;
} }
void TopLevel::importFile( std::string file )
{
isImport = true;
reduceFile( file.c_str(), true );
isImport = false;
}
void TopLevel::import( const InputLoc &loc, std::string name, Literal *literal ) void TopLevel::import( const InputLoc &loc, std::string name, Literal *literal )
{ {
MachineDef *machineDef = new MachineDef( MachineDef *machineDef = new MachineDef(
new Join( new Join(
new Expression( new Expression(
new Term( new Term(
new FactorWithAug( new FactorWithAug(
new FactorWithRep( new FactorWithRep(
new FactorWithNeg ( new Factor( literal ) ) new FactorWithNeg ( new Factor( literal ) )
) )
skipping to change at line 206 skipping to change at line 199
) )
) )
) )
); );
/* Generic creation of machine for instantiation and assignment. */ /* Generic creation of machine for instantiation and assignment. */
tryMachineDef( loc, name, machineDef, false ); tryMachineDef( loc, name, machineDef, false );
machineDef->join->loc = loc; machineDef->join->loc = loc;
} }
void TopLevel::reduceFile( const char *inputFileName, bool import ) void TopLevel::reduceFile( const char *cmd, const char *inputFileName )
{ {
char idstr[64], imstr[64]; const int baseN = 2;
sprintf( idstr, "%d", includeDepth ); const char **argv = new const char*[baseN + id->includePaths.length() + 1
sprintf( imstr, "%d", import ); ];
argv[0] = cmd;
const char *argv[7];
argv[0] = "rlparse";
argv[1] = inputFileName; argv[1] = inputFileName;
argv[2] = imstr; // Import for ( int i = 0; i < id->includePaths.length(); i++ )
argv[3] = idstr; // IncludeDepth argv[baseN + i] = id->includePaths.data[i];
argv[4] = targetMachine == 0 ? "" : targetMachine; argv[baseN + id->includePaths.length()] = 0;
argv[5] = searchMachine == 0 ? "" : searchMachine;
argv[6] = 0;
const char *prevCurFileName = curFileName; const char *prevCurFileName = curFileName;
curFileName = inputFileName; curFileName = inputFileName;
colm_program *program = colm_new_program( &rlparse_object ); colm_program *program = colm_new_program( &rl_parse );
colm_set_debug( program, 0 ); colm_set_debug( program, 0 );
colm_set_reduce_ctx( program, this ); colm_set_reduce_ctx( program, this );
colm_run_program( program, 6, argv ); colm_run_program( program, baseN + id->includePaths.length(), argv );
id->streamFileNames.append( colm_extract_fns( program ) ); id->streamFileNames.append( colm_extract_fns( program ) );
int length = 0; int length = 0;
const char *err = colm_error( program, &length ); const char *err = colm_error( program, &length );
if ( err != 0 ) { if ( err != 0 ) {
// std::cout << "error" << std::endl; // std::cout << "error" << std::endl;
id->error_plain() << string( err, length ) << std::endl; id->error_plain() << string( err, length ) << std::endl;
} }
colm_delete_program( program ); colm_delete_program( program );
curFileName = prevCurFileName; curFileName = prevCurFileName;
delete[] argv;
} }
 End of changes. 11 change blocks. 
25 lines changed or deleted 16 lines changed or added

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