parsedata.cc (ragel-7.0.0.11) | : | parsedata.cc (ragel-7.0.0.12) | ||
---|---|---|---|---|
skipping to change at line 1017 | skipping to change at line 1017 | |||
set = false; | set = false; | |||
return set; | return set; | |||
} | } | |||
/* Initialize the key operators object that will be referenced by all fsms | /* Initialize the key operators object that will be referenced by all fsms | |||
* created. */ | * created. */ | |||
void ParseData::initKeyOps( const HostLang *hostLang ) | void ParseData::initKeyOps( const HostLang *hostLang ) | |||
{ | { | |||
/* Signedness and bounds. */ | /* Signedness and bounds. */ | |||
alphType = alphTypeSet ? userAlphType : hostLang->defaultAlphType; | alphType = alphTypeSet ? userAlphType : &hostLang->hostTypes[hostLang->de faultAlphType]; | |||
fsmCtx->keyOps->setAlphType( hostLang, alphType ); | fsmCtx->keyOps->setAlphType( hostLang, alphType ); | |||
if ( lowerNum != 0 ) { | if ( lowerNum != 0 ) { | |||
/* If ranges are given then interpret the alphabet type. */ | /* If ranges are given then interpret the alphabet type. */ | |||
fsmCtx->keyOps->minKey = makeFsmKeyNum( lowerNum, rangeLowLoc, th is ); | fsmCtx->keyOps->minKey = makeFsmKeyNum( lowerNum, rangeLowLoc, th is ); | |||
fsmCtx->keyOps->maxKey = makeFsmKeyNum( upperNum, rangeHighLoc, t his ); | fsmCtx->keyOps->maxKey = makeFsmKeyNum( upperNum, rangeHighLoc, t his ); | |||
} | } | |||
} | } | |||
void ParseData::printNameInst( std::ostream &out, NameInst *nameInst, int level ) | void ParseData::printNameInst( std::ostream &out, NameInst *nameInst, int level ) | |||
skipping to change at line 1098 | skipping to change at line 1098 | |||
/* The action will also need an ordering: ahead of all user actio n | /* The action will also need an ordering: ahead of all user actio n | |||
* embeddings. */ | * embeddings. */ | |||
initTokStartOrd = fsmCtx->curActionOrd++; | initTokStartOrd = fsmCtx->curActionOrd++; | |||
initActIdOrd = fsmCtx->curActionOrd++; | initActIdOrd = fsmCtx->curActionOrd++; | |||
setTokStartOrd = fsmCtx->curActionOrd++; | setTokStartOrd = fsmCtx->curActionOrd++; | |||
setTokEndOrd = fsmCtx->curActionOrd++; | setTokEndOrd = fsmCtx->curActionOrd++; | |||
} | } | |||
} | } | |||
/* After building the graph, do some extra processing to ensure the runtime | /* After building the graph, do some extra processing to ensure the runtime | |||
* data of the longest mactch operators is consistent. */ | * data of the longest mactch operators is consistent. We want tokstart to be | |||
void ParseData::setLongestMatchData( FsmAp *graph ) | * null when no token match is active. */ | |||
void ParseData::longestMatchInitTweaks( FsmAp *graph ) | ||||
{ | { | |||
if ( lmList.length() > 0 ) { | if ( lmList.length() > 0 ) { | |||
/* Make sure all entry points (targets of fgoto, fcall, fnext, fe ntry) | /* Make sure all entry points (targets of fgoto, fcall, fnext, fe ntry) | |||
* init the tokstart. */ | * init the tokstart. */ | |||
for ( EntryMap::Iter en = graph->entryPoints; en.lte(); en++ ) { | for ( EntryMap::Iter en = graph->entryPoints; en.lte(); en++ ) { | |||
/* This is run after duplicates are removed, we must guar d against | /* This is run after duplicates are removed, we must guar d against | |||
* inserting a duplicate. */ | * inserting a duplicate. */ | |||
ActionTable &actionTable = en->value->toStateActionTable; | ActionTable &actionTable = en->value->toStateActionTable; | |||
if ( ! actionTable.hasAction( initTokStart ) ) | if ( ! actionTable.hasAction( initTokStart ) ) { | |||
/* We do this after the analysis pass, which refe | ||||
rence counts | ||||
* the actions. Keep them up to date so we don't | ||||
break the | ||||
* build. */ | ||||
initTokStart->numToStateRefs += 1; | ||||
actionTable.setAction( initTokStartOrd, initTokSt art ); | actionTable.setAction( initTokStartOrd, initTokSt art ); | |||
} | ||||
} | } | |||
/* Find the set of states that are the target of transitions with | /* Find the set of states that are the target of transitions with | |||
* actions that have calls. These states will be targeted by fret | * actions that have calls. These states will be targeted by fret | |||
* statements. */ | * statements. */ | |||
StateSet states; | StateSet states; | |||
for ( StateList::Iter state = graph->stateList; state.lte(); stat e++ ) { | for ( StateList::Iter state = graph->stateList; state.lte(); stat e++ ) { | |||
for ( TransList::Iter trans = state->outList; trans.lte() ; trans++ ) { | for ( TransList::Iter trans = state->outList; trans.lte() ; trans++ ) { | |||
if ( trans->plain() ) { | if ( trans->plain() ) { | |||
for ( ActionTable::Iter ati = trans->tdap ()->actionTable; ati.lte(); ati++ ) { | for ( ActionTable::Iter ati = trans->tdap ()->actionTable; ati.lte(); ati++ ) { | |||
skipping to change at line 1140 | skipping to change at line 1146 | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
/* Init tokstart upon entering the above collected states. */ | /* Init tokstart upon entering the above collected states. */ | |||
for ( StateSet::Iter ps = states; ps.lte(); ps++ ) { | for ( StateSet::Iter ps = states; ps.lte(); ps++ ) { | |||
/* This is run after duplicates are removed, we must guar d against | /* This is run after duplicates are removed, we must guar d against | |||
* inserting a duplicate. */ | * inserting a duplicate. */ | |||
ActionTable &actionTable = (*ps)->toStateActionTable; | ActionTable &actionTable = (*ps)->toStateActionTable; | |||
if ( ! actionTable.hasAction( initTokStart ) ) | if ( ! actionTable.hasAction( initTokStart ) ) { | |||
/* We do this after the analysis pass, which refe | ||||
rence counts | ||||
* the actions. Keep them up to date so we don't | ||||
break the | ||||
* build. */ | ||||
initTokStart->numToStateRefs += 1; | ||||
actionTable.setAction( initTokStartOrd, initTokSt art ); | actionTable.setAction( initTokStartOrd, initTokSt art ); | |||
} | ||||
} | } | |||
} | } | |||
} | } | |||
/* Always returns the breadth check result. Will not consume the fsm. */ | /* Always returns the breadth check result. Will not consume the fsm. */ | |||
BreadthResult *ParseData::checkBreadth( FsmAp *fsm ) | BreadthResult *ParseData::checkBreadth( FsmAp *fsm ) | |||
{ | { | |||
double start = 0; | double start = 0; | |||
int minDepth = 0; | int minDepth = 0; | |||
FsmAp::breadthFromEntry( start, minDepth, id->histogram, fsm, fsm->startS tate ); | FsmAp::breadthFromEntry( start, minDepth, id->histogram, fsm, fsm->startS tate ); | |||
skipping to change at line 1420 | skipping to change at line 1431 | |||
sectionGraph = res.fsm; | sectionGraph = res.fsm; | |||
} | } | |||
/* If any errors have occured in the input file then don't write anything . */ | /* If any errors have occured in the input file then don't write anything . */ | |||
if ( id->errorCount > 0 ) | if ( id->errorCount > 0 ) | |||
return FsmRes( FsmRes::InternalError() ); | return FsmRes( FsmRes::InternalError() ); | |||
fsmCtx->analyzeGraph( sectionGraph ); | fsmCtx->analyzeGraph( sectionGraph ); | |||
/* Depends on the graph analysis. */ | /* Depends on the graph analysis. */ | |||
setLongestMatchData( sectionGraph ); | longestMatchInitTweaks( sectionGraph ); | |||
fsmCtx->prepareReduction( sectionGraph ); | fsmCtx->prepareReduction( sectionGraph ); | |||
return FsmRes( FsmRes::Fsm(), sectionGraph ); | return FsmRes( FsmRes::Fsm(), sectionGraph ); | |||
} | } | |||
void ParseData::generateReduced( const char *inputFileName, CodeStyle codeStyle, | void ParseData::generateReduced( const char *inputFileName, CodeStyle codeStyle, | |||
std::ostream &out, const HostLang *hostLang ) | std::ostream &out, const HostLang *hostLang ) | |||
{ | { | |||
Reducer *red = new Reducer( this->id, fsmCtx, sectionGraph, sectionName, machineId ); | Reducer *red = new Reducer( this->id, fsmCtx, sectionGraph, sectionName, machineId ); | |||
red->make( hostLang, alphType ); | red->make( hostLang, alphType ); | |||
CodeGenArgs args( this->id, red, alphType, machineId, inputFileName, sect ionName, out, codeStyle ); | CodeGenArgs args( this->id, red, alphType, machineId, inputFileName, sect ionName, out, codeStyle ); | |||
args.lineDirectives = !id->noLineDirectives; | args.lineDirectives = !id->noLineDirectives; | |||
args.forceVar = id->forceVar; | ||||
args.loopLabels = hostLang->loopLabels; | ||||
/* Write out with it. */ | /* Write out with it. */ | |||
cgd = (*hostLang->makeCodeGen)( hostLang, args ); | cgd = (*hostLang->makeCodeGen)( hostLang, args ); | |||
/* Code generation anlysis step. */ | /* Code generation anlysis step. */ | |||
cgd->genAnalysis(); | cgd->genAnalysis(); | |||
} | } | |||
#if 0 | #if 0 | |||
void ParseData::generateXML( ostream &out ) | void ParseData::generateXML( ostream &out ) | |||
End of changes. 8 change blocks. | ||||
6 lines changed or deleted | 23 lines changed or added |