diff options
author | vvvv <vvvv@ydb.tech> | 2023-07-31 18:21:04 +0300 |
---|---|---|
committer | vvvv <vvvv@ydb.tech> | 2023-07-31 18:21:04 +0300 |
commit | dec41c40e51aa407edef81a3c566a5a15780fc49 (patch) | |
tree | 4f197b596b32f35eca368121f0dff913419da9af /contrib/tools/ragel5/redfsm | |
parent | 3ca8b54c96e09eb2b65be7f09675623438d559c7 (diff) | |
download | ydb-dec41c40e51aa407edef81a3c566a5a15780fc49.tar.gz |
YQL-16239 Move purecalc to public
Diffstat (limited to 'contrib/tools/ragel5/redfsm')
-rw-r--r-- | contrib/tools/ragel5/redfsm/gendata.cpp | 717 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/gendata.h | 167 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/phash.h | 10 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/redfsm.cpp | 559 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/redfsm.h | 534 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/xmlparse.cpp | 3549 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/xmlparse.h | 228 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/xmlscan.cpp | 925 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/xmltags.cpp | 244 | ||||
-rw-r--r-- | contrib/tools/ragel5/redfsm/ya.make | 25 |
10 files changed, 6958 insertions, 0 deletions
diff --git a/contrib/tools/ragel5/redfsm/gendata.cpp b/contrib/tools/ragel5/redfsm/gendata.cpp new file mode 100644 index 0000000000..b0893ccdc2 --- /dev/null +++ b/contrib/tools/ragel5/redfsm/gendata.cpp @@ -0,0 +1,717 @@ +/* + * Copyright 2005-2007 Adrian Thurston <thurston@cs.queensu.ca> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Ragel; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gendata.h" +#include <iostream> + +using std::cerr; +using std::endl; + +CodeGenData::CodeGenData( ostream &out ) +: + sourceFileName(0), + fsmName(0), + out(out), + redFsm(0), + allActions(0), + allActionTables(0), + allConditions(0), + allCondSpaces(0), + allStates(0), + nameIndex(0), + startState(-1), + errState(-1), + getKeyExpr(0), + accessExpr(0), + curStateExpr(0), + wantComplete(0), + hasLongestMatch(false), + codeGenErrCount(0), + hasEnd(true), + dataPrefix(true), + writeFirstFinal(true), + writeErr(true) +{} + + +void CodeGenData::createMachine() +{ + redFsm = new RedFsmAp(); +} + +void CodeGenData::initActionList( unsigned long length ) +{ + allActions = new Action[length]; + for ( unsigned long a = 0; a < length; a++ ) + actionList.append( allActions+a ); +} + +void CodeGenData::newAction( int anum, char *name, int line, + int col, InlineList *inlineList ) +{ + allActions[anum].actionId = anum; + allActions[anum].name = name; + allActions[anum].loc.line = line; + allActions[anum].loc.col = col; + allActions[anum].inlineList = inlineList; +} + +void CodeGenData::initActionTableList( unsigned long length ) +{ + allActionTables = new RedAction[length]; +} + +void CodeGenData::initStateList( unsigned long length ) +{ + allStates = new RedStateAp[length]; + for ( unsigned long s = 0; s < length; s++ ) + redFsm->stateList.append( allStates+s ); + + /* We get the start state as an offset, set the pointer now. */ + if ( startState >= 0 ) + redFsm->startState = allStates + startState; + if ( errState >= 0 ) + redFsm->errState = allStates + errState; + for ( EntryIdVect::Iter en = entryPointIds; en.lte(); en++ ) + redFsm->entryPoints.insert( allStates + *en ); + + /* The nextStateId is no longer used to assign state ids (they come in set + * from the frontend now), however generation code still depends on it. + * Should eventually remove this variable. */ + redFsm->nextStateId = redFsm->stateList.length(); +} + +void CodeGenData::setStartState( unsigned long startState ) +{ + this->startState = startState; +} + +void CodeGenData::setErrorState( unsigned long errState ) +{ + this->errState = errState; +} + +void CodeGenData::addEntryPoint( char *name, unsigned long entryState ) +{ + entryPointIds.append( entryState ); + entryPointNames.append( name ); +} + +void CodeGenData::initTransList( int snum, unsigned long length ) +{ + /* Could preallocate the out range to save time growing it. For now do + * nothing. */ +} + +void CodeGenData::newTrans( int snum, int tnum, Key lowKey, + Key highKey, long targ, long action ) +{ + /* Get the current state and range. */ + RedStateAp *curState = allStates + snum; + RedTransList &destRange = curState->outRange; + + if ( curState == redFsm->errState ) + return; + + /* Make the new transitions. */ + RedStateAp *targState = targ >= 0 ? (allStates + targ) : + wantComplete ? redFsm->getErrorState() : 0; + RedAction *actionTable = action >= 0 ? (allActionTables + action) : 0; + RedTransAp *trans = redFsm->allocateTrans( targState, actionTable ); + RedTransEl transEl( lowKey, highKey, trans ); + + if ( wantComplete ) { + /* If the machine is to be complete then we need to fill any gaps with + * the error transitions. */ + if ( destRange.length() == 0 ) { + /* Range is currently empty. */ + if ( keyOps->minKey < lowKey ) { + /* The first range doesn't start at the low end. */ + Key fillHighKey = lowKey; + fillHighKey.decrement(); + + /* Create the filler with the state's error transition. */ + RedTransEl newTel( keyOps->minKey, fillHighKey, redFsm->getErrorTrans() ); + destRange.append( newTel ); + } + } + else { + /* The range list is not empty, get the the last range. */ + RedTransEl *last = &destRange[destRange.length()-1]; + Key nextKey = last->highKey; + nextKey.increment(); + if ( nextKey < lowKey ) { + /* There is a gap to fill. Make the high key. */ + Key fillHighKey = lowKey; + fillHighKey.decrement(); + + /* Create the filler with the state's error transtion. */ + RedTransEl newTel( nextKey, fillHighKey, redFsm->getErrorTrans() ); + destRange.append( newTel ); + } + } + } + + /* Filler taken care of. Append the range. */ + destRange.append( RedTransEl( lowKey, highKey, trans ) ); +} + +void CodeGenData::finishTransList( int snum ) +{ + /* Get the current state and range. */ + RedStateAp *curState = allStates + snum; + RedTransList &destRange = curState->outRange; + + if ( curState == redFsm->errState ) + return; + + /* If building a complete machine we may need filler on the end. */ + if ( wantComplete ) { + /* Check if there are any ranges already. */ + if ( destRange.length() == 0 ) { + /* Fill with the whole alphabet. */ + /* Add the range on the lower and upper bound. */ + RedTransEl newTel( keyOps->minKey, keyOps->maxKey, redFsm->getErrorTrans() ); + destRange.append( newTel ); + } + else { + /* Get the last and check for a gap on the end. */ + RedTransEl *last = &destRange[destRange.length()-1]; + if ( last->highKey < keyOps->maxKey ) { + /* Make the high key. */ + Key fillLowKey = last->highKey; + fillLowKey.increment(); + + /* Create the new range with the error trans and append it. */ + RedTransEl newTel( fillLowKey, keyOps->maxKey, redFsm->getErrorTrans() ); + destRange.append( newTel ); + } + } + } +} + +void CodeGenData::setId( int snum, int id ) +{ + RedStateAp *curState = allStates + snum; + curState->id = id; +} + +void CodeGenData::setFinal( int snum ) +{ + RedStateAp *curState = allStates + snum; + curState->isFinal = true; +} + + +void CodeGenData::setStateActions( int snum, long toStateAction, + long fromStateAction, long eofAction ) +{ + RedStateAp *curState = allStates + snum; + if ( toStateAction >= 0 ) + curState->toStateAction = allActionTables + toStateAction; + if ( fromStateAction >= 0 ) + curState->fromStateAction = allActionTables + fromStateAction; + if ( eofAction >= 0 ) + curState->eofAction = allActionTables + eofAction; +} + +void CodeGenData::resolveTargetStates( InlineList *inlineList ) +{ + for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) { + switch ( item->type ) { + case InlineItem::Goto: case InlineItem::Call: + case InlineItem::Next: case InlineItem::Entry: + item->targState = allStates + item->targId; + break; + default: + break; + } + + if ( item->children != 0 ) + resolveTargetStates( item->children ); + } +} + +void CodeGenData::closeMachine() +{ + for ( ActionList::Iter a = actionList; a.lte(); a++ ) + resolveTargetStates( a->inlineList ); + + /* Note that even if we want a complete graph we do not give the error + * state a default transition. All machines break out of the processing + * loop when in the error state. */ + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + for ( StateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ ) + st->stateCondVect.append( sci ); + } +} + + +bool CodeGenData::setAlphType( char *data ) +{ + /* FIXME: This should validate the alphabet type selection. */ + HostType *alphType = hostLang->hostTypes + atoi(data); + thisKeyOps.setAlphType( alphType ); + return true; +} + +void CodeGenData::initCondSpaceList( ulong length ) +{ + allCondSpaces = new CondSpace[length]; + for ( ulong c = 0; c < length; c++ ) + condSpaceList.append( allCondSpaces + c ); +} + +void CodeGenData::newCondSpace( int cnum, int condSpaceId, Key baseKey ) +{ + CondSpace *cond = allCondSpaces + cnum; + cond->condSpaceId = condSpaceId; + cond->baseKey = baseKey; +} + +void CodeGenData::condSpaceItem( int cnum, long condActionId ) +{ + CondSpace *cond = allCondSpaces + cnum; + cond->condSet.append( allActions + condActionId ); +} + +void CodeGenData::initStateCondList( int snum, ulong length ) +{ + /* Could preallocate these, as we could with transitions. */ +} + +void CodeGenData::addStateCond( int snum, Key lowKey, Key highKey, long condNum ) +{ + RedStateAp *curState = allStates + snum; + + /* Create the new state condition. */ + StateCond *stateCond = new StateCond; + stateCond->lowKey = lowKey; + stateCond->highKey = highKey; + + /* Assign it a cond space. */ + CondSpace *condSpace = allCondSpaces + condNum; + stateCond->condSpace = condSpace; + + curState->stateCondList.append( stateCond ); +} + + +CondSpace *CodeGenData::findCondSpace( Key lowKey, Key highKey ) +{ + for ( CondSpaceList::Iter cs = condSpaceList; cs.lte(); cs++ ) { + Key csHighKey = cs->baseKey; + csHighKey += keyOps->alphSize() * (1 << cs->condSet.length()); + + if ( lowKey >= cs->baseKey && highKey <= csHighKey ) + return cs; + } + return 0; +} + +Condition *CodeGenData::findCondition( Key key ) +{ + for ( ConditionList::Iter cond = conditionList; cond.lte(); cond++ ) { + Key upperKey = cond->baseKey + (1 << cond->condSet.length()); + if ( cond->baseKey <= key && key <= upperKey ) + return cond; + } + return 0; +} + +Key CodeGenData::findMaxKey() +{ + Key maxKey = keyOps->maxKey; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + assert( st->outSingle.length() == 0 ); + assert( st->defTrans == 0 ); + + long rangeLen = st->outRange.length(); + if ( rangeLen > 0 ) { + Key highKey = st->outRange[rangeLen-1].highKey; + if ( highKey > maxKey ) + maxKey = highKey; + } + } + return maxKey; +} + +void CodeGenData::findFinalActionRefs() +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Rerence count out of single transitions. */ + for ( RedTransList::Iter rtel = st->outSingle; rtel.lte(); rtel++ ) { + if ( rtel->value->action != 0 ) { + rtel->value->action->numTransRefs += 1; + for ( ActionTable::Iter item = rtel->value->action->key; item.lte(); item++ ) + item->value->numTransRefs += 1; + } + } + + /* Reference count out of range transitions. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + if ( rtel->value->action != 0 ) { + rtel->value->action->numTransRefs += 1; + for ( ActionTable::Iter item = rtel->value->action->key; item.lte(); item++ ) + item->value->numTransRefs += 1; + } + } + + /* Reference count default transition. */ + if ( st->defTrans != 0 && st->defTrans->action != 0 ) { + st->defTrans->action->numTransRefs += 1; + for ( ActionTable::Iter item = st->defTrans->action->key; item.lte(); item++ ) + item->value->numTransRefs += 1; + } + + /* Reference count to state actions. */ + if ( st->toStateAction != 0 ) { + st->toStateAction->numToStateRefs += 1; + for ( ActionTable::Iter item = st->toStateAction->key; item.lte(); item++ ) + item->value->numToStateRefs += 1; + } + + /* Reference count from state actions. */ + if ( st->fromStateAction != 0 ) { + st->fromStateAction->numFromStateRefs += 1; + for ( ActionTable::Iter item = st->fromStateAction->key; item.lte(); item++ ) + item->value->numFromStateRefs += 1; + } + + /* Reference count EOF actions. */ + if ( st->eofAction != 0 ) { + st->eofAction->numEofRefs += 1; + for ( ActionTable::Iter item = st->eofAction->key; item.lte(); item++ ) + item->value->numEofRefs += 1; + } + } +} + +void CodeGenData::analyzeAction( Action *act, InlineList *inlineList ) +{ + for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) { + /* Only consider actions that are referenced. */ + if ( act->numRefs() > 0 ) { + if ( item->type == InlineItem::Goto || item->type == InlineItem::GotoExpr ) + redFsm->bAnyActionGotos = true; + else if ( item->type == InlineItem::Call || item->type == InlineItem::CallExpr ) + redFsm->bAnyActionCalls = true; + else if ( item->type == InlineItem::Ret ) + redFsm->bAnyActionRets = true; + } + + /* Check for various things in regular actions. */ + if ( act->numTransRefs > 0 || act->numToStateRefs > 0 || act->numFromStateRefs > 0 ) { + /* Any returns in regular actions? */ + if ( item->type == InlineItem::Ret ) + redFsm->bAnyRegActionRets = true; + + /* Any next statements in the regular actions? */ + if ( item->type == InlineItem::Next || item->type == InlineItem::NextExpr ) + redFsm->bAnyRegNextStmt = true; + + /* Any by value control in regular actions? */ + if ( item->type == InlineItem::CallExpr || item->type == InlineItem::GotoExpr ) + redFsm->bAnyRegActionByValControl = true; + + /* Any references to the current state in regular actions? */ + if ( item->type == InlineItem::Curs ) + redFsm->bAnyRegCurStateRef = true; + + if ( item->type == InlineItem::Break ) + redFsm->bAnyRegBreak = true; + + if ( item->type == InlineItem::LmSwitch && item->handlesError ) + redFsm->bAnyLmSwitchError = true; + } + + if ( item->children != 0 ) + analyzeAction( act, item->children ); + } +} + +void CodeGenData::analyzeActionList( RedAction *redAct, InlineList *inlineList ) +{ + for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) { + /* Any next statements in the action table? */ + if ( item->type == InlineItem::Next || item->type == InlineItem::NextExpr ) + redAct->bAnyNextStmt = true; + + /* Any references to the current state. */ + if ( item->type == InlineItem::Curs ) + redAct->bAnyCurStateRef = true; + + if ( item->type == InlineItem::Break ) + redAct->bAnyBreakStmt = true; + + if ( item->children != 0 ) + analyzeActionList( redAct, item->children ); + } +} + +/* Assign ids to referenced actions. */ +void CodeGenData::assignActionIds() +{ + int nextActionId = 0; + for ( ActionList::Iter act = actionList; act.lte(); act++ ) { + /* Only ever interested in referenced actions. */ + if ( act->numRefs() > 0 ) + act->actionId = nextActionId++; + } +} + +void CodeGenData::setValueLimits() +{ + redFsm->maxSingleLen = 0; + redFsm->maxRangeLen = 0; + redFsm->maxKeyOffset = 0; + redFsm->maxIndexOffset = 0; + redFsm->maxActListId = 0; + redFsm->maxActionLoc = 0; + redFsm->maxActArrItem = 0; + redFsm->maxSpan = 0; + redFsm->maxCondSpan = 0; + redFsm->maxFlatIndexOffset = 0; + redFsm->maxCondOffset = 0; + redFsm->maxCondLen = 0; + redFsm->maxCondSpaceId = 0; + redFsm->maxCondIndexOffset = 0; + + /* In both of these cases the 0 index is reserved for no value, so the max + * is one more than it would be if they started at 0. */ + redFsm->maxIndex = redFsm->transSet.length(); + redFsm->maxCond = condSpaceList.length(); + + /* The nextStateId - 1 is the last state id assigned. */ + redFsm->maxState = redFsm->nextStateId - 1; + + for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { + if ( csi->condSpaceId > redFsm->maxCondSpaceId ) + redFsm->maxCondSpaceId = csi->condSpaceId; + } + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Maximum cond length. */ + if ( st->stateCondList.length() > redFsm->maxCondLen ) + redFsm->maxCondLen = st->stateCondList.length(); + + /* Maximum single length. */ + if ( st->outSingle.length() > redFsm->maxSingleLen ) + redFsm->maxSingleLen = st->outSingle.length(); + + /* Maximum range length. */ + if ( st->outRange.length() > redFsm->maxRangeLen ) + redFsm->maxRangeLen = st->outRange.length(); + + /* The key offset index offset for the state after last is not used, skip it.. */ + if ( ! st.last() ) { + redFsm->maxCondOffset += st->stateCondList.length(); + redFsm->maxKeyOffset += st->outSingle.length() + st->outRange.length()*2; + redFsm->maxIndexOffset += st->outSingle.length() + st->outRange.length() + 1; + } + + /* Max cond span. */ + if ( st->condList != 0 ) { + unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey ); + if ( span > redFsm->maxCondSpan ) + redFsm->maxCondSpan = span; + } + + /* Max key span. */ + if ( st->transList != 0 ) { + unsigned long long span = keyOps->span( st->lowKey, st->highKey ); + if ( span > redFsm->maxSpan ) + redFsm->maxSpan = span; + } + + /* Max cond index offset. */ + if ( ! st.last() ) { + if ( st->condList != 0 ) + redFsm->maxCondIndexOffset += keyOps->span( st->condLowKey, st->condHighKey ); + } + + /* Max flat index offset. */ + if ( ! st.last() ) { + if ( st->transList != 0 ) + redFsm->maxFlatIndexOffset += keyOps->span( st->lowKey, st->highKey ); + redFsm->maxFlatIndexOffset += 1; + } + } + + for ( ActionTableMap::Iter at = redFsm->actionMap; at.lte(); at++ ) { + /* Maximum id of action lists. */ + if ( at->actListId+1 > redFsm->maxActListId ) + redFsm->maxActListId = at->actListId+1; + + /* Maximum location of items in action array. */ + if ( at->location+1 > redFsm->maxActionLoc ) + redFsm->maxActionLoc = at->location+1; + + /* Maximum values going into the action array. */ + if ( at->key.length() > redFsm->maxActArrItem ) + redFsm->maxActArrItem = at->key.length(); + for ( ActionTable::Iter item = at->key; item.lte(); item++ ) { + if ( item->value->actionId > redFsm->maxActArrItem ) + redFsm->maxActArrItem = item->value->actionId; + } + } +} + + + +/* Gather various info on the machine. */ +void CodeGenData::analyzeMachine() +{ + /* Find the true count of action references. */ + findFinalActionRefs(); + + /* Check if there are any calls in action code. */ + for ( ActionList::Iter act = actionList; act.lte(); act++ ) { + /* Record the occurrence of various kinds of actions. */ + if ( act->numToStateRefs > 0 ) + redFsm->bAnyToStateActions = true; + if ( act->numFromStateRefs > 0 ) + redFsm->bAnyFromStateActions = true; + if ( act->numEofRefs > 0 ) + redFsm->bAnyEofActions = true; + if ( act->numTransRefs > 0 ) + redFsm->bAnyRegActions = true; + + /* Recurse through the action's parse tree looking for various things. */ + analyzeAction( act, act->inlineList ); + } + + /* Analyze reduced action lists. */ + for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + for ( ActionTable::Iter act = redAct->key; act.lte(); act++ ) + analyzeActionList( redAct, act->value->inlineList ); + } + + /* Find states that have transitions with actions that have next + * statements. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Check any actions out of outSinge. */ + for ( RedTransList::Iter rtel = st->outSingle; rtel.lte(); rtel++ ) { + if ( rtel->value->action != 0 && rtel->value->action->anyCurStateRef() ) + st->bAnyRegCurStateRef = true; + } + + /* Check any actions out of outRange. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + if ( rtel->value->action != 0 && rtel->value->action->anyCurStateRef() ) + st->bAnyRegCurStateRef = true; + } + + /* Check any action out of default. */ + if ( st->defTrans != 0 && st->defTrans->action != 0 && + st->defTrans->action->anyCurStateRef() ) + st->bAnyRegCurStateRef = true; + + if ( st->stateCondList.length() > 0 ) + redFsm->bAnyConditions = true; + } + + /* Assign ids to actions that are referenced. */ + assignActionIds(); + + /* Set the maximums of various values used for deciding types. */ + setValueLimits(); +} + +void CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) +{ + /* FIXME: This should be moved to the virtual functions in the code + * generators. + * + * Force a newline. */ + out << "\n"; + genLineDirective( out ); + + if ( strcmp( args[0], "data" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + if ( strcmp( args[i], "noerror" ) == 0 ) + writeErr = false; + else if ( strcmp( args[i], "noprefix" ) == 0 ) + dataPrefix = false; + else if ( strcmp( args[i], "nofinal" ) == 0 ) + writeFirstFinal = false; + else { + source_warning(loc) << "unrecognized write option \"" << + args[i] << "\"" << endl; + } + } + writeData(); + } + else if ( strcmp( args[0], "init" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + source_warning(loc) << "unrecognized write option \"" << + args[i] << "\"" << endl; + } + writeInit(); + } + else if ( strcmp( args[0], "exec" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + if ( strcmp( args[i], "noend" ) == 0 ) + hasEnd = false; + else { + source_warning(loc) << "unrecognized write option \"" << + args[i] << "\"" << endl; + } + } + writeExec(); + } + else if ( strcmp( args[0], "eof" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + source_warning(loc) << "unrecognized write option \"" << + args[i] << "\"" << endl; + } + writeEOF(); + } + else if ( strcmp( args[0], "exports" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + source_warning(loc) << "unrecognized write option \"" << + args[i] << "\"" << endl; + } + writeExports(); + } + else { + /* EMIT An error here. */ + source_error(loc) << "unrecognized write command \"" << + args[0] << "\"" << endl; + } +} + +ostream &CodeGenData::source_warning( const InputLoc &loc ) +{ + cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: "; + return cerr; +} + +ostream &CodeGenData::source_error( const InputLoc &loc ) +{ + codeGenErrCount += 1; + assert( sourceFileName != 0 ); + cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": "; + return cerr; +} + + diff --git a/contrib/tools/ragel5/redfsm/gendata.h b/contrib/tools/ragel5/redfsm/gendata.h new file mode 100644 index 0000000000..855e0710a7 --- /dev/null +++ b/contrib/tools/ragel5/redfsm/gendata.h @@ -0,0 +1,167 @@ +/* + * Copyright 2005-2007 Adrian Thurston <thurston@cs.queensu.ca> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Ragel; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GENDATA_H +#define _GENDATA_H + +#include <iostream> +#include "redfsm.h" +#include "common.h" + +using std::ostream; + +struct NameInst; +typedef DList<Action> ActionList; + +typedef unsigned long ulong; + +struct FsmCodeGen; +struct CodeGenData; + +typedef AvlMap<char *, CodeGenData*, CmpStr> CodeGenMap; +typedef AvlMapEl<char *, CodeGenData*> CodeGenMapEl; + +/* + * The interface to the parser + */ + +/* These functions must be implemented by the code generation executable. + * The openOutput function is invoked when the root element is opened. The + * makeCodeGen function is invoked when a ragel_def element is opened. */ +std::ostream *openOutput( char *inputFile ); +CodeGenData *makeCodeGen( char *sourceFileName, + char *fsmName, ostream &out, bool wantComplete ); + +void lineDirective( ostream &out, char *fileName, int line ); +void genLineDirective( ostream &out ); + +/*********************************/ + +struct CodeGenData +{ + /* + * The interface to the code generator. + */ + virtual void finishRagelDef() {} + + /* These are invoked by the corresponding write statements. */ + virtual void writeData() {}; + virtual void writeInit() {}; + virtual void writeExec() {}; + virtual void writeEOF() {}; + virtual void writeExports() {}; + + /* This can also be overwridden to modify the processing of write + * statements. */ + virtual void writeStatement( InputLoc &loc, int nargs, char **args ); + + /********************/ + + CodeGenData( ostream &out ); + virtual ~CodeGenData() {} + + /* + * Collecting the machine. + */ + + char *sourceFileName; + char *fsmName; + ostream &out; + RedFsmAp *redFsm; + Action *allActions; + RedAction *allActionTables; + Condition *allConditions; + CondSpace *allCondSpaces; + RedStateAp *allStates; + NameInst **nameIndex; + int startState; + int errState; + ActionList actionList; + ConditionList conditionList; + CondSpaceList condSpaceList; + InlineList *getKeyExpr; + InlineList *accessExpr; + InlineList *curStateExpr; + KeyOps thisKeyOps; + bool wantComplete; + EntryIdVect entryPointIds; + EntryNameVect entryPointNames; + bool hasLongestMatch; + int codeGenErrCount; + ExportList exportList; + + /* Write options. */ + bool hasEnd; + bool dataPrefix; + bool writeFirstFinal; + bool writeErr; + + void createMachine(); + void initActionList( unsigned long length ); + void newAction( int anum, char *name, int line, int col, InlineList *inlineList ); + void initActionTableList( unsigned long length ); + void initStateList( unsigned long length ); + void setStartState( unsigned long startState ); + void setErrorState( unsigned long errState ); + void addEntryPoint( char *name, unsigned long entryState ); + void setId( int snum, int id ); + void setFinal( int snum ); + void initTransList( int snum, unsigned long length ); + void newTrans( int snum, int tnum, Key lowKey, Key highKey, + long targ, long act ); + void finishTransList( int snum ); + void setStateActions( int snum, long toStateAction, + long fromStateAction, long eofAction ); + void setForcedErrorState() + { redFsm->forcedErrorState = true; } + + + void initCondSpaceList( ulong length ); + void condSpaceItem( int cnum, long condActionId ); + void newCondSpace( int cnum, int condSpaceId, Key baseKey ); + + void initStateCondList( int snum, ulong length ); + void addStateCond( int snum, Key lowKey, Key highKey, long condNum ); + + CondSpace *findCondSpace( Key lowKey, Key highKey ); + Condition *findCondition( Key key ); + + bool setAlphType( char *data ); + + void resolveTargetStates( InlineList *inlineList ); + Key findMaxKey(); + + /* Gather various info on the machine. */ + void analyzeActionList( RedAction *redAct, InlineList *inlineList ); + void analyzeAction( Action *act, InlineList *inlineList ); + void findFinalActionRefs(); + void analyzeMachine(); + + void closeMachine(); + void setValueLimits(); + void assignActionIds(); + + ostream &source_warning( const InputLoc &loc ); + ostream &source_error( const InputLoc &loc ); +}; + + +#endif /* _GENDATA_H */ diff --git a/contrib/tools/ragel5/redfsm/phash.h b/contrib/tools/ragel5/redfsm/phash.h new file mode 100644 index 0000000000..11ce7502a6 --- /dev/null +++ b/contrib/tools/ragel5/redfsm/phash.h @@ -0,0 +1,10 @@ +#pragma once + +class Perfect_Hash +{ +private: + static inline unsigned int hash (const char *str, unsigned int len); + +public: + static struct XMLTagHashPair *in_word_set (const char *str, unsigned int len); +}; diff --git a/contrib/tools/ragel5/redfsm/redfsm.cpp b/contrib/tools/ragel5/redfsm/redfsm.cpp new file mode 100644 index 0000000000..6a55b22ec7 --- /dev/null +++ b/contrib/tools/ragel5/redfsm/redfsm.cpp @@ -0,0 +1,559 @@ +/* + * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Ragel; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "redfsm.h" +#include "avlmap.h" +#include <iostream> +#include <sstream> + +using std::ostringstream; + +KeyOps *keyOps = 0; + +string Action::nameOrLoc() +{ + if ( name != 0 ) + return string(name); + else { + ostringstream ret; + ret << loc.line << ":" << loc.col; + return ret.str(); + } +} + +RedFsmAp::RedFsmAp() +: + wantComplete(false), + forcedErrorState(false), + nextActionId(0), + nextTransId(0), + startState(0), + errState(0), + errTrans(0), + firstFinState(0), + numFinStates(0), + bAnyToStateActions(false), + bAnyFromStateActions(false), + bAnyRegActions(false), + bAnyEofActions(false), + bAnyActionGotos(false), + bAnyActionCalls(false), + bAnyActionRets(false), + bAnyRegActionRets(false), + bAnyRegActionByValControl(false), + bAnyRegNextStmt(false), + bAnyRegCurStateRef(false), + bAnyRegBreak(false), + bAnyLmSwitchError(false), + bAnyConditions(false) +{ +} + +/* Does the machine have any actions. */ +bool RedFsmAp::anyActions() +{ + return actionMap.length() > 0; +} + +void RedFsmAp::depthFirstOrdering( RedStateAp *state ) +{ + /* Nothing to do if the state is already on the list. */ + if ( state->onStateList ) + return; + + /* Doing depth first, put state on the list. */ + state->onStateList = true; + stateList.append( state ); + + /* At this point transitions should only be in ranges. */ + assert( state->outSingle.length() == 0 ); + assert( state->defTrans == 0 ); + + /* Recurse on everything ranges. */ + for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) { + if ( rtel->value->targ != 0 ) + depthFirstOrdering( rtel->value->targ ); + } +} + +/* Ordering states by transition connections. */ +void RedFsmAp::depthFirstOrdering() +{ + /* Init on state list flags. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) + st->onStateList = false; + + /* Clear out the state list, we will rebuild it. */ + int stateListLen = stateList.length(); + stateList.abandon(); + + /* Add back to the state list from the start state and all other entry + * points. */ + if ( startState != 0 ) + depthFirstOrdering( startState ); + for ( RedStateSet::Iter en = entryPoints; en.lte(); en++ ) + depthFirstOrdering( *en ); + if ( forcedErrorState ) + depthFirstOrdering( errState ); + + /* Make sure we put everything back on. */ + assert( stateListLen == stateList.length() ); +} + +/* Assign state ids by appearance in the state list. */ +void RedFsmAp::sequentialStateIds() +{ + /* Table based machines depend on the state numbers starting at zero. */ + nextStateId = 0; + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) + st->id = nextStateId++; +} + +/* Stable sort the states by final state status. */ +void RedFsmAp::sortStatesByFinal() +{ + /* Move forward through the list and throw final states onto the end. */ + RedStateAp *state = 0; + RedStateAp *next = stateList.head; + RedStateAp *last = stateList.tail; + while ( state != last ) { + /* Move forward and load up the next. */ + state = next; + next = state->next; + + /* Throw to the end? */ + if ( state->isFinal ) { + stateList.detach( state ); + stateList.append( state ); + } + } +} + +/* Assign state ids by final state state status. */ +void RedFsmAp::sortStateIdsByFinal() +{ + /* Table based machines depend on this starting at zero. */ + nextStateId = 0; + + /* First pass to assign non final ids. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + if ( ! st->isFinal ) + st->id = nextStateId++; + } + + /* Second pass to assign final ids. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + if ( st->isFinal ) + st->id = nextStateId++; + } +} + +void RedFsmAp::sortByStateId() +{ + /* FIXME: Implement. */ +} + +/* Find the final state with the lowest id. */ +void RedFsmAp::findFirstFinState() +{ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + if ( st->isFinal && (firstFinState == 0 || st->id < firstFinState->id) ) + firstFinState = st; + } +} + +void RedFsmAp::assignActionLocs() +{ + int nextLocation = 0; + for ( ActionTableMap::Iter act = actionMap; act.lte(); act++ ) { + /* Store the loc, skip over the array and a null terminator. */ + act->location = nextLocation; + nextLocation += act->key.length() + 1; + } +} + +/* Check if we can extend the current range by displacing any ranges + * ahead to the singles. */ +bool RedFsmAp::canExtend( const RedTransList &list, int pos ) +{ + /* Get the transition that we want to extend. */ + RedTransAp *extendTrans = list[pos].value; + + /* Look ahead in the transition list. */ + for ( int next = pos + 1; next < list.length(); pos++, next++ ) { + /* If they are not continuous then cannot extend. */ + Key nextKey = list[next].lowKey; + nextKey.decrement(); + if ( list[pos].highKey != nextKey ) + break; + + /* Check for the extenstion property. */ + if ( extendTrans == list[next].value ) + return true; + + /* If the span of the next element is more than one, then don't keep + * checking, it won't be moved to single. */ + unsigned long long nextSpan = keyOps->span( list[next].lowKey, list[next].highKey ); + if ( nextSpan > 1 ) + break; + } + return false; +} + +/* Move ranges to the singles list. */ +void RedFsmAp::moveTransToSingle( RedStateAp *state ) +{ + RedTransList &range = state->outRange; + RedTransList &single = state->outSingle; + for ( int rpos = 0; rpos < range.length(); ) { + /* Check if this is a range we can extend. */ + if ( canExtend( range, rpos ) ) { + /* Transfer singles over. */ + while ( range[rpos].value != range[rpos+1].value ) { + /* Transfer the range to single. */ + single.append( range[rpos+1] ); + range.remove( rpos+1 ); + } + + /* Extend. */ + range[rpos].highKey = range[rpos+1].highKey; + range.remove( rpos+1 ); + } + /* Maybe move it to the singles. */ + else if ( keyOps->span( range[rpos].lowKey, range[rpos].highKey ) == 1 ) { + single.append( range[rpos] ); + range.remove( rpos ); + } + else { + /* Keeping it in the ranges. */ + rpos += 1; + } + } +} + +/* Look through ranges and choose suitable single character transitions. */ +void RedFsmAp::chooseSingle() +{ + /* Loop the states. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + /* Rewrite the transition list taking out the suitable single + * transtions. */ + moveTransToSingle( st ); + } +} + +void RedFsmAp::makeFlat() +{ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + if ( st->stateCondList.length() == 0 ) { + st->condLowKey = 0; + st->condHighKey = 0; + } + else { + st->condLowKey = st->stateCondList.head->lowKey; + st->condHighKey = st->stateCondList.tail->highKey; + + unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey ); + st->condList = new CondSpace*[ span ]; + memset( st->condList, 0, sizeof(CondSpace*)*span ); + + for ( StateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ ) { + unsigned long long base, trSpan; + base = keyOps->span( st->condLowKey, sci->lowKey )-1; + trSpan = keyOps->span( sci->lowKey, sci->highKey ); + for ( unsigned long long pos = 0; pos < trSpan; pos++ ) + st->condList[base+pos] = sci->condSpace; + } + } + + if ( st->outRange.length() == 0 ) { + st->lowKey = st->highKey = 0; + st->transList = 0; + } + else { + st->lowKey = st->outRange[0].lowKey; + st->highKey = st->outRange[st->outRange.length()-1].highKey; + unsigned long long span = keyOps->span( st->lowKey, st->highKey ); + st->transList = new RedTransAp*[ span ]; + memset( st->transList, 0, sizeof(RedTransAp*)*span ); + + for ( RedTransList::Iter trans = st->outRange; trans.lte(); trans++ ) { + unsigned long long base, trSpan; + base = keyOps->span( st->lowKey, trans->lowKey )-1; + trSpan = keyOps->span( trans->lowKey, trans->highKey ); + for ( unsigned long long pos = 0; pos < trSpan; pos++ ) + st->transList[base+pos] = trans->value; + } + + /* Fill in the gaps with the default transition. */ + for ( unsigned long long pos = 0; pos < span; pos++ ) { + if ( st->transList[pos] == 0 ) + st->transList[pos] = st->defTrans; + } + } + } +} + + +/* A default transition has been picked, move it from the outRange to the + * default pointer. */ +void RedFsmAp::moveToDefault( RedTransAp *defTrans, RedStateAp *state ) +{ + /* Rewrite the outRange, omitting any ranges that use + * the picked default. */ + RedTransList outRange; + for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) { + /* If it does not take the default, copy it over. */ + if ( rtel->value != defTrans ) + outRange.append( *rtel ); + } + + /* Save off the range we just created into the state's range. */ + state->outRange.transfer( outRange ); + + /* Store the default. */ + state->defTrans = defTrans; +} + +bool RedFsmAp::alphabetCovered( RedTransList &outRange ) +{ + /* Cannot cover without any out ranges. */ + if ( outRange.length() == 0 ) + return false; + + /* If the first range doesn't start at the the lower bound then the + * alphabet is not covered. */ + RedTransList::Iter rtel = outRange; + if ( keyOps->minKey < rtel->lowKey ) + return false; + + /* Check that every range is next to the previous one. */ + rtel.increment(); + for ( ; rtel.lte(); rtel++ ) { + Key highKey = rtel[-1].highKey; + highKey.increment(); + if ( highKey != rtel->lowKey ) + return false; + } + + /* The last must extend to the upper bound. */ + RedTransEl *last = &outRange[outRange.length()-1]; + if ( last->highKey < keyOps->maxKey ) + return false; + + return true; +} + +RedTransAp *RedFsmAp::chooseDefaultSpan( RedStateAp *state ) +{ + /* Make a set of transitions from the outRange. */ + RedTransSet stateTransSet; + for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) + stateTransSet.insert( rtel->value ); + + /* For each transition in the find how many alphabet characters the + * transition spans. */ + unsigned long long *span = new unsigned long long[stateTransSet.length()]; + memset( span, 0, sizeof(unsigned long long) * stateTransSet.length() ); + for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) { + /* Lookup the transition in the set. */ + RedTransAp **inSet = stateTransSet.find( rtel->value ); + int pos = inSet - stateTransSet.data; + span[pos] += keyOps->span( rtel->lowKey, rtel->highKey ); + } + + /* Find the max span, choose it for making the default. */ + RedTransAp *maxTrans = 0; + unsigned long long maxSpan = 0; + for ( RedTransSet::Iter rtel = stateTransSet; rtel.lte(); rtel++ ) { + if ( span[rtel.pos()] > maxSpan ) { + maxSpan = span[rtel.pos()]; + maxTrans = *rtel; + } + } + + delete[] span; + return maxTrans; +} + +/* Pick default transitions from ranges for the states. */ +void RedFsmAp::chooseDefaultSpan() +{ + /* Loop the states. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + /* Only pick a default transition if the alphabet is covered. This + * avoids any transitions in the out range that go to error and avoids + * the need for an ERR state. */ + if ( alphabetCovered( st->outRange ) ) { + /* Pick a default transition by largest span. */ + RedTransAp *defTrans = chooseDefaultSpan( st ); + + /* Rewrite the transition list taking out the transition we picked + * as the default and store the default. */ + moveToDefault( defTrans, st ); + } + } +} + +RedTransAp *RedFsmAp::chooseDefaultGoto( RedStateAp *state ) +{ + /* Make a set of transitions from the outRange. */ + RedTransSet stateTransSet; + for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) { + if ( rtel->value->targ == state->next ) + return rtel->value; + } + return 0; +} + +void RedFsmAp::chooseDefaultGoto() +{ + /* Loop the states. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + /* Pick a default transition. */ + RedTransAp *defTrans = chooseDefaultGoto( st ); + if ( defTrans == 0 ) + defTrans = chooseDefaultSpan( st ); + + /* Rewrite the transition list taking out the transition we picked + * as the default and store the default. */ + moveToDefault( defTrans, st ); + } +} + +RedTransAp *RedFsmAp::chooseDefaultNumRanges( RedStateAp *state ) +{ + /* Make a set of transitions from the outRange. */ + RedTransSet stateTransSet; + for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) + stateTransSet.insert( rtel->value ); + + /* For each transition in the find how many ranges use the transition. */ + int *numRanges = new int[stateTransSet.length()]; + memset( numRanges, 0, sizeof(int) * stateTransSet.length() ); + for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) { + /* Lookup the transition in the set. */ + RedTransAp **inSet = stateTransSet.find( rtel->value ); + numRanges[inSet - stateTransSet.data] += 1; + } + + /* Find the max number of ranges. */ + RedTransAp *maxTrans = 0; + int maxNumRanges = 0; + for ( RedTransSet::Iter rtel = stateTransSet; rtel.lte(); rtel++ ) { + if ( numRanges[rtel.pos()] > maxNumRanges ) { + maxNumRanges = numRanges[rtel.pos()]; + maxTrans = *rtel; + } + } + + delete[] numRanges; + return maxTrans; +} + +void RedFsmAp::chooseDefaultNumRanges() +{ + /* Loop the states. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + /* Pick a default transition. */ + RedTransAp *defTrans = chooseDefaultNumRanges( st ); + + /* Rewrite the transition list taking out the transition we picked + * as the default and store the default. */ + moveToDefault( defTrans, st ); + } +} + +RedTransAp *RedFsmAp::getErrorTrans( ) +{ + /* If the error trans has not been made aready, make it. */ + if ( errTrans == 0 ) { + /* This insert should always succeed since no transition created by + * the user can point to the error state. */ + errTrans = new RedTransAp( getErrorState(), 0, nextTransId++ ); + RedTransAp *inRes = transSet.insert( errTrans ); + assert( inRes != 0 ); + } + return errTrans; +} + +RedStateAp *RedFsmAp::getErrorState() +{ + /* Something went wrong. An error state is needed but one was not supplied + * by the frontend. */ + assert( errState != 0 ); + return errState; +} + + +RedTransAp *RedFsmAp::allocateTrans( RedStateAp *targ, RedAction *action ) +{ + /* Create a reduced trans and look for it in the transiton set. */ + RedTransAp redTrans( targ, action, 0 ); + RedTransAp *inDict = transSet.find( &redTrans ); + if ( inDict == 0 ) { + inDict = new RedTransAp( targ, action, nextTransId++ ); + transSet.insert( inDict ); + } + return inDict; +} + +void RedFsmAp::partitionFsm( int nparts ) +{ + /* At this point the states are ordered by a depth-first traversal. We + * will allocate to partitions based on this ordering. */ + this->nParts = nparts; + int partSize = stateList.length() / nparts; + int remainder = stateList.length() % nparts; + int numInPart = partSize; + int partition = 0; + if ( remainder-- > 0 ) + numInPart += 1; + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + st->partition = partition; + + numInPart -= 1; + if ( numInPart == 0 ) { + partition += 1; + numInPart = partSize; + if ( remainder-- > 0 ) + numInPart += 1; + } + } +} + +void RedFsmAp::setInTrans() +{ + /* First pass counts the number of transitions. */ + for ( TransApSet::Iter trans = transSet; trans.lte(); trans++ ) + trans->targ->numInTrans += 1; + + /* Pass over states to allocate the needed memory. Reset the counts so we + * can use them as the current size. */ + for ( RedStateList::Iter st = stateList; st.lte(); st++ ) { + st->inTrans = new RedTransAp*[st->numInTrans]; + st->numInTrans = 0; + } + + /* Second pass over transitions copies pointers into the in trans list. */ + for ( TransApSet::Iter trans = transSet; trans.lte(); trans++ ) + trans->targ->inTrans[trans->targ->numInTrans++] = trans; +} diff --git a/contrib/tools/ragel5/redfsm/redfsm.h b/contrib/tools/ragel5/redfsm/redfsm.h new file mode 100644 index 0000000000..515b1b621b --- /dev/null +++ b/contrib/tools/ragel5/redfsm/redfsm.h @@ -0,0 +1,534 @@ +/* + * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Ragel; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _REDFSM_H +#define _REDFSM_H + +#include <assert.h> +#include <string.h> +#include <string> +#include "common.h" +#include "vector.h" +#include "dlist.h" +#include "compare.h" +#include "bstmap.h" +#include "bstset.h" +#include "avlmap.h" +#include "avltree.h" +#include "avlbasic.h" +#include "mergesort.h" +#include "sbstmap.h" +#include "sbstset.h" +#include "sbsttable.h" + +#define TRANS_ERR_TRANS 0 +#define STATE_ERR_STATE 0 +#define FUNC_NO_FUNC 0 + +using std::string; + +struct RedStateAp; +struct InlineList; +struct Action; + +/* Location in an input file. */ +struct InputLoc +{ + int line; + int col; +}; + +/* + * Inline code tree + */ +struct InlineItem +{ + enum Type + { + Text, Goto, Call, Next, GotoExpr, CallExpr, NextExpr, Ret, + PChar, Char, Hold, Exec, HoldTE, ExecTE, Curs, Targs, Entry, + LmSwitch, LmSetActId, LmSetTokEnd, LmGetTokEnd, LmInitTokStart, + LmInitAct, LmSetTokStart, SubAction, Break + }; + + InlineItem( const InputLoc &loc, Type type ) : + loc(loc), data(0), targId(0), targState(0), + lmId(0), children(0), offset(0), + handlesError(false), type(type) { } + + InputLoc loc; + char *data; + int targId; + RedStateAp *targState; + int lmId; + InlineList *children; + int offset; + bool handlesError; + Type type; + + InlineItem *prev, *next; +}; + +/* Normally this would be atypedef, but that would entail including DList from + * ptreetypes, which should be just typedef forwards. */ +struct InlineList : public DList<InlineItem> { }; + +/* Element in list of actions. Contains the string for the code to exectute. */ +struct Action +: + public DListEl<Action> +{ + Action( ) + : + name(0), + inlineList(0), + actionId(0), + numTransRefs(0), + numToStateRefs(0), + numFromStateRefs(0), + numEofRefs(0) + { + } + + /* Data collected during parse. */ + InputLoc loc; + char *name; + InlineList *inlineList; + int actionId; + + string nameOrLoc(); + + /* Number of references in the final machine. */ + int numRefs() + { return numTransRefs + numToStateRefs + numFromStateRefs + numEofRefs; } + int numTransRefs; + int numToStateRefs; + int numFromStateRefs; + int numEofRefs; +}; + + +/* Forwards. */ +struct RedStateAp; +struct StateAp; + +/* Transistion Action Element. */ +typedef SBstMapEl< int, Action* > ActionTableEl; + +/* Transition Action Table. */ +struct ActionTable + : public SBstMap< int, Action*, CmpOrd<int> > +{ + void setAction( int ordering, Action *action ); + void setActions( int *orderings, Action **actions, int nActs ); + void setActions( const ActionTable &other ); +}; + +/* Compare of a whole action table element (key & value). */ +struct CmpActionTableEl +{ + static int compare( const ActionTableEl &action1, + const ActionTableEl &action2 ) + { + if ( action1.key < action2.key ) + return -1; + else if ( action1.key > action2.key ) + return 1; + else if ( action1.value < action2.value ) + return -1; + else if ( action1.value > action2.value ) + return 1; + return 0; + } +}; + +/* Compare for ActionTable. */ +typedef CmpSTable< ActionTableEl, CmpActionTableEl > CmpActionTable; + +/* Set of states. */ +typedef BstSet<RedStateAp*> RedStateSet; +typedef BstSet<int> IntSet; + +/* Reduced action. */ +struct RedAction +: + public AvlTreeEl<RedAction> +{ + RedAction( ) + : + key(), + eofRefs(0), + numTransRefs(0), + numToStateRefs(0), + numFromStateRefs(0), + numEofRefs(0), + bAnyNextStmt(false), + bAnyCurStateRef(false), + bAnyBreakStmt(false) + { } + + const ActionTable &getKey() + { return key; } + + ActionTable key; + int actListId; + int location; + IntSet *eofRefs; + + /* Number of references in the final machine. */ + int numRefs() + { return numTransRefs + numToStateRefs + numFromStateRefs + numEofRefs; } + int numTransRefs; + int numToStateRefs; + int numFromStateRefs; + int numEofRefs; + + bool anyNextStmt() { return bAnyNextStmt; } + bool anyCurStateRef() { return bAnyCurStateRef; } + bool anyBreakStmt() { return bAnyBreakStmt; } + + bool bAnyNextStmt; + bool bAnyCurStateRef; + bool bAnyBreakStmt; +}; +typedef AvlTree<RedAction, ActionTable, CmpActionTable> ActionTableMap; + +/* Reduced transition. */ +struct RedTransAp +: + public AvlTreeEl<RedTransAp> +{ + RedTransAp( RedStateAp *targ, RedAction *action, int id ) + : targ(targ), action(action), id(id), labelNeeded(true) { } + + RedStateAp *targ; + RedAction *action; + int id; + bool partitionBoundary; + bool labelNeeded; +}; + +/* Compare of transitions for the final reduction of transitions. Comparison + * is on target and the pointer to the shared action table. It is assumed that + * when this is used the action tables have been reduced. */ +struct CmpRedTransAp +{ + static int compare( const RedTransAp &t1, const RedTransAp &t2 ) + { + if ( t1.targ < t2.targ ) + return -1; + else if ( t1.targ > t2.targ ) + return 1; + else if ( t1.action < t2.action ) + return -1; + else if ( t1.action > t2.action ) + return 1; + else + return 0; + } +}; + +typedef AvlBasic<RedTransAp, CmpRedTransAp> TransApSet; + +/* Element in out range. */ +struct RedTransEl +{ + /* Constructors. */ + RedTransEl( Key lowKey, Key highKey, RedTransAp *value ) + : lowKey(lowKey), highKey(highKey), value(value) { } + + Key lowKey, highKey; + RedTransAp *value; +}; + +typedef Vector<RedTransEl> RedTransList; +typedef Vector<RedStateAp*> RedStateVect; + +typedef BstMapEl<RedStateAp*, unsigned long long> RedSpanMapEl; +typedef BstMap<RedStateAp*, unsigned long long> RedSpanMap; + +/* Compare used by span map sort. Reverse sorts by the span. */ +struct CmpRedSpanMapEl +{ + static int compare( const RedSpanMapEl &smel1, const RedSpanMapEl &smel2 ) + { + if ( smel1.value > smel2.value ) + return -1; + else if ( smel1.value < smel2.value ) + return 1; + else + return 0; + } +}; + +/* Sorting state-span map entries by span. */ +typedef MergeSort<RedSpanMapEl, CmpRedSpanMapEl> RedSpanMapSort; + +/* Set of entry ids that go into this state. */ +typedef Vector<int> EntryIdVect; +typedef Vector<char*> EntryNameVect; + +typedef Vector< Action* > CondSet; + +struct Condition +{ + Condition( ) + : key(0), baseKey(0) {} + + Key key; + Key baseKey; + CondSet condSet; + + Condition *next, *prev; +}; +typedef DList<Condition> ConditionList; + +struct CondSpace +{ + Key baseKey; + CondSet condSet; + int condSpaceId; + + CondSpace *next, *prev; +}; +typedef DList<CondSpace> CondSpaceList; + +struct StateCond +{ + Key lowKey; + Key highKey; + + CondSpace *condSpace; + + StateCond *prev, *next; +}; +typedef DList<StateCond> StateCondList; +typedef Vector<StateCond*> StateCondVect; + +/* Reduced state. */ +struct RedStateAp +{ + RedStateAp() + : + defTrans(0), + condList(0), + transList(0), + isFinal(false), + labelNeeded(false), + outNeeded(false), + onStateList(false), + toStateAction(0), + fromStateAction(0), + eofAction(0), + id(0), + bAnyRegCurStateRef(false), + partitionBoundary(false), + inTrans(0), + numInTrans(0) + { } + + /* Transitions out. */ + RedTransList outSingle; + RedTransList outRange; + RedTransAp *defTrans; + + /* For flat conditions. */ + Key condLowKey, condHighKey; + CondSpace **condList; + + /* For flat keys. */ + Key lowKey, highKey; + RedTransAp **transList; + + /* The list of states that transitions from this state go to. */ + RedStateVect targStates; + + bool isFinal; + bool labelNeeded; + bool outNeeded; + bool onStateList; + RedAction *toStateAction; + RedAction *fromStateAction; + RedAction *eofAction; + int id; + StateCondList stateCondList; + StateCondVect stateCondVect; + + /* Pointers for the list of states. */ + RedStateAp *prev, *next; + + bool anyRegCurStateRef() { return bAnyRegCurStateRef; } + bool bAnyRegCurStateRef; + + int partition; + bool partitionBoundary; + + RedTransAp **inTrans; + int numInTrans; +}; + +/* List of states. */ +typedef DList<RedStateAp> RedStateList; + +/* Set of reduced transitons. Comparison is by pointer. */ +typedef BstSet< RedTransAp*, CmpOrd<RedTransAp*> > RedTransSet; + +/* Next version of the fsm machine. */ +struct RedFsmAp +{ + RedFsmAp(); + + bool wantComplete; + bool forcedErrorState; + + int nextActionId; + int nextTransId; + + /* Next State Id doubles as the total number of state ids. */ + int nextStateId; + + TransApSet transSet; + ActionTableMap actionMap; + RedStateList stateList; + RedStateSet entryPoints; + RedStateAp *startState; + RedStateAp *errState; + RedTransAp *errTrans; + RedTransAp *errActionTrans; + RedStateAp *firstFinState; + int numFinStates; + int nParts; + + bool bAnyToStateActions; + bool bAnyFromStateActions; + bool bAnyRegActions; + bool bAnyEofActions; + bool bAnyActionGotos; + bool bAnyActionCalls; + bool bAnyActionRets; + bool bAnyRegActionRets; + bool bAnyRegActionByValControl; + bool bAnyRegNextStmt; + bool bAnyRegCurStateRef; + bool bAnyRegBreak; + bool bAnyLmSwitchError; + bool bAnyConditions; + + int maxState; + int maxSingleLen; + int maxRangeLen; + int maxKeyOffset; + int maxIndexOffset; + int maxIndex; + int maxActListId; + int maxActionLoc; + int maxActArrItem; + unsigned long long maxSpan; + unsigned long long maxCondSpan; + int maxFlatIndexOffset; + Key maxKey; + int maxCondOffset; + int maxCondLen; + int maxCondSpaceId; + int maxCondIndexOffset; + int maxCond; + + bool anyActions(); + bool anyToStateActions() { return bAnyToStateActions; } + bool anyFromStateActions() { return bAnyFromStateActions; } + bool anyRegActions() { return bAnyRegActions; } + bool anyEofActions() { return bAnyEofActions; } + bool anyActionGotos() { return bAnyActionGotos; } + bool anyActionCalls() { return bAnyActionCalls; } + bool anyActionRets() { return bAnyActionRets; } + bool anyRegActionRets() { return bAnyRegActionRets; } + bool anyRegActionByValControl() { return bAnyRegActionByValControl; } + bool anyRegNextStmt() { return bAnyRegNextStmt; } + bool anyRegCurStateRef() { return bAnyRegCurStateRef; } + bool anyRegBreak() { return bAnyRegBreak; } + bool anyLmSwitchError() { return bAnyLmSwitchError; } + bool anyConditions() { return bAnyConditions; } + + + /* Is is it possible to extend a range by bumping ranges that span only + * one character to the singles array. */ + bool canExtend( const RedTransList &list, int pos ); + + /* Pick single transitions from the ranges. */ + void moveTransToSingle( RedStateAp *state ); + void chooseSingle(); + + void makeFlat(); + + /* Move a selected transition from ranges to default. */ + void moveToDefault( RedTransAp *defTrans, RedStateAp *state ); + + /* Pick a default transition by largest span. */ + RedTransAp *chooseDefaultSpan( RedStateAp *state ); + void chooseDefaultSpan(); + + /* Pick a default transition by most number of ranges. */ + RedTransAp *chooseDefaultNumRanges( RedStateAp *state ); + void chooseDefaultNumRanges(); + + /* Pick a default transition tailored towards goto driven machine. */ + RedTransAp *chooseDefaultGoto( RedStateAp *state ); + void chooseDefaultGoto(); + + /* Ordering states by transition connections. */ + void optimizeStateOrdering( RedStateAp *state ); + void optimizeStateOrdering(); + + /* Ordering states by transition connections. */ + void depthFirstOrdering( RedStateAp *state ); + void depthFirstOrdering(); + + /* Set state ids. */ + void sequentialStateIds(); + void sortStateIdsByFinal(); + + /* Arrange states in by final id. This is a stable sort. */ + void sortStatesByFinal(); + + /* Sorting states by id. */ + void sortByStateId(); + + /* Locating the first final state. This is the final state with the lowest + * id. */ + void findFirstFinState(); + + void assignActionLocs(); + + RedTransAp *getErrorTrans(); + RedStateAp *getErrorState(); + + /* Is every char in the alphabet covered? */ + bool alphabetCovered( RedTransList &outRange ); + + RedTransAp *allocateTrans( RedStateAp *targState, RedAction *actionTable ); + + void partitionFsm( int nParts ); + + void setInTrans(); +}; + + +#endif /* _REDFSM_H */ diff --git a/contrib/tools/ragel5/redfsm/xmlparse.cpp b/contrib/tools/ragel5/redfsm/xmlparse.cpp new file mode 100644 index 0000000000..6da8c50e91 --- /dev/null +++ b/contrib/tools/ragel5/redfsm/xmlparse.cpp @@ -0,0 +1,3549 @@ +/* Automatically generated by Kelbt from "xmlparse.kl". + * + * Parts of this file are copied from Kelbt source covered by the GNU + * GPL. As a special exception, you may use the parts of this file copied + * from Kelbt source without restriction. The remainder is derived from + * "xmlparse.kl" and inherits the copyright status of that file. + */ + +#line 1 "xmlparse.kl" +/* + * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Ragel; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "xmlparse.h" +#include "common.h" +#include "gendata.h" +#include <iostream> + +#include <stdlib.h> +//#include <malloc.h> + +using std::cout; +using std::ostream; +using std::istream; +using std::cerr; +using std::endl; + +Key readKey( char *td, char **end ); +long readOffsetPtr( char *td, char **end ); +unsigned long readLength( char *td ); + +#line 117 "xmlparse.kh" +#line 120 "xmlparse.kh" +#line 163 "xmlparse.kh" +#line 846 "xmlparse.kl" + + +#line 54 "xmlparse.cpp" +struct Parser_Lel_inline_item_type +{ +#line 499 "xmlparse.kl" + + InlineItem *inlineItem; + + +#line 61 "xmlparse.cpp" +}; + +struct Parser_Lel_inline_list +{ +#line 480 "xmlparse.kl" + + InlineList *inlineList; + + +#line 71 "xmlparse.cpp" +}; + +struct Parser_Lel_lm_action_list +{ +#line 716 "xmlparse.kl" + + InlineList *inlineList; + + +#line 81 "xmlparse.cpp" +}; + +struct Parser_Lel_tag_arg +{ +#line 256 "xmlparse.kl" + + char *option; + + +#line 91 "xmlparse.cpp" +}; + +struct Parser_Lel_tag_write_head +{ +#line 220 "xmlparse.kl" + + InputLoc loc; + + +#line 101 "xmlparse.cpp" +}; + +union Parser_UserData +{ + struct Parser_Lel_inline_item_type inline_item_type; + struct Parser_Lel_inline_list inline_list; + struct Parser_Lel_lm_action_list lm_action_list; + struct Parser_Lel_tag_arg tag_arg; + struct Parser_Lel_tag_write_head tag_write_head; + struct Token token; +}; + +struct Parser_LangEl +{ + char *file; + int line; + int type; + int reduction; + int state; + union Parser_UserData user; + unsigned int retry; + struct Parser_LangEl *next, *child; +}; + +#line 127 "xmlparse.cpp" +unsigned int Parser_startState = 0; + +short Parser_indicies[] = { + 142, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 140, 139, 0, 1, 283, 144, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 144, 144, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 144, -1, -1, -1, -1, -1, + -1, -1, -1, 2, 146, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 151, + 146, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 146, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 3, 143, -1, -1, -1, + 4, 5, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 6, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 169, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 145, 147, 148, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 7, 153, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 153, -1, -1, -1, -1, + -1, -1, 153, -1, 153, -1, -1, -1, + -1, -1, -1, -1, 153, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 153, 153, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 8, + 141, 9, 171, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 171, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 10, 11, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 174, -1, -1, + -1, -1, -1, -1, 12, -1, 13, -1, + -1, -1, -1, -1, -1, -1, 16, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 15, 14, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 152, 154, 155, 156, 157, 158, + 159, -1, -1, -1, -1, -1, -1, 17, + 149, 18, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 19, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 170, 150, 20, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 217, -1, -1, -1, -1, + -1, -1, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, -1, 217, 217, 217, 217, + 217, 217, 217, -1, -1, -1, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 21, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 217, -1, -1, -1, -1, + -1, -1, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, -1, 217, 217, 217, 217, + 217, 217, 217, -1, -1, -1, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 24, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 217, -1, -1, -1, -1, + -1, -1, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, -1, 217, 217, 217, 217, + 217, 217, 217, -1, -1, -1, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 23, 162, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 162, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 22, 176, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 176, -1, -1, -1, -1, 176, 176, + 176, 176, -1, -1, -1, -1, -1, -1, + 176, -1, 176, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 25, 168, 26, 164, 27, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 52, -1, -1, -1, -1, -1, -1, + 28, 29, 30, 31, 32, 33, 34, 35, + 37, 38, 39, 40, 41, 42, 43, 44, + 45, -1, 53, 47, 51, 50, 48, 46, + 49, -1, -1, -1, 36, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 216, -1, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, + 228, 229, 230, 231, 232, 233, 234, 235, + 236, 237, 238, 239, 240, 241, 242, 243, + 54, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 55, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 161, 56, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 52, -1, -1, -1, + -1, -1, -1, 28, 29, 30, 31, 32, + 33, 34, 35, 37, 38, 39, 40, 41, + 42, 43, 44, 45, -1, 53, 47, 51, + 50, 48, 46, 49, -1, -1, -1, 36, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 216, + -1, 218, 219, 220, 221, 222, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, + 233, 234, 235, 236, 237, 238, 239, 240, + 241, 242, 243, 57, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 52, -1, -1, -1, -1, -1, -1, 28, + 29, 30, 31, 32, 33, 34, 35, 37, + 38, 39, 40, 41, 42, 43, 44, 45, + -1, 53, 47, 51, 50, 48, 46, 49, + -1, -1, -1, 36, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 216, -1, 218, 219, 220, + 221, 222, 223, 224, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, + 237, 238, 239, 240, 241, 242, 243, 58, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 191, -1, -1, -1, + -1, 59, 60, 212, 274, -1, -1, -1, + -1, -1, -1, 61, -1, 279, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 175, 177, 178, 179, + 180, 181, 182, 183, -1, -1, 62, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 63, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 64, -1, -1, + 65, 172, 165, 67, 68, 69, 70, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 217, -1, -1, -1, + -1, -1, -1, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, -1, 217, 217, 217, + 217, 217, 217, 217, -1, -1, -1, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 71, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 217, -1, -1, -1, + -1, -1, -1, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, -1, 217, 217, 217, + 217, 217, 217, 217, -1, -1, -1, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 72, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 217, -1, -1, -1, + -1, -1, -1, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, -1, 217, 217, 217, + 217, 217, 217, 217, -1, -1, -1, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 73, 74, + 91, 75, 76, 77, 217, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 217, -1, -1, -1, -1, -1, -1, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, -1, 217, 217, 217, 217, 217, 217, + 217, -1, -1, -1, 217, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 78, 79, 217, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 217, -1, -1, -1, -1, -1, + -1, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, -1, 217, 217, 217, 217, 217, + 217, 217, -1, -1, -1, 217, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 80, 81, 82, 83, + 89, 85, 88, 90, 87, 86, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 217, -1, -1, -1, -1, + -1, -1, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, -1, 217, 217, 217, 217, + 217, 217, 217, -1, -1, -1, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 66, 271, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 271, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 84, 160, 92, 167, 166, 173, + 93, 94, 188, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 188, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 95, + 193, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 193, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 96, 214, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 214, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 97, + 276, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 276, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 98, + 100, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 99, 281, 101, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 52, -1, -1, -1, -1, -1, + -1, 28, 29, 30, 31, 32, 33, 34, + 35, 37, 38, 39, 40, 41, 42, 43, + 44, 45, -1, 53, 47, 51, 50, 48, + 46, 49, -1, -1, -1, 36, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 216, -1, 218, + 219, 220, 221, 222, 223, 224, 225, 226, + 227, 228, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 102, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 52, -1, -1, -1, -1, -1, + -1, 28, 29, 30, 31, 32, 33, 34, + 35, 37, 38, 39, 40, 41, 42, 43, + 44, 45, -1, 53, 47, 51, 50, 48, + 46, 49, -1, -1, -1, 36, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 216, -1, 218, + 219, 220, 221, 222, 223, 224, 225, 226, + 227, 228, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, + 243, 103, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 52, -1, + -1, -1, -1, -1, -1, 28, 29, 30, + 31, 32, 33, 34, 35, 37, 38, 39, + 40, 41, 42, 43, 44, 45, -1, 53, + 47, 51, 50, 48, 46, 49, -1, -1, + -1, 36, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 216, -1, 218, 219, 220, 221, 222, + 223, 224, 225, 226, 227, 228, 229, 230, + 231, 232, 233, 234, 235, 236, 237, 238, + 239, 240, 241, 242, 243, 104, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 52, -1, -1, -1, -1, -1, + -1, 28, 29, 30, 31, 32, 33, 34, + 35, 37, 38, 39, 40, 41, 42, 43, + 44, 45, -1, 53, 47, 51, 50, 48, + 46, 49, -1, -1, -1, 36, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 216, -1, 218, + 219, 220, 221, 222, 223, 224, 225, 226, + 227, 228, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, + 243, 251, 253, 254, 255, 105, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 52, -1, -1, -1, -1, -1, + -1, 28, 29, 30, 31, 32, 33, 34, + 35, 37, 38, 39, 40, 41, 42, 43, + 44, 45, -1, 53, 47, 51, 50, 48, + 46, 49, -1, -1, -1, 36, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 216, -1, 218, + 219, 220, 221, 222, 223, 224, 225, 226, + 227, 228, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, + 243, 257, 106, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 52, + -1, -1, -1, -1, -1, -1, 28, 29, + 30, 31, 32, 33, 34, 35, 37, 38, + 39, 40, 41, 42, 43, 44, 45, -1, + 53, 47, 51, 50, 48, 46, 49, -1, + -1, -1, 36, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 216, -1, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, + 238, 239, 240, 241, 242, 243, 259, 260, + 261, 107, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 108, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 270, 263, + 267, 266, 264, 262, 265, 252, 163, 184, + 185, 109, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 110, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 187, + 111, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 112, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 192, 113, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 114, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 213, 115, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 116, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 275, 118, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 100, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 280, 117, + 268, 248, 249, 250, 256, 258, 269, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 217, -1, -1, -1, + -1, -1, -1, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, -1, 217, 217, 217, + 217, 217, 217, 217, -1, -1, -1, 217, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 119, 186, + 120, 190, 196, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 196, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 196, -1, -1, + -1, -1, 196, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 121, 211, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 217, -1, -1, -1, -1, + -1, -1, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, -1, 217, 217, 217, 217, + 217, 217, 217, -1, -1, -1, 217, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 122, 273, 123, + 282, 278, 124, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 52, + -1, -1, -1, -1, -1, -1, 28, 29, + 30, 31, 32, 33, 34, 35, 37, 38, + 39, 40, 41, 42, 43, 44, 45, -1, + 53, 47, 51, 50, 48, 46, 49, -1, + -1, -1, 36, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 216, -1, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, + 238, 239, 240, 241, 242, 243, 189, 125, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 207, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 126, -1, -1, -1, -1, 202, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 195, 197, 198, 199, 127, -1, + -1, 128, 129, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 52, + -1, -1, -1, -1, -1, -1, 28, 29, + 30, 31, 32, 33, 34, 35, 37, 38, + 39, 40, 41, 42, 43, 44, 45, -1, + 53, 47, 51, 50, 48, 46, 49, -1, + -1, -1, 36, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 216, -1, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, + 238, 239, 240, 241, 242, 243, 277, 272, + 194, 130, 204, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 204, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 131, 209, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 209, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 132, 215, + 200, 133, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 134, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 203, 135, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 136, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 208, + 201, 137, 206, 138, 205, 210, +}; + +unsigned short Parser_keys[] = { + 129, 188, 185, 185, 47, 189, 47, 195, + 47, 207, 47, 196, 129, 129, 47, 47, + 47, 208, 47, 210, 131, 131, 47, 209, + 130, 130, 47, 47, 47, 206, 47, 206, + 47, 206, 47, 204, 47, 211, 180, 180, + 47, 47, 143, 143, 47, 266, 47, 205, + 47, 266, 47, 266, 47, 272, 184, 184, + 145, 145, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 206, 47, 206, 47, 206, + 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 206, 47, 47, 47, 206, + 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 206, 47, 267, 153, 153, + 47, 47, 181, 181, 182, 182, 136, 136, + 47, 47, 47, 47, 47, 220, 47, 223, + 47, 237, 47, 270, 150, 274, 47, 266, + 155, 155, 156, 156, 157, 157, 158, 158, + 47, 266, 47, 266, 47, 266, 162, 162, + 163, 163, 164, 164, 165, 165, 47, 266, + 167, 167, 47, 266, 169, 169, 170, 170, + 171, 171, 47, 268, 174, 174, 175, 175, + 176, 176, 177, 177, 178, 178, 179, 179, + 183, 183, 154, 154, 137, 137, 138, 138, + 47, 221, 47, 224, 47, 238, 47, 271, + 47, 274, 47, 47, 148, 148, 159, 159, + 160, 160, 161, 161, 166, 166, 168, 168, + 173, 173, 47, 206, 147, 147, 47, 47, + 132, 132, 47, 225, 139, 139, 47, 206, + 140, 140, 47, 47, 150, 150, 149, 149, + 47, 266, 171, 171, 47, 233, 47, 266, + 142, 142, 148, 148, 133, 133, 47, 47, + 47, 231, 47, 234, 141, 141, 146, 146, + 47, 232, 47, 235, 151, 151, 47, 47, + 134, 134, 47, 47, 152, 152, 135, 135, + 0, 0 +}; + +unsigned int Parser_offsets[] = { + 0, 60, 61, 204, 353, 514, 664, 665, + 666, 828, 992, 993, 1156, 1157, 1158, 1318, + 1478, 1638, 1796, 1961, 1962, 1963, 1964, 2184, + 2343, 2563, 2783, 3009, 3010, 3011, 3012, 3013, + 3014, 3015, 3175, 3335, 3495, 3496, 3497, 3498, + 3499, 3500, 3660, 3661, 3821, 3822, 3823, 3824, + 3825, 3826, 3827, 3828, 3829, 3830, 3990, 4211, + 4212, 4213, 4214, 4215, 4216, 4217, 4218, 4392, + 4569, 4760, 4984, 5109, 5329, 5330, 5331, 5332, + 5333, 5553, 5773, 5993, 5994, 5995, 5996, 5997, + 6217, 6218, 6438, 6439, 6440, 6441, 6663, 6664, + 6665, 6666, 6667, 6668, 6669, 6670, 6671, 6672, + 6673, 6848, 7026, 7218, 7443, 7671, 7672, 7673, + 7674, 7675, 7676, 7677, 7678, 7679, 7839, 7840, + 7841, 7842, 8021, 8022, 8182, 8183, 8184, 8185, + 8186, 8406, 8407, 8594, 8814, 8815, 8816, 8817, + 8818, 9003, 9191, 9192, 9193, 9379, 9568, 9569, + 9570, 9571, 9572, 9573, 9574 +}; + +unsigned short Parser_targs[] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, + 121, 122, 123, 124, 125, 126, 127, 128, + 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140 +}; + +unsigned int Parser_actInds[] = { + 0, 2, 4, 6, 8, 10, 12, 14, + 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, + 48, 50, 52, 54, 56, 58, 60, 62, + 64, 66, 68, 70, 72, 74, 76, 78, + 80, 82, 84, 86, 88, 90, 92, 94, + 96, 98, 100, 102, 104, 106, 108, 110, + 112, 114, 116, 118, 120, 122, 124, 126, + 128, 130, 132, 134, 136, 138, 140, 142, + 144, 146, 148, 150, 152, 154, 156, 158, + 160, 162, 164, 166, 168, 170, 172, 174, + 176, 178, 180, 182, 184, 186, 188, 190, + 192, 194, 196, 198, 200, 202, 204, 206, + 208, 210, 212, 214, 216, 218, 220, 222, + 224, 226, 228, 230, 232, 234, 236, 238, + 240, 242, 244, 246, 248, 250, 252, 254, + 256, 258, 260, 262, 264, 266, 268, 270, + 272, 274, 276, 278, 280, 282, 284, 286, + 288, 290, 292, 294, 296, 298, 300, 302, + 304, 306, 308, 310, 312, 314, 316, 318, + 320, 322, 324, 326, 328, 330, 332, 334, + 336, 338, 340, 342, 344, 346, 348, 350, + 352, 354, 356, 358, 360, 362, 364, 366, + 368, 370, 372, 374, 376, 378, 380, 382, + 384, 386, 388, 390, 392, 394, 396, 398, + 400, 402, 404, 406, 408, 410, 412, 414, + 416, 418, 420, 422, 424, 426, 428, 430, + 432, 434, 436, 438, 440, 442, 444, 446, + 448, 450, 452, 454, 456, 458, 460, 462, + 464, 466, 468, 470, 472, 474, 476, 478, + 480, 482, 484, 486, 488, 490, 492, 494, + 496, 498, 500, 502, 504, 506, 508, 510, + 512, 514, 516, 518, 520, 522, 524, 526, + 528, 530, 532, 534, 536, 538, 540, 542, + 544, 546, 548, 550, 552, 554, 556, 558, + 560, 562, 564, 566 +}; + +unsigned int Parser_actions[] = { + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 3, 0, + 6, 0, 11, 0, 15, 0, 19, 0, + 22, 0, 27, 0, 30, 0, 35, 0, + 39, 0, 43, 0, 47, 0, 51, 0, + 55, 0, 58, 0, 63, 0, 67, 0, + 71, 0, 75, 0, 79, 0, 83, 0, + 87, 0, 91, 0, 94, 0, 99, 0, + 103, 0, 107, 0, 111, 0, 115, 0, + 119, 0, 123, 0, 127, 0, 130, 0, + 135, 0, 139, 0, 143, 0, 147, 0, + 150, 0, 155, 0, 159, 0, 163, 0, + 167, 0, 171, 0, 175, 0, 179, 0, + 183, 0, 187, 0, 191, 0, 195, 0, + 198, 0, 203, 0, 207, 0, 211, 0, + 215, 0, 218, 0, 223, 0, 227, 0, + 230, 0, 235, 0, 239, 0, 243, 0, + 247, 0, 251, 0, 255, 0, 259, 0, + 262, 0, 267, 0, 271, 0, 275, 0, + 279, 0, 282, 0, 287, 0, 291, 0, + 295, 0, 299, 0, 302, 0, 307, 0, + 311, 0, 314, 0, 319, 0, 323, 0, + 327, 0, 331, 0, 335, 0, 339, 0, + 343, 0, 347, 0, 351, 0, 355, 0, + 359, 0, 363, 0, 367, 0, 371, 0, + 375, 0, 379, 0, 383, 0, 387, 0, + 391, 0, 395, 0, 399, 0, 403, 0, + 407, 0, 411, 0, 415, 0, 419, 0, + 423, 0, 427, 0, 431, 0, 435, 0, + 439, 0, 443, 0, 447, 0, 451, 0, + 455, 0, 459, 0, 463, 0, 467, 0, + 471, 0, 475, 0, 479, 0, 483, 0, + 487, 0, 491, 0, 495, 0, 499, 0, + 503, 0, 507, 0, 511, 0, 515, 0, + 519, 0, 523, 0, 527, 0, 530, 0, + 535, 0, 539, 0, 543, 0, 547, 0, + 550, 0, 555, 0, 559, 0, 563, 0, + 567, 0, 571, 0, 575, 0, 1, 0 +}; + +int Parser_commitLen[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2 +}; + +unsigned int Parser_fssProdIdIndex[] = { + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, + 144 +}; + +char Parser_fssProdLengths[] = { + 1, 0, 5, 1, 2, 0, 2, 0, + 1, 1, 3, 4, 1, 2, 0, 1, + 1, 1, 1, 1, 1, 4, 2, 0, + 3, 3, 4, 4, 4, 4, 1, 2, + 0, 3, 4, 1, 2, 0, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 4, + 2, 0, 3, 4, 1, 2, 0, 4, + 2, 0, 1, 1, 1, 3, 4, 1, + 2, 0, 3, 4, 1, 2, 0, 3, + 4, 1, 2, 0, 4, 2, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 3, 3, 4, 4, 4, + 3, 3, 3, 3, 3, 4, 3, 4, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 4, 4, 2, 0, 4, 4, 1, + 2, 0, 3, 4, 1, 2, 1, 3, + 1 +}; + +unsigned short Parser_prodLhsIds[] = { + 187, 187, 186, 188, 189, 189, 190, 190, + 192, 192, 193, 191, 195, 196, 196, 197, + 197, 197, 197, 197, 197, 202, 204, 204, + 205, 198, 199, 200, 201, 194, 207, 208, + 208, 209, 203, 210, 211, 211, 212, 212, + 212, 212, 212, 212, 212, 213, 214, 215, + 220, 220, 221, 216, 222, 223, 223, 224, + 225, 225, 226, 226, 226, 227, 228, 230, + 231, 231, 232, 229, 233, 234, 234, 235, + 217, 236, 237, 237, 238, 206, 206, 239, + 239, 239, 239, 239, 239, 239, 239, 239, + 239, 239, 239, 239, 239, 239, 239, 239, + 239, 239, 239, 239, 239, 239, 239, 239, + 239, 241, 242, 243, 244, 245, 246, 247, + 248, 249, 250, 251, 252, 253, 254, 255, + 256, 257, 258, 259, 260, 261, 262, 263, + 264, 265, 266, 267, 267, 268, 218, 269, + 270, 270, 271, 219, 272, 273, 273, 274, + 275 +}; + +const char *Parser_prodNames[] = { + "start-1", + "start-2", + "tag_ragel-1", + "tag_ragel_head-1", + "ragel_def_list-1", + "ragel_def_list-2", + "host_or_write_list-1", + "host_or_write_list-2", + "host_or_write-1", + "host_or_write-2", + "tag_host-1", + "ragel_def-1", + "tag_ragel_def_head-1", + "ragel_def_item_list-1", + "ragel_def_item_list-2", + "ragel_def_item-1", + "ragel_def_item-2", + "ragel_def_item-3", + "ragel_def_item-4", + "ragel_def_item-5", + "ragel_def_item-6", + "tag_export_list-1", + "export_list-1", + "export_list-2", + "tag_export-1", + "tag_alph_type-1", + "tag_getkey_expr-1", + "tag_access_expr-1", + "tag_curstate_expr-1", + "tag_write-1", + "tag_write_head-1", + "write_option_list-1", + "write_option_list-2", + "tag_arg-1", + "tag_machine-1", + "tag_machine_head-1", + "machine_item_list-1", + "machine_item_list-2", + "machine_item-1", + "machine_item-2", + "machine_item-3", + "machine_item-4", + "machine_item-5", + "machine_item-6", + "machine_item-7", + "tag_start_state-1", + "tag_error_state-1", + "tag_entry_points-1", + "entry_point_list-1", + "entry_point_list-2", + "tag_entry-1", + "tag_state_list-1", + "tag_state_list_head-1", + "state_list-1", + "state_list-2", + "tag_state-1", + "state_item_list-1", + "state_item_list-2", + "state_item-1", + "state_item-2", + "state_item-3", + "tag_state_actions-1", + "tag_state_cond_list-1", + "tag_state_cond_list_head-1", + "state_cond_list-1", + "state_cond_list-2", + "state_cond-1", + "tag_trans_list-1", + "tag_trans_list_head-1", + "trans_list-1", + "trans_list-2", + "tag_trans-1", + "tag_action_list-1", + "tag_action_list_head-1", + "action_list-1", + "action_list-2", + "tag_action-1", + "inline_list-1", + "inline_list-2", + "inline_item-1", + "inline_item-2", + "inline_item-3", + "inline_item-4", + "inline_item-5", + "inline_item-6", + "inline_item-7", + "inline_item-8", + "inline_item-9", + "inline_item-10", + "inline_item-11", + "inline_item-12", + "inline_item-13", + "inline_item-14", + "inline_item-15", + "inline_item-16", + "inline_item-17", + "inline_item-18", + "inline_item-19", + "inline_item-20", + "inline_item-21", + "inline_item-22", + "inline_item-23", + "inline_item-24", + "inline_item-25", + "inline_item-26", + "tag_text-1", + "tag_goto-1", + "tag_call-1", + "tag_next-1", + "tag_goto_expr-1", + "tag_call_expr-1", + "tag_next_expr-1", + "tag_ret-1", + "tag_break-1", + "tag_pchar-1", + "tag_char-1", + "tag_hold-1", + "tag_exec-1", + "tag_holdte-1", + "tag_execte-1", + "tag_curs-1", + "tag_targs-1", + "tag_il_entry-1", + "tag_init_tokstart-1", + "tag_init_act-1", + "tag_get_tokend-1", + "tag_set_tokstart-1", + "tag_set_tokend-1", + "tag_set_act-1", + "tag_sub_action-1", + "tag_lm_switch-1", + "lm_action_list-1", + "lm_action_list-2", + "tag_inline_action-1", + "tag_action_table_list-1", + "tag_action_table_list_head-1", + "action_table_list-1", + "action_table_list-2", + "tag_action_table-1", + "tag_cond_space_list-1", + "tag_cond_space_list_head-1", + "cond_space_list-1", + "cond_space_list-2", + "tag_cond_space-1", + "_start-1" +}; + +const char *Parser_lelNames[] = { + "D-0", + "D-1", + "D-2", + "D-3", + "D-4", + "D-5", + "D-6", + "D-7", + "D-8", + "D-9", + "D-10", + "D-11", + "D-12", + "D-13", + "D-14", + "D-15", + "D-16", + "D-17", + "D-18", + "D-19", + "D-20", + "D-21", + "D-22", + "D-23", + "D-24", + "D-25", + "D-26", + "D-27", + "D-28", + "D-29", + "D-30", + "D-31", + "D-32", + "!", + "\"", + "#", + "$", + "%", + "&", + "'", + "(", + ")", + "*", + "+", + ",", + "-", + ".", + "/", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + ":", + ";", + "<", + "=", + ">", + "?", + "@", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "[", + "\\", + "]", + "^", + "_", + "`", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "{", + "|", + "}", + "~", + "D-127", + "TAG_unknown", + "TAG_ragel", + "TAG_ragel_def", + "TAG_host", + "TAG_state_list", + "TAG_state", + "TAG_trans_list", + "TAG_t", + "TAG_machine", + "TAG_start_state", + "TAG_error_state", + "TAG_action_list", + "TAG_action_table_list", + "TAG_action", + "TAG_action_table", + "TAG_alphtype", + "TAG_element", + "TAG_getkey", + "TAG_state_actions", + "TAG_entry_points", + "TAG_sub_action", + "TAG_cond_space_list", + "TAG_cond_space", + "TAG_cond_list", + "TAG_c", + "TAG_exports", + "TAG_ex", + "TAG_text", + "TAG_goto", + "TAG_call", + "TAG_next", + "TAG_goto_expr", + "TAG_call_expr", + "TAG_next_expr", + "TAG_ret", + "TAG_pchar", + "TAG_char", + "TAG_hold", + "TAG_exec", + "TAG_holdte", + "TAG_execte", + "TAG_curs", + "TAG_targs", + "TAG_entry", + "TAG_data", + "TAG_lm_switch", + "TAG_init_act", + "TAG_set_act", + "TAG_set_tokend", + "TAG_get_tokend", + "TAG_init_tokstart", + "TAG_set_tokstart", + "TAG_write", + "TAG_curstate", + "TAG_access", + "TAG_break", + "TAG_arg", + "_eof", + "tag_ragel", + "start", + "tag_ragel_head", + "ragel_def_list", + "host_or_write_list", + "ragel_def", + "host_or_write", + "tag_host", + "tag_write", + "tag_ragel_def_head", + "ragel_def_item_list", + "ragel_def_item", + "tag_alph_type", + "tag_getkey_expr", + "tag_access_expr", + "tag_curstate_expr", + "tag_export_list", + "tag_machine", + "export_list", + "tag_export", + "inline_list", + "tag_write_head", + "write_option_list", + "tag_arg", + "tag_machine_head", + "machine_item_list", + "machine_item", + "tag_start_state", + "tag_error_state", + "tag_entry_points", + "tag_state_list", + "tag_action_list", + "tag_action_table_list", + "tag_cond_space_list", + "entry_point_list", + "tag_entry", + "tag_state_list_head", + "state_list", + "tag_state", + "state_item_list", + "state_item", + "tag_state_actions", + "tag_state_cond_list", + "tag_trans_list", + "tag_state_cond_list_head", + "state_cond_list", + "state_cond", + "tag_trans_list_head", + "trans_list", + "tag_trans", + "tag_action_list_head", + "action_list", + "tag_action", + "inline_item", + "inline_item_type", + "tag_text", + "tag_goto", + "tag_call", + "tag_next", + "tag_goto_expr", + "tag_call_expr", + "tag_next_expr", + "tag_ret", + "tag_break", + "tag_pchar", + "tag_char", + "tag_hold", + "tag_exec", + "tag_holdte", + "tag_execte", + "tag_curs", + "tag_targs", + "tag_il_entry", + "tag_init_tokstart", + "tag_init_act", + "tag_get_tokend", + "tag_set_tokstart", + "tag_set_tokend", + "tag_set_act", + "tag_sub_action", + "tag_lm_switch", + "lm_action_list", + "tag_inline_action", + "tag_action_table_list_head", + "action_table_list", + "tag_action_table", + "tag_cond_space_list_head", + "cond_space_list", + "tag_cond_space", + "_start" +}; + +#line 851 "xmlparse.kl" + + +void Parser::init() +{ + #line 2079 "xmlparse.cpp" + curs = Parser_startState; + pool = 0; + freshEl = (struct Parser_LangEl*) malloc( sizeof(struct Parser_LangEl)*8128); + #ifdef LOG_ACTIONS + cerr << "allocating 8128 LangEls" << endl; + #endif + stackTop = freshEl; + stackTop->type = 0; + stackTop->state = -1; + stackTop->next = 0; + stackTop->child = 0; + freshPos = 1; + lastFinal = stackTop; + numRetry = 0; + numNodes = 0; + errCount = 0; +#line 856 "xmlparse.kl" +} + +int Parser::parseLangEl( int type, const Token *token ) +{ + #line 2101 "xmlparse.cpp" +#define reject() induceReject = 1 + + int pos, targState; + unsigned int *action; + int rhsLen; + struct Parser_LangEl *rhs[32]; + struct Parser_LangEl *lel; + struct Parser_LangEl *input; + char induceReject; + + if ( curs < 0 ) + return 0; + + if ( pool == 0 ) { + if ( freshPos == 8128 ) { + freshEl = (struct Parser_LangEl*) malloc( + sizeof(struct Parser_LangEl)*8128); + #ifdef LOG_ACTIONS + cerr << "allocating 8128 LangEls" << endl; + #endif + freshPos = 0; + } + input = freshEl + freshPos++; + } + else { + input = pool; + pool = pool->next; + } + numNodes += 1; + input->type = type; + input->user.token = *token; + input->next = 0; + input->retry = 0; + input->child = 0; + +again: + if ( input == 0 ) + goto _out; + + lel = input; + if ( lel->type < Parser_keys[curs<<1] || lel->type > Parser_keys[(curs<<1)+1] ) + goto parseError; + + pos = Parser_indicies[Parser_offsets[curs] + (lel->type - Parser_keys[curs<<1])]; + if ( pos < 0 ) + goto parseError; + + induceReject = 0; + targState = Parser_targs[pos]; + action = Parser_actions + Parser_actInds[pos]; + if ( lel->retry & 0x0000ffff ) + action += (lel->retry & 0x0000ffff); + + if ( *action & 0x1 ) { + #ifdef LOG_ACTIONS + cerr << "shifted: " << Parser_lelNames[lel->type]; + #endif + input = input->next; + lel->state = curs; + lel->next = stackTop; + stackTop = lel; + + if ( action[1] == 0 ) + lel->retry &= 0xffff0000; + else { + lel->retry += 1; + numRetry += 1; + #ifdef LOG_ACTIONS + cerr << " retry: " << stackTop; + #endif + } + #ifdef LOG_ACTIONS + cerr << endl; + #endif + } + + if ( Parser_commitLen[pos] != 0 ) { + struct Parser_LangEl *commitHead = stackTop; + int absCommitLen = Parser_commitLen[pos]; + + #ifdef LOG_ACTIONS + cerr << "running commit of length: " << Parser_commitLen[pos] << endl; + #endif + + if ( absCommitLen < 0 ) { + commitHead = commitHead->next; + absCommitLen = -1 * absCommitLen; + } + { + struct Parser_LangEl *lel = commitHead; + struct Parser_LangEl **cmStack = (struct Parser_LangEl**) malloc( sizeof(struct Parser_LangEl) * numNodes); + int n = absCommitLen, depth = 0, sp = 0; + +commit_head: + if ( lel->retry > 0 ) { + if ( lel->retry & 0x0000ffff ) + numRetry -= 1; + if ( lel->retry & 0xffff0000 ) + numRetry -= 1; + lel->retry = 0; + } + + /* If depth is > 0 then move over lel freely, otherwise, make + * sure that we have not already done n steps down the line. */ + if ( lel->next != 0 && ( depth > 0 || n > 1 ) ) { + cmStack[sp++] = lel; + lel = lel->next; + + /* If we are at the top level count the steps down the line. */ + if ( depth == 0 ) + n -= 1; + goto commit_head; + } + +commit_reverse: + if ( lel->child != 0 ) { + cmStack[sp++] = lel; + lel = lel->child; + + /* When we move down we need to increment the depth. */ + depth += 1; + goto commit_head; + } + +commit_upwards: + if ( sp > 0 ) { + /* Figure out which place to return to. */ + if ( cmStack[sp-1]->next == lel ) { + lel = cmStack[--sp]; + goto commit_reverse; + } + else { + /* Going back up, adjust the depth. */ + lel = cmStack[--sp]; + depth -= 1; + goto commit_upwards; + } + } + free( cmStack ); + } + if ( numRetry == 0 ) { + #ifdef LOG_ACTIONS + cerr << "number of retries is zero, " + "executing final actions" << endl; + #endif + { + struct Parser_LangEl *lel = commitHead; + struct Parser_LangEl **cmStack = (struct Parser_LangEl**) malloc( sizeof( struct Parser_LangEl) * numNodes); + int sp = 0; + char doExec = 0; + +final_head: + if ( lel == lastFinal ) { + doExec = 1; + goto hit_final; + } + + if ( lel->next != 0 ) { + cmStack[sp++] = lel; + lel = lel->next; + goto final_head; + } + +final_reverse: + + if ( lel->child != 0 ) { + cmStack[sp++] = lel; + lel = lel->child; + goto final_head; + } + +final_upwards: + + if ( doExec ) { +{ + if ( lel->type < 186 ) { + } + else { + struct Parser_LangEl *redLel = lel; + if ( redLel->child != 0 ) { + int r = Parser_fssProdLengths[redLel->reduction] - 1; + struct Parser_LangEl *rhsEl = redLel->child; + while ( rhsEl != 0 ) { + rhs[r--] = rhsEl; + rhsEl = rhsEl->next; + } + } +switch ( lel->reduction ) { +case 1: { +#line 46 "xmlparse.kl" + + /* If we get no input the assumption is that the frontend died and + * emitted an error. */ + errCount += 1; + + +#line 2297 "xmlparse.cpp" +} break; +case 3: { +#line 55 "xmlparse.kl" + + Attribute *fileNameAttr = (&rhs[0]->user.token)->tag->findAttr( "filename" ); + if ( fileNameAttr == 0 ) { + error((&rhs[0]->user.token)->loc) << "tag <ragel> requires a filename attribute" << endl; + exit(1); + } + else { + sourceFileName = fileNameAttr->value; + + Attribute *langAttr = (&rhs[0]->user.token)->tag->findAttr( "lang" ); + if ( langAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <ragel> requires a lang attribute" << endl; + else { + if ( strcmp( langAttr->value, "C" ) == 0 ) { + hostLangType = CCode; + hostLang = &hostLangC; + } + else if ( strcmp( langAttr->value, "D" ) == 0 ) { + hostLangType = DCode; + hostLang = &hostLangD; + } + else if ( strcmp( langAttr->value, "Java" ) == 0 ) { + hostLangType = JavaCode; + hostLang = &hostLangJava; + } + else if ( strcmp( langAttr->value, "Ruby" ) == 0 ) { + hostLangType = RubyCode; + hostLang = &hostLangRuby; + } + else { + error((&rhs[0]->user.token)->loc) << "expecting lang attribute to be " + "one of C, D, Java or Ruby" << endl; + } + + outStream = openOutput( sourceFileName ); + } + } + + +#line 2340 "xmlparse.cpp" +} break; +case 10: { +#line 105 "xmlparse.kl" + + Attribute *lineAttr = (&rhs[0]->user.token)->tag->findAttr( "line" ); + if ( lineAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <host> requires a line attribute" << endl; + else { + int line = atoi( lineAttr->value ); + if ( outputActive ) + lineDirective( *outStream, sourceFileName, line ); + } + + if ( outputActive ) + *outStream << (&rhs[2]->user.token)->tag->content; + + +#line 2358 "xmlparse.cpp" +} break; +case 11: { +#line 121 "xmlparse.kl" + + /* 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(); + + +#line 2376 "xmlparse.cpp" +} break; +case 12: { +#line 136 "xmlparse.kl" + + char *fsmName = 0; + Attribute *nameAttr = (&rhs[0]->user.token)->tag->findAttr( "name" ); + if ( nameAttr != 0 ) { + fsmName = nameAttr->value; + + CodeGenMapEl *mapEl = codeGenMap.find( fsmName ); + if ( mapEl != 0 ) + cgd = mapEl->value; + else { + cgd = makeCodeGen( sourceFileName, fsmName, *outStream, wantComplete ); + codeGenMap.insert( fsmName, cgd ); + } + } + else { + cgd = makeCodeGen( sourceFileName, fsmName, + *outStream, wantComplete ); + } + + ::keyOps = &cgd->thisKeyOps; + + +#line 2402 "xmlparse.cpp" +} break; +case 24: { +#line 174 "xmlparse.kl" + + Attribute *nameAttr = (&rhs[0]->user.token)->tag->findAttr( "name" ); + if ( nameAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <ex> requires a name attribute" << endl; + else { + char *td = (&rhs[2]->user.token)->tag->content; + Key exportKey = readKey( td, &td ); + cgd->exportList.append( new Export( nameAttr->value, exportKey ) ); + } + + +#line 2417 "xmlparse.cpp" +} break; +case 25: { +#line 186 "xmlparse.kl" + + if ( ! cgd->setAlphType( (&rhs[2]->user.token)->tag->content ) ) + error((&rhs[0]->user.token)->loc) << "tag <alphtype> specifies unknown alphabet type" << endl; + + +#line 2426 "xmlparse.cpp" +} break; +case 26: { +#line 192 "xmlparse.kl" + + cgd->getKeyExpr = (&rhs[1]->user.inline_list)->inlineList; + + +#line 2434 "xmlparse.cpp" +} break; +case 27: { +#line 197 "xmlparse.kl" + + cgd->accessExpr = (&rhs[1]->user.inline_list)->inlineList; + + +#line 2442 "xmlparse.cpp" +} break; +case 28: { +#line 202 "xmlparse.kl" + + cgd->curStateExpr = (&rhs[1]->user.inline_list)->inlineList; + + +#line 2450 "xmlparse.cpp" +} break; +case 29: { +#line 207 "xmlparse.kl" + + /* Terminate the options list and call the write statement handler. */ + writeOptions.append(0); + cgd->writeStatement( (&rhs[0]->user.tag_write_head)->loc, writeOptions.length()-1, writeOptions.data ); + + /* CodeGenData may have issued an error. */ + errCount += cgd->codeGenErrCount; + + /* Clear the options in prep for the next write statement. */ + writeOptions.empty(); + + +#line 2466 "xmlparse.cpp" +} break; +case 30: { +#line 225 "xmlparse.kl" + + Attribute *nameAttr = (&rhs[0]->user.token)->tag->findAttr( "def_name" ); + Attribute *lineAttr = (&rhs[0]->user.token)->tag->findAttr( "line" ); + Attribute *colAttr = (&rhs[0]->user.token)->tag->findAttr( "col" ); + + if ( nameAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <write> requires a def_name attribute" << endl; + if ( lineAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <write> requires a line attribute" << endl; + if ( colAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <write> requires a col attribute" << endl; + + if ( nameAttr != 0 && lineAttr != 0 && colAttr != 0 ) { + CodeGenMapEl *mapEl = codeGenMap.find( nameAttr->value ); + if ( mapEl == 0 ) + error((&rhs[0]->user.token)->loc) << "internal error: cannot find codeGen" << endl; + else { + cgd = mapEl->value; + ::keyOps = &cgd->thisKeyOps; + } + + (&redLel->user.tag_write_head)->loc.line = atoi(lineAttr->value); + (&redLel->user.tag_write_head)->loc.col = atoi(colAttr->value); + } + + +#line 2496 "xmlparse.cpp" +} break; +case 33: { +#line 261 "xmlparse.kl" + + writeOptions.append( (&rhs[2]->user.token)->tag->content ); + + +#line 2504 "xmlparse.cpp" +} break; +case 34: { +#line 266 "xmlparse.kl" + + cgd->closeMachine(); + + +#line 2512 "xmlparse.cpp" +} break; +case 35: { +#line 271 "xmlparse.kl" + + cgd->createMachine(); + + +#line 2520 "xmlparse.cpp" +} break; +case 45: { +#line 291 "xmlparse.kl" + + unsigned long startState = strtoul( (&rhs[2]->user.token)->tag->content, 0, 10 ); + cgd->setStartState( startState ); + + +#line 2529 "xmlparse.cpp" +} break; +case 46: { +#line 297 "xmlparse.kl" + + unsigned long errorState = strtoul( (&rhs[2]->user.token)->tag->content, 0, 10 ); + cgd->setErrorState( errorState ); + + +#line 2538 "xmlparse.cpp" +} break; +case 47: { +#line 303 "xmlparse.kl" + + Attribute *errorAttr = (&rhs[0]->user.token)->tag->findAttr( "error" ); + if ( errorAttr != 0 ) + cgd->setForcedErrorState(); + + +#line 2548 "xmlparse.cpp" +} break; +case 50: { +#line 313 "xmlparse.kl" + + Attribute *nameAttr = (&rhs[0]->user.token)->tag->findAttr( "name" ); + if ( nameAttr == 0 ) { + error((&rhs[0]->user.token)->loc) << "tag <entry_points>::<entry> " + "requires a name attribute" << endl; + } + else { + char *data = (&rhs[2]->user.token)->tag->content; + unsigned long entry = strtoul( data, &data, 10 ); + cgd->addEntryPoint( nameAttr->value, entry ); + } + + +#line 2565 "xmlparse.cpp" +} break; +case 52: { +#line 329 "xmlparse.kl" + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + if ( lengthAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <state_list> requires a length attribute" << endl; + else { + unsigned long length = strtoul( lengthAttr->value, 0, 10 ); + cgd->initStateList( length ); + curState = 0; + } + + +#line 2580 "xmlparse.cpp" +} break; +case 55: { +#line 344 "xmlparse.kl" + + Attribute *idAttr = (&rhs[0]->user.token)->tag->findAttr( "id" ); + if ( idAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <state> requires an id attribute" << endl; + else { + int id = atoi( idAttr->value ); + cgd->setId( curState, id ); + } + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "final" ); + if ( lengthAttr != 0 ) + cgd->setFinal( curState ); + curState += 1; + + +#line 2599 "xmlparse.cpp" +} break; +case 61: { +#line 367 "xmlparse.kl" + + char *ad = (&rhs[2]->user.token)->tag->content; + + long toStateAction = readOffsetPtr( ad, &ad ); + long fromStateAction = readOffsetPtr( ad, &ad ); + long eofAction = readOffsetPtr( ad, &ad ); + + cgd->setStateActions( curState, toStateAction, + fromStateAction, eofAction ); + + +#line 2614 "xmlparse.cpp" +} break; +case 63: { +#line 381 "xmlparse.kl" + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + if ( lengthAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <cond_list> requires a length attribute" << endl; + else { + ulong length = readLength( lengthAttr->value ); + cgd->initStateCondList( curState, length ); + curStateCond = 0; + } + + +#line 2629 "xmlparse.cpp" +} break; +case 66: { +#line 396 "xmlparse.kl" + + char *td = (&rhs[2]->user.token)->tag->content; + Key lowKey = readKey( td, &td ); + Key highKey = readKey( td, &td ); + long condId = readOffsetPtr( td, &td ); + cgd->addStateCond( curState, lowKey, highKey, condId ); + + +#line 2641 "xmlparse.cpp" +} break; +case 67: { +#line 405 "xmlparse.kl" + + cgd->finishTransList( curState ); + + +#line 2649 "xmlparse.cpp" +} break; +case 68: { +#line 410 "xmlparse.kl" + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + if ( lengthAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <trans_list> requires a length attribute" << endl; + else { + unsigned long length = strtoul( lengthAttr->value, 0, 10 ); + cgd->initTransList( curState, length ); + curTrans = 0; + } + + +#line 2664 "xmlparse.cpp" +} break; +case 71: { +#line 425 "xmlparse.kl" + + char *td = (&rhs[2]->user.token)->tag->content; + Key lowKey = readKey( td, &td ); + Key highKey = readKey( td, &td ); + long targ = readOffsetPtr( td, &td ); + long action = readOffsetPtr( td, &td ); + + cgd->newTrans( curState, curTrans++, lowKey, highKey, targ, action ); + + +#line 2678 "xmlparse.cpp" +} break; +case 73: { +#line 442 "xmlparse.kl" + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + if ( lengthAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <action_list> requires a length attribute" << endl; + else { + unsigned long length = strtoul( lengthAttr->value, 0, 10 ); + cgd->initActionList( length ); + curAction = 0; + } + + +#line 2693 "xmlparse.cpp" +} break; +case 76: { +#line 461 "xmlparse.kl" + + Attribute *lineAttr = (&rhs[0]->user.token)->tag->findAttr( "line" ); + Attribute *colAttr = (&rhs[0]->user.token)->tag->findAttr( "col" ); + Attribute *nameAttr = (&rhs[0]->user.token)->tag->findAttr( "name" ); + if ( lineAttr == 0 || colAttr == 0) + error((&rhs[0]->user.token)->loc) << "tag <action> requires a line and col attributes" << endl; + else { + unsigned long line = strtoul( lineAttr->value, 0, 10 ); + unsigned long col = strtoul( colAttr->value, 0, 10 ); + + char *name = 0; + if ( nameAttr != 0 ) + name = nameAttr->value; + + cgd->newAction( curAction++, name, line, col, (&rhs[1]->user.inline_list)->inlineList ); + } + + +#line 2715 "xmlparse.cpp" +} break; +case 77: { +#line 486 "xmlparse.kl" + + /* Append the item to the list, return the list. */ + (&rhs[0]->user.inline_list)->inlineList->append( (&rhs[1]->user.inline_item_type)->inlineItem ); + (&redLel->user.inline_list)->inlineList = (&rhs[0]->user.inline_list)->inlineList; + + +#line 2725 "xmlparse.cpp" +} break; +case 78: { +#line 493 "xmlparse.kl" + + /* Start with empty list. */ + (&redLel->user.inline_list)->inlineList = new InlineList; + + +#line 2734 "xmlparse.cpp" +} break; +case 79: { +#line 505 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2740 "xmlparse.cpp" +} break; +case 80: { +#line 506 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2746 "xmlparse.cpp" +} break; +case 81: { +#line 507 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2752 "xmlparse.cpp" +} break; +case 82: { +#line 508 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2758 "xmlparse.cpp" +} break; +case 83: { +#line 509 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2764 "xmlparse.cpp" +} break; +case 84: { +#line 510 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2770 "xmlparse.cpp" +} break; +case 85: { +#line 511 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2776 "xmlparse.cpp" +} break; +case 86: { +#line 512 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2782 "xmlparse.cpp" +} break; +case 87: { +#line 513 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2788 "xmlparse.cpp" +} break; +case 88: { +#line 514 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2794 "xmlparse.cpp" +} break; +case 89: { +#line 515 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2800 "xmlparse.cpp" +} break; +case 90: { +#line 516 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2806 "xmlparse.cpp" +} break; +case 91: { +#line 517 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2812 "xmlparse.cpp" +} break; +case 92: { +#line 518 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2818 "xmlparse.cpp" +} break; +case 93: { +#line 519 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2824 "xmlparse.cpp" +} break; +case 94: { +#line 520 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2830 "xmlparse.cpp" +} break; +case 95: { +#line 521 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2836 "xmlparse.cpp" +} break; +case 96: { +#line 522 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2842 "xmlparse.cpp" +} break; +case 97: { +#line 523 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2848 "xmlparse.cpp" +} break; +case 98: { +#line 524 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2854 "xmlparse.cpp" +} break; +case 99: { +#line 525 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2860 "xmlparse.cpp" +} break; +case 100: { +#line 526 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2866 "xmlparse.cpp" +} break; +case 101: { +#line 527 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2872 "xmlparse.cpp" +} break; +case 102: { +#line 528 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2878 "xmlparse.cpp" +} break; +case 103: { +#line 529 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2884 "xmlparse.cpp" +} break; +case 104: { +#line 530 "xmlparse.kl" + (&redLel->user.inline_item_type)->inlineItem = (&rhs[0]->user.inline_item_type)->inlineItem; + +#line 2890 "xmlparse.cpp" +} break; +case 105: { +#line 560 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Text ); + (&redLel->user.inline_item_type)->inlineItem->data = (&rhs[2]->user.token)->tag->content; + + +#line 2899 "xmlparse.cpp" +} break; +case 106: { +#line 566 "xmlparse.kl" + + int targ = strtol( (&rhs[2]->user.token)->tag->content, 0, 10 ); + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Goto ); + (&redLel->user.inline_item_type)->inlineItem->targId = targ; + + +#line 2909 "xmlparse.cpp" +} break; +case 107: { +#line 573 "xmlparse.kl" + + int targ = strtol( (&rhs[2]->user.token)->tag->content, 0, 10 ); + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Call ); + (&redLel->user.inline_item_type)->inlineItem->targId = targ; + + +#line 2919 "xmlparse.cpp" +} break; +case 108: { +#line 580 "xmlparse.kl" + + int targ = strtol( (&rhs[2]->user.token)->tag->content, 0, 10 ); + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Next ); + (&redLel->user.inline_item_type)->inlineItem->targId = targ; + + +#line 2929 "xmlparse.cpp" +} break; +case 109: { +#line 587 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::GotoExpr ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.inline_list)->inlineList; + + +#line 2938 "xmlparse.cpp" +} break; +case 110: { +#line 593 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::CallExpr ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.inline_list)->inlineList; + + +#line 2947 "xmlparse.cpp" +} break; +case 111: { +#line 599 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::NextExpr ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.inline_list)->inlineList; + + +#line 2956 "xmlparse.cpp" +} break; +case 112: { +#line 605 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Ret ); + + +#line 2964 "xmlparse.cpp" +} break; +case 113: { +#line 610 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Break ); + + +#line 2972 "xmlparse.cpp" +} break; +case 114: { +#line 615 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::PChar ); + + +#line 2980 "xmlparse.cpp" +} break; +case 115: { +#line 620 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Char ); + + +#line 2988 "xmlparse.cpp" +} break; +case 116: { +#line 625 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Hold ); + + +#line 2996 "xmlparse.cpp" +} break; +case 117: { +#line 630 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Exec ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.inline_list)->inlineList; + + +#line 3005 "xmlparse.cpp" +} break; +case 118: { +#line 636 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::HoldTE ); + + +#line 3013 "xmlparse.cpp" +} break; +case 119: { +#line 641 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::ExecTE ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.inline_list)->inlineList; + + +#line 3022 "xmlparse.cpp" +} break; +case 120: { +#line 647 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Curs ); + + +#line 3030 "xmlparse.cpp" +} break; +case 121: { +#line 652 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Targs ); + + +#line 3038 "xmlparse.cpp" +} break; +case 122: { +#line 657 "xmlparse.kl" + + int targ = strtol( (&rhs[2]->user.token)->tag->content, 0, 10 ); + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::Entry ); + (&redLel->user.inline_item_type)->inlineItem->targId = targ; + + +#line 3048 "xmlparse.cpp" +} break; +case 123: { +#line 664 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::LmInitTokStart ); + + +#line 3056 "xmlparse.cpp" +} break; +case 124: { +#line 669 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::LmInitAct ); + + +#line 3064 "xmlparse.cpp" +} break; +case 125: { +#line 674 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::LmGetTokEnd ); + + +#line 3072 "xmlparse.cpp" +} break; +case 126: { +#line 679 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSetTokStart ); + cgd->hasLongestMatch = true; + + +#line 3081 "xmlparse.cpp" +} break; +case 127: { +#line 685 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSetTokEnd ); + (&redLel->user.inline_item_type)->inlineItem->offset = strtol( (&rhs[2]->user.token)->tag->content, 0, 10 ); + + +#line 3090 "xmlparse.cpp" +} break; +case 128: { +#line 691 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSetActId ); + (&redLel->user.inline_item_type)->inlineItem->lmId = strtol( (&rhs[2]->user.token)->tag->content, 0, 10 ); + + +#line 3099 "xmlparse.cpp" +} break; +case 129: { +#line 697 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::SubAction ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.inline_list)->inlineList; + + +#line 3108 "xmlparse.cpp" +} break; +case 130: { +#line 704 "xmlparse.kl" + + bool handlesError = false; + Attribute *handlesErrorAttr = (&rhs[0]->user.token)->tag->findAttr( "handles_error" ); + if ( handlesErrorAttr != 0 ) + handlesError = true; + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSwitch ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.lm_action_list)->inlineList; + (&redLel->user.inline_item_type)->inlineItem->handlesError = handlesError; + + +#line 3123 "xmlparse.cpp" +} break; +case 131: { +#line 721 "xmlparse.kl" + + (&redLel->user.lm_action_list)->inlineList = (&rhs[0]->user.lm_action_list)->inlineList; + (&redLel->user.lm_action_list)->inlineList->append( (&rhs[1]->user.inline_item_type)->inlineItem ); + + +#line 3132 "xmlparse.cpp" +} break; +case 132: { +#line 726 "xmlparse.kl" + + (&redLel->user.lm_action_list)->inlineList = new InlineList; + + +#line 3140 "xmlparse.cpp" +} break; +case 133: { +#line 733 "xmlparse.kl" + + (&redLel->user.inline_item_type)->inlineItem = new InlineItem( InputLoc(), InlineItem::SubAction ); + (&redLel->user.inline_item_type)->inlineItem->children = (&rhs[1]->user.inline_list)->inlineList; + + Attribute *idAttr = (&rhs[0]->user.token)->tag->findAttr( "id" ); + if ( idAttr != 0 ) { + unsigned long id = strtoul( idAttr->value, 0, 10 ); + (&redLel->user.inline_item_type)->inlineItem->lmId = id; + } + + +#line 3155 "xmlparse.cpp" +} break; +case 135: { +#line 752 "xmlparse.kl" + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + if ( lengthAttr == 0 ) { + error((&rhs[0]->user.token)->loc) << "tag <action_table_list> requires " + "a length attribute" << endl; + } + else { + unsigned long length = strtoul( lengthAttr->value, 0, 10 ); + cgd->initActionTableList( length ); + curActionTable = 0; + } + + +#line 3172 "xmlparse.cpp" +} break; +case 138: { +#line 769 "xmlparse.kl" + + /* Find the length of the action table. */ + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + if ( lengthAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <at> requires a length attribute" << endl; + else { + unsigned long length = strtoul( lengthAttr->value, 0, 10 ); + + /* Collect the action table. */ + RedAction *redAct = cgd->allActionTables + curActionTable; + redAct->actListId = curActionTable; + redAct->key.setAsNew( length ); + char *ptr = (&rhs[2]->user.token)->tag->content; + int pos = 0; + while ( *ptr != 0 ) { + unsigned long actionId = strtoul( ptr, &ptr, 10 ); + redAct->key[pos].key = 0; + redAct->key[pos].value = cgd->allActions+actionId; + pos += 1; + } + + /* Insert into the action table map. */ + cgd->redFsm->actionMap.insert( redAct ); + } + + curActionTable += 1; + + +#line 3204 "xmlparse.cpp" +} break; +case 140: { +#line 804 "xmlparse.kl" + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + if ( lengthAttr == 0 ) { + error((&rhs[0]->user.token)->loc) << "tag <cond_space_list> " + "requires a length attribute" << endl; + } + else { + ulong length = readLength( lengthAttr->value ); + cgd->initCondSpaceList( length ); + curCondSpace = 0; + } + + +#line 3221 "xmlparse.cpp" +} break; +case 143: { +#line 821 "xmlparse.kl" + + Attribute *lengthAttr = (&rhs[0]->user.token)->tag->findAttr( "length" ); + Attribute *idAttr = (&rhs[0]->user.token)->tag->findAttr( "id" ); + if ( lengthAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <cond_space> requires a length attribute" << endl; + else { + if ( lengthAttr == 0 ) + error((&rhs[0]->user.token)->loc) << "tag <cond_space> requires an id attribute" << endl; + else { + unsigned long condSpaceId = strtoul( idAttr->value, 0, 10 ); + ulong length = readLength( lengthAttr->value ); + + char *td = (&rhs[2]->user.token)->tag->content; + Key baseKey = readKey( td, &td ); + + cgd->newCondSpace( curCondSpace, condSpaceId, baseKey ); + for ( ulong a = 0; a < length; a++ ) { + long actionOffset = readOffsetPtr( td, &td ); + cgd->condSpaceItem( curCondSpace, actionOffset ); + } + curCondSpace += 1; + } + } + + +#line 3250 "xmlparse.cpp" +} break; +} + } +} + + if ( lel->child != 0 ) { + struct Parser_LangEl *first = lel->child; + struct Parser_LangEl *child = lel->child; + numNodes -= 1; + lel->child = 0; + while ( child->next != 0 ) { + child = child->next; + numNodes -= 1; + } + child->next = pool; + pool = first; + } + } + +hit_final: + if ( sp > 0 ) { + /* Figure out which place to return to. */ + if ( cmStack[sp-1]->next == lel ) { + lel = cmStack[--sp]; + goto final_reverse; + } + else { + lel = cmStack[--sp]; + goto final_upwards; + } + } + + lastFinal = lel; + free( cmStack ); + } + } + } + + if ( *action & 0x2 ) { + int fssRed = *action >> 2; + int reduction = Parser_fssProdIdIndex[fssRed]; + struct Parser_LangEl *redLel; + if ( pool == 0 ) { + if ( freshPos == 8128 ) { + freshEl = (struct Parser_LangEl*) malloc( + sizeof(struct Parser_LangEl)*8128); + #ifdef LOG_ACTIONS + cerr << "allocating 8128 LangEls" << endl; + #endif + freshPos = 0; + } + redLel = freshEl + freshPos++; + } + else { + redLel = pool; + pool = pool->next; + } + numNodes += 1; + redLel->type = Parser_prodLhsIds[reduction]; + redLel->reduction = reduction; + redLel->child = 0; + redLel->next = 0; + redLel->retry = (lel->retry << 16); + lel->retry &= 0xffff0000; + + rhsLen = Parser_fssProdLengths[fssRed]; + if ( rhsLen > 0 ) { + int r; + for ( r = rhsLen-1; r > 0; r-- ) { + rhs[r] = stackTop; + stackTop = stackTop->next; + } + rhs[0] = stackTop; + stackTop = stackTop->next; + rhs[0]->next = 0; + } + #ifdef LOG_ACTIONS + cerr << "reduced: " + << Parser_prodNames[reduction] + << " rhsLen: " << rhsLen; + #endif + if ( action[1] == 0 ) + redLel->retry = 0; + else { + redLel->retry += 0x10000; + numRetry += 1; + #ifdef LOG_ACTIONS + cerr << " retry: " << redLel; + #endif + } + + #ifdef LOG_ACTIONS + cerr << endl; + #endif + + if ( rhsLen == 0 ) { + redLel->file = lel->file; + redLel->line = lel->line; + targState = curs; + } + else { + redLel->child = rhs[rhsLen-1]; + redLel->file = rhs[0]->file; + redLel->line = rhs[0]->line; + targState = rhs[0]->state; + } + + if ( induceReject ) { + #ifdef LOG_ACTIONS + cerr << "error induced during reduction of " << + Parser_lelNames[redLel->type] << endl; + #endif + redLel->state = curs; + redLel->next = stackTop; + stackTop = redLel; + curs = targState; + goto parseError; + } + else { + redLel->next = input; + input = redLel; + } + } + + + curs = targState; + goto again; + +parseError: + #ifdef LOG_BACKTRACK + cerr << "hit error" << endl; + #endif + if ( numRetry > 0 ) { + while ( 1 ) { + struct Parser_LangEl *redLel = stackTop; + if ( stackTop->type < 186 ) { + #ifdef LOG_BACKTRACK + cerr << "backing up over terminal: " << + Parser_lelNames[stackTop->type] << endl; + #endif + stackTop = stackTop->next; + redLel->next = input; + input = redLel; + } + else { + #ifdef LOG_BACKTRACK + cerr << "backing up over non-terminal: " << + Parser_lelNames[stackTop->type] << endl; + #endif + stackTop = stackTop->next; + struct Parser_LangEl *first = redLel->child; + if ( first == 0 ) + rhsLen = 0; + else { + rhsLen = 1; + while ( first->next != 0 ) { + first = first->next; + rhsLen += 1; + } + first->next = stackTop; + stackTop = redLel->child; + + struct Parser_LangEl *rhsEl = stackTop; + int p = rhsLen; + while ( p > 0 ) { + rhs[--p] = rhsEl; + rhsEl = rhsEl->next; + } + } + redLel->next = pool; + pool = redLel; + numNodes -= 1; + } + + if ( redLel->retry > 0 ) { + #ifdef LOG_BACKTRACK + cerr << "found retry targ: " << redLel << endl; + #endif + numRetry -= 1; + #ifdef LOG_BACKTRACK + cerr << "found retry: " << redLel << endl; + #endif + if ( redLel->retry & 0x0000ffff ) + curs = input->state; + else { + input->retry = redLel->retry >> 16; + if ( stackTop->state < 0 ) + curs = Parser_startState; + else { + curs = Parser_targs[(int)Parser_indicies[Parser_offsets[stackTop->state] + (stackTop->type - Parser_keys[stackTop->state<<1])]]; + } + } + goto again; + } + } + } + curs = -1; + errCount += 1; +_out: {} +#line 861 "xmlparse.kl" + return errCount == 0 ? 0 : -1; +} + + +unsigned long readLength( char *td ) +{ + return strtoul( td, 0, 10 ); +} + +Key readKey( char *td, char **end ) +{ + if ( keyOps->isSigned ) + return Key( strtol( td, end, 10 ) ); + else + return Key( strtoul( td, end, 10 ) ); +} + +long readOffsetPtr( char *td, char **end ) +{ + while ( *td == ' ' || *td == '\t' ) + td++; + + if ( *td == 'x' ) { + if ( end != 0 ) + *end = td + 1; + return -1; + } + + return strtol( td, end, 10 ); +} + +ostream &Parser::warning( const InputLoc &loc ) +{ + cerr << fileName << ":" << loc.line << ":" << loc.col << ": warning: "; + return cerr; +} + +ostream &Parser::error( const InputLoc &loc ) +{ + errCount += 1; + assert( fileName != 0 ); + cerr << fileName << ":" << loc.line << ":" << loc.col << ": "; + return cerr; +} + + +ostream &Parser::parser_error( int tokId, Token &token ) +{ + errCount += 1; + assert( fileName != 0 ); + cerr << fileName << ":" << token.loc.line << ":" << token.loc.col; + if ( token.tag != 0 ) { + if ( token.tag->tagId == 0 ) + cerr << ": at unknown tag"; + else + cerr << ": at tag <" << token.tag->tagId->name << ">"; + } + cerr << ": "; + + return cerr; +} + +int Parser::token( int tokenId, Token &tok ) +{ + int res = parseLangEl( tokenId, &tok ); + if ( res < 0 ) { + parser_error( tokenId, tok ) << "parse error" << endl; + exit(1); + } + return res; +} + +int Parser::token( int tokenId, int col, int line ) +{ + Token tok; + tok.loc.col = col; + tok.loc.line = line; + tok.tag = 0; + return token( tokenId, tok ); +} + +int Parser::token( XMLTag *tag, int col, int line ) +{ + Token tok; + tok.loc.col = col; + tok.loc.line = line; + tok.tag = tag; + + if ( tag->type == XMLTag::Close ) { + int res = token( '/', tok ); + if ( res < 0 ) + return res; + } + + tok.tag = tag; + return token( tag->tagId != 0 ? tag->tagId->id : TAG_unknown, tok ); +} diff --git a/contrib/tools/ragel5/redfsm/xmlparse.h b/contrib/tools/ragel5/redfsm/xmlparse.h new file mode 100644 index 0000000000..b51a7cd67a --- /dev/null +++ b/contrib/tools/ragel5/redfsm/xmlparse.h @@ -0,0 +1,228 @@ +/* Automatically generated by Kelbt from "xmlparse.kh". + * + * Parts of this file are copied from Kelbt source covered by the GNU + * GPL. As a special exception, you may use the parts of this file copied + * from Kelbt source without restriction. The remainder is derived from + * "xmlparse.kh" and inherits the copyright status of that file. + */ + +#line 1 "xmlparse.kh" +/* + * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Ragel; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _XMLPARSE_H +#define _XMLPARSE_H + +#include "vector.h" +#include "gendata.h" +#include <iostream> + +using std::ostream; + +struct AttrMarker +{ + char *id; + int idLen; + char *value; + int valueLen; +}; + +struct Attribute +{ + char *id; + char *value; +}; + +typedef Vector<AttrMarker> AttrMkList; +typedef Vector<Attribute> AttrList; +struct XMLTagHashPair; + +struct XMLTag +{ + enum TagType { Open, Close }; + + XMLTag( XMLTagHashPair *tagId, TagType type ) : + tagId(tagId), type(type), + content(0), attrList(0) {} + + Attribute *findAttr(const char *id ) + { + if ( attrList != 0 ) { + for ( AttrList::Iter attr = *attrList; attr.lte(); attr++ ) { + if ( strcmp( id, attr->id ) == 0 ) + return attr; + } + } + return 0; + } + + XMLTagHashPair *tagId; + TagType type; + + /* Content is associtated with closing tags. */ + char *content; + + /* Attribute lists are associated with opening tags. */ + AttrList *attrList; +}; + + +struct XMLTagHashPair +{ + const char *name; + int id; +}; + +struct Token +{ + XMLTag *tag; + InputLoc loc; +}; + +struct InlineItem; +struct InlineList; + +struct LmSwitchVect; +struct LmSwitchAction; + +struct Parser +{ + #line 117 "xmlparse.kh" + + + #line 111 "xmlparse.h" + struct Parser_LangEl *freshEl; + int freshPos; + struct Parser_LangEl *pool; + int numRetry; + int numNodes; + struct Parser_LangEl *stackTop; + struct Parser_LangEl *lastFinal; + int errCount; + int curs; +#line 120 "xmlparse.kh" + + void init(); + int parseLangEl( int type, const Token *token ); + + Parser(const char *fileName, bool outputActive, bool wantComplete ) : + fileName(fileName), sourceFileName(0), 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 ); + + /* Report an error encountered by the parser. */ + ostream &warning( const InputLoc &loc ); + ostream &error(); + ostream &error( const InputLoc &loc ); + ostream &parser_error( int tokId, Token &token ); + + /* The name of the root section, this does not change during an include. */ + const char *fileName; + char *sourceFileName; + ostream *outStream; + bool outputActive; + bool wantComplete; + + /* Collected during parsing. */ + char *attrKey; + char *attrValue; + int curAction; + int curActionTable; + int curTrans; + int curState; + int curCondSpace; + int curStateCond; + + CodeGenData *cgd; + CodeGenMap codeGenMap; + + Vector <char*> writeOptions; +}; + +#line 164 "xmlparse.h" +#define TAG_unknown 128 +#define TAG_ragel 129 +#define TAG_ragel_def 130 +#define TAG_host 131 +#define TAG_state_list 132 +#define TAG_state 133 +#define TAG_trans_list 134 +#define TAG_t 135 +#define TAG_machine 136 +#define TAG_start_state 137 +#define TAG_error_state 138 +#define TAG_action_list 139 +#define TAG_action_table_list 140 +#define TAG_action 141 +#define TAG_action_table 142 +#define TAG_alphtype 143 +#define TAG_element 144 +#define TAG_getkey 145 +#define TAG_state_actions 146 +#define TAG_entry_points 147 +#define TAG_sub_action 148 +#define TAG_cond_space_list 149 +#define TAG_cond_space 150 +#define TAG_cond_list 151 +#define TAG_c 152 +#define TAG_exports 153 +#define TAG_ex 154 +#define TAG_text 155 +#define TAG_goto 156 +#define TAG_call 157 +#define TAG_next 158 +#define TAG_goto_expr 159 +#define TAG_call_expr 160 +#define TAG_next_expr 161 +#define TAG_ret 162 +#define TAG_pchar 163 +#define TAG_char 164 +#define TAG_hold 165 +#define TAG_exec 166 +#define TAG_holdte 167 +#define TAG_execte 168 +#define TAG_curs 169 +#define TAG_targs 170 +#define TAG_entry 171 +#define TAG_data 172 +#define TAG_lm_switch 173 +#define TAG_init_act 174 +#define TAG_set_act 175 +#define TAG_set_tokend 176 +#define TAG_get_tokend 177 +#define TAG_init_tokstart 178 +#define TAG_set_tokstart 179 +#define TAG_write 180 +#define TAG_curstate 181 +#define TAG_access 182 +#define TAG_break 183 +#define TAG_arg 184 +#define _eof 185 + +#line 163 "xmlparse.kh" + +int xml_parse( std::istream &input, const char *fileName, + bool outputActive, bool wantComplete ); + +#endif /* _XMLPARSE_H */ diff --git a/contrib/tools/ragel5/redfsm/xmlscan.cpp b/contrib/tools/ragel5/redfsm/xmlscan.cpp new file mode 100644 index 0000000000..a3d979a0ff --- /dev/null +++ b/contrib/tools/ragel5/redfsm/xmlscan.cpp @@ -0,0 +1,925 @@ +#line 1 "xmlscan.rl" +/* + * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Ragel; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <iostream> +#include <string.h> +#include "vector.h" +#include "xmlparse.h" +#include "buffer.h" + +using std::istream; +using std::cout; +using std::cerr; +using std::endl; + +#define BUFSIZE 4096 + + +#line 37 "xmlscan.cpp" +static const int Scanner_start = 20; + +static const int Scanner_first_final = 20; + +static const int Scanner_error = 0; + +#line 37 "xmlscan.rl" + +#include "phash.h" + +struct Scanner +{ + Scanner(const char *fileName, istream &input ) : + fileName(fileName), + input(input), + curline(1), + curcol(1), + p(0), pe(0), + done(false), + data(0), data_len(0), + value(0) + { + +#line 69 "xmlscan.cpp" + { + cs = Scanner_start; + tokstart = 0; + tokend = 0; + act = 0; + } +#line 63 "xmlscan.rl" + + } + + int scan(); + void adjustAttrPointers( int distance ); + std::ostream &error(); + + const char *fileName; + istream &input; + + /* Scanner State. */ + int cs, act, have, curline, curcol; + char *tokstart, *tokend; + char *p, *pe; + int done; + + /* Token data */ + char *data; + int data_len; + int value; + AttrMkList attrMkList; + Buffer buffer; + char *tag_id_start; + int tag_id_len; + int token_col, token_line; + + char buf[BUFSIZE]; +}; + + +#define TK_NO_TOKEN (-1) +#define TK_ERR 1 +#define TK_SPACE 2 +#define TK_EOF 3 +#define TK_OpenTag 4 +#define TK_CloseTag 5 + +#define ret_tok( _tok ) token = (_tok); data = tokstart + +void Scanner::adjustAttrPointers( int distance ) +{ + for ( AttrMkList::Iter attr = attrMkList; attr.lte(); attr++ ) { + attr->id -= distance; + attr->value -= distance; + } +} + +/* There is no claim that this is a proper XML parser, but it is good + * enough for our purposes. */ +#line 178 "xmlscan.rl" + + +int Scanner::scan( ) +{ + int token = TK_NO_TOKEN; + int space = 0, readlen = 0; + char *attr_id_start = 0; + char *attr_value_start = 0; + int attr_id_len = 0; + int attr_value_len = 0; + + attrMkList.empty(); + buffer.clear(); + + while ( 1 ) { + if ( p == pe ) { + //printf("scanner: need more data\n"); + + if ( tokstart == 0 ) + have = 0; + else { + /* There is data that needs to be shifted over. */ + //printf("scanner: buffer broken mid token\n"); + have = pe - tokstart; + memmove( buf, tokstart, have ); + + int distance = tokstart - buf; + tokend -= distance; + tag_id_start -= distance; + attr_id_start -= distance; + attr_value_start -= distance; + adjustAttrPointers( distance ); + tokstart = buf; + } + + p = buf + have; + space = BUFSIZE - have; + + if ( space == 0 ) { + /* We filled up the buffer trying to scan a token. */ + return TK_SPACE; + } + + if ( done ) { + //printf("scanner: end of file\n"); + p[0] = 0; + readlen = 1; + } + else { + input.read( p, space ); + readlen = input.gcount(); + if ( input.eof() ) { + //printf("scanner: setting done flag\n"); + done = 1; + } + } + + pe = p + readlen; + } + + +#line 188 "xmlscan.cpp" + { + if ( p == pe ) + goto _out; + switch ( cs ) + { +tr6: +#line 115 "xmlscan.rl" + { curcol++; } +#line 168 "xmlscan.rl" + {tokend = p+1;{ buffer.append( '&' ); }{p = ((tokend))-1;}} + goto st20; +tr8: +#line 115 "xmlscan.rl" + { curcol++; } +#line 172 "xmlscan.rl" + {tokend = p+1;{ buffer.append( '>' ); }{p = ((tokend))-1;}} + goto st20; +tr10: +#line 115 "xmlscan.rl" + { curcol++; } +#line 170 "xmlscan.rl" + {tokend = p+1;{ buffer.append( '<' ); }{p = ((tokend))-1;}} + goto st20; +tr20: +#line 150 "xmlscan.rl" + { tag_id_len = p - tag_id_start; } +#line 115 "xmlscan.rl" + { curcol++; } +#line 160 "xmlscan.rl" + {tokend = p+1;{ ret_tok( TK_CloseTag ); {{p = ((tokend))-1;}goto _out20;} }{p = ((tokend))-1;}} + goto st20; +tr23: +#line 115 "xmlscan.rl" + { curcol++; } +#line 160 "xmlscan.rl" + {tokend = p+1;{ ret_tok( TK_CloseTag ); {{p = ((tokend))-1;}goto _out20;} }{p = ((tokend))-1;}} + goto st20; +tr27: +#line 150 "xmlscan.rl" + { tag_id_len = p - tag_id_start; } +#line 115 "xmlscan.rl" + { curcol++; } +#line 157 "xmlscan.rl" + {tokend = p+1;{ ret_tok( TK_OpenTag ); {{p = ((tokend))-1;}goto _out20;} }{p = ((tokend))-1;}} + goto st20; +tr30: +#line 115 "xmlscan.rl" + { curcol++; } +#line 157 "xmlscan.rl" + {tokend = p+1;{ ret_tok( TK_OpenTag ); {{p = ((tokend))-1;}goto _out20;} }{p = ((tokend))-1;}} + goto st20; +tr46: +#line 132 "xmlscan.rl" + { + attr_value_len = p - attr_value_start; + + AttrMarker newAttr; + newAttr.id = attr_id_start; + newAttr.idLen = attr_id_len; + newAttr.value = attr_value_start; + newAttr.valueLen = attr_value_len; + attrMkList.append( newAttr ); + } +#line 115 "xmlscan.rl" + { curcol++; } +#line 157 "xmlscan.rl" + {tokend = p+1;{ ret_tok( TK_OpenTag ); {{p = ((tokend))-1;}goto _out20;} }{p = ((tokend))-1;}} + goto st20; +tr48: +#line 115 "xmlscan.rl" + { curcol++; } +#line 164 "xmlscan.rl" + {tokend = p+1;{ buffer.append( *p ); }{p = ((tokend))-1;}} + goto st20; +tr49: +#line 116 "xmlscan.rl" + { token_col = curcol; token_line = curline; } +#line 175 "xmlscan.rl" + {tokend = p+1;{ ret_tok( TK_EOF ); {{p = ((tokend))-1;}goto _out20;} }{p = ((tokend))-1;}} + goto st20; +tr50: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } +#line 164 "xmlscan.rl" + {tokend = p+1;{ buffer.append( *p ); }{p = ((tokend))-1;}} + goto st20; +st20: +#line 1 "xmlscan.rl" + {tokstart = 0;} + if ( ++p == pe ) + goto _out20; +case 20: +#line 1 "xmlscan.rl" + {tokstart = p;} +#line 285 "xmlscan.cpp" + switch( (*p) ) { + case 0: goto tr49; + case 10: goto tr50; + case 38: goto tr51; + case 60: goto tr52; + } + goto tr48; +tr51: +#line 115 "xmlscan.rl" + { curcol++; } + goto st1; +st1: + if ( ++p == pe ) + goto _out1; +case 1: +#line 301 "xmlscan.cpp" + switch( (*p) ) { + case 97: goto tr0; + case 103: goto tr2; + case 108: goto tr3; + } + goto st0; +st0: + goto _out0; +tr0: +#line 115 "xmlscan.rl" + { curcol++; } + goto st2; +st2: + if ( ++p == pe ) + goto _out2; +case 2: +#line 318 "xmlscan.cpp" + if ( (*p) == 109 ) + goto tr4; + goto st0; +tr4: +#line 115 "xmlscan.rl" + { curcol++; } + goto st3; +st3: + if ( ++p == pe ) + goto _out3; +case 3: +#line 330 "xmlscan.cpp" + if ( (*p) == 112 ) + goto tr5; + goto st0; +tr5: +#line 115 "xmlscan.rl" + { curcol++; } + goto st4; +st4: + if ( ++p == pe ) + goto _out4; +case 4: +#line 342 "xmlscan.cpp" + if ( (*p) == 59 ) + goto tr6; + goto st0; +tr2: +#line 115 "xmlscan.rl" + { curcol++; } + goto st5; +st5: + if ( ++p == pe ) + goto _out5; +case 5: +#line 354 "xmlscan.cpp" + if ( (*p) == 116 ) + goto tr7; + goto st0; +tr7: +#line 115 "xmlscan.rl" + { curcol++; } + goto st6; +st6: + if ( ++p == pe ) + goto _out6; +case 6: +#line 366 "xmlscan.cpp" + if ( (*p) == 59 ) + goto tr8; + goto st0; +tr3: +#line 115 "xmlscan.rl" + { curcol++; } + goto st7; +st7: + if ( ++p == pe ) + goto _out7; +case 7: +#line 378 "xmlscan.cpp" + if ( (*p) == 116 ) + goto tr9; + goto st0; +tr9: +#line 115 "xmlscan.rl" + { curcol++; } + goto st8; +st8: + if ( ++p == pe ) + goto _out8; +case 8: +#line 390 "xmlscan.cpp" + if ( (*p) == 59 ) + goto tr10; + goto st0; +tr11: +#line 115 "xmlscan.rl" + { curcol++; } + goto st9; +tr12: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st9; +tr52: +#line 116 "xmlscan.rl" + { token_col = curcol; token_line = curline; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st9; +st9: + if ( ++p == pe ) + goto _out9; +case 9: +#line 414 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr11; + case 10: goto tr12; + case 13: goto tr11; + case 32: goto tr11; + case 47: goto tr13; + case 95: goto tr14; + } + if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr14; + } else if ( (*p) >= 65 ) + goto tr14; + goto st0; +tr13: +#line 115 "xmlscan.rl" + { curcol++; } + goto st10; +tr15: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st10; +st10: + if ( ++p == pe ) + goto _out10; +case 10: +#line 443 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr13; + case 10: goto tr15; + case 13: goto tr13; + case 32: goto tr13; + case 95: goto tr16; + } + if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr16; + } else if ( (*p) >= 65 ) + goto tr16; + goto st0; +tr19: +#line 115 "xmlscan.rl" + { curcol++; } + goto st11; +tr16: +#line 149 "xmlscan.rl" + { tag_id_start = p; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st11; +st11: + if ( ++p == pe ) + goto _out11; +case 11: +#line 471 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr17; + case 10: goto tr18; + case 13: goto tr17; + case 32: goto tr17; + case 62: goto tr20; + case 95: goto tr19; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr19; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr19; + } else + goto tr19; + goto st0; +tr21: +#line 115 "xmlscan.rl" + { curcol++; } + goto st12; +tr22: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st12; +tr17: +#line 150 "xmlscan.rl" + { tag_id_len = p - tag_id_start; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st12; +tr18: +#line 150 "xmlscan.rl" + { tag_id_len = p - tag_id_start; } +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st12; +st12: + if ( ++p == pe ) + goto _out12; +case 12: +#line 517 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr21; + case 10: goto tr22; + case 13: goto tr21; + case 32: goto tr21; + case 62: goto tr23; + } + goto st0; +tr26: +#line 115 "xmlscan.rl" + { curcol++; } + goto st13; +tr14: +#line 149 "xmlscan.rl" + { tag_id_start = p; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st13; +st13: + if ( ++p == pe ) + goto _out13; +case 13: +#line 540 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr24; + case 10: goto tr25; + case 13: goto tr24; + case 32: goto tr24; + case 62: goto tr27; + case 95: goto tr26; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr26; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr26; + } else + goto tr26; + goto st0; +tr28: +#line 115 "xmlscan.rl" + { curcol++; } + goto st14; +tr29: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st14; +tr24: +#line 150 "xmlscan.rl" + { tag_id_len = p - tag_id_start; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st14; +tr25: +#line 150 "xmlscan.rl" + { tag_id_len = p - tag_id_start; } +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st14; +tr44: +#line 132 "xmlscan.rl" + { + attr_value_len = p - attr_value_start; + + AttrMarker newAttr; + newAttr.id = attr_id_start; + newAttr.idLen = attr_id_len; + newAttr.value = attr_value_start; + newAttr.valueLen = attr_value_len; + attrMkList.append( newAttr ); + } +#line 115 "xmlscan.rl" + { curcol++; } + goto st14; +tr45: +#line 132 "xmlscan.rl" + { + attr_value_len = p - attr_value_start; + + AttrMarker newAttr; + newAttr.id = attr_id_start; + newAttr.idLen = attr_id_len; + newAttr.value = attr_value_start; + newAttr.valueLen = attr_value_len; + attrMkList.append( newAttr ); + } +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st14; +st14: + if ( ++p == pe ) + goto _out14; +case 14: +#line 618 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr28; + case 10: goto tr29; + case 13: goto tr28; + case 32: goto tr28; + case 62: goto tr30; + case 95: goto tr31; + } + if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr31; + } else if ( (*p) >= 65 ) + goto tr31; + goto st0; +tr34: +#line 115 "xmlscan.rl" + { curcol++; } + goto st15; +tr31: +#line 124 "xmlscan.rl" + { attr_id_start = p; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st15; +tr47: +#line 132 "xmlscan.rl" + { + attr_value_len = p - attr_value_start; + + AttrMarker newAttr; + newAttr.id = attr_id_start; + newAttr.idLen = attr_id_len; + newAttr.value = attr_value_start; + newAttr.valueLen = attr_value_len; + attrMkList.append( newAttr ); + } +#line 124 "xmlscan.rl" + { attr_id_start = p; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st15; +st15: + if ( ++p == pe ) + goto _out15; +case 15: +#line 664 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr32; + case 10: goto tr33; + case 13: goto tr32; + case 32: goto tr32; + case 61: goto tr35; + case 95: goto tr34; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr34; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr34; + } else + goto tr34; + goto st0; +tr36: +#line 115 "xmlscan.rl" + { curcol++; } + goto st16; +tr37: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st16; +tr32: +#line 125 "xmlscan.rl" + { attr_id_len = p - attr_id_start; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st16; +tr33: +#line 125 "xmlscan.rl" + { attr_id_len = p - attr_id_start; } +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st16; +st16: + if ( ++p == pe ) + goto _out16; +case 16: +#line 710 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr36; + case 10: goto tr37; + case 13: goto tr36; + case 32: goto tr36; + case 61: goto tr38; + } + goto st0; +tr38: +#line 115 "xmlscan.rl" + { curcol++; } + goto st17; +tr39: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st17; +tr35: +#line 125 "xmlscan.rl" + { attr_id_len = p - attr_id_start; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st17; +st17: + if ( ++p == pe ) + goto _out17; +case 17: +#line 739 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr38; + case 10: goto tr39; + case 13: goto tr38; + case 32: goto tr38; + case 34: goto tr40; + } + goto st0; +tr41: +#line 115 "xmlscan.rl" + { curcol++; } + goto st18; +tr42: +#line 117 "xmlscan.rl" + { curcol = 0; curline++; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st18; +tr40: +#line 130 "xmlscan.rl" + { attr_value_start = p; } +#line 115 "xmlscan.rl" + { curcol++; } + goto st18; +st18: + if ( ++p == pe ) + goto _out18; +case 18: +#line 768 "xmlscan.cpp" + switch( (*p) ) { + case 10: goto tr42; + case 34: goto tr43; + } + goto tr41; +tr43: +#line 115 "xmlscan.rl" + { curcol++; } + goto st19; +st19: + if ( ++p == pe ) + goto _out19; +case 19: +#line 782 "xmlscan.cpp" + switch( (*p) ) { + case 9: goto tr44; + case 10: goto tr45; + case 13: goto tr44; + case 32: goto tr44; + case 62: goto tr46; + case 95: goto tr47; + } + if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr47; + } else if ( (*p) >= 65 ) + goto tr47; + goto st0; + } + _out20: cs = 20; goto _out; + _out1: cs = 1; goto _out; + _out0: cs = 0; goto _out; + _out2: cs = 2; goto _out; + _out3: cs = 3; goto _out; + _out4: cs = 4; goto _out; + _out5: cs = 5; goto _out; + _out6: cs = 6; goto _out; + _out7: cs = 7; goto _out; + _out8: cs = 8; goto _out; + _out9: cs = 9; goto _out; + _out10: cs = 10; goto _out; + _out11: cs = 11; goto _out; + _out12: cs = 12; goto _out; + _out13: cs = 13; goto _out; + _out14: cs = 14; goto _out; + _out15: cs = 15; goto _out; + _out16: cs = 16; goto _out; + _out17: cs = 17; goto _out; + _out18: cs = 18; goto _out; + _out19: cs = 19; goto _out; + + _out: {} + } +#line 239 "xmlscan.rl" + + if ( cs == Scanner_error ) + return TK_ERR; + + if ( token != TK_NO_TOKEN ) { + /* fbreak does not advance p, so we do it manually. */ + p = p + 1; + data_len = p - data; + return token; + } + } +} + +int xml_parse( std::istream &input, const char *fileName, + bool outputActive, bool wantComplete ) +{ + Scanner scanner( fileName, input ); + Parser parser( fileName, outputActive, wantComplete ); + + parser.init(); + + while ( 1 ) { + int token = scanner.scan(); + if ( token == TK_NO_TOKEN ) { + cerr << "xmlscan: interal error: scanner returned NO_TOKEN" << endl; + exit(1); + } + else if ( token == TK_EOF ) { + parser.token( _eof, scanner.token_col, scanner.token_line ); + break; + } + else if ( token == TK_ERR ) { + scanner.error() << "scanner error" << endl; + break; + } + else if ( token == TK_SPACE ) { + scanner.error() << "scanner is out of buffer space" << endl; + break; + } + else { + /* All other tokens are either open or close tags. */ + XMLTagHashPair *tagId = Perfect_Hash::in_word_set( + scanner.tag_id_start, scanner.tag_id_len ); + + XMLTag *tag = new XMLTag( tagId, token == TK_OpenTag ? + XMLTag::Open : XMLTag::Close ); + + if ( tagId != 0 ) { + /* Get attributes for open tags. */ + if ( token == TK_OpenTag && scanner.attrMkList.length() > 0 ) { + tag->attrList = new AttrList; + for ( AttrMkList::Iter attr = scanner.attrMkList; + attr.lte(); attr++ ) + { + Attribute newAttr; + newAttr.id = new char[attr->idLen+1]; + memcpy( newAttr.id, attr->id, attr->idLen ); + newAttr.id[attr->idLen] = 0; + + /* Exclude the surrounding quotes. */ + newAttr.value = new char[attr->valueLen-1]; + memcpy( newAttr.value, attr->value+1, attr->valueLen-2 ); + newAttr.value[attr->valueLen-2] = 0; + + tag->attrList->append( newAttr ); + } + } + + /* Get content for closing tags. */ + if ( token == TK_CloseTag ) { + switch ( tagId->id ) { + case TAG_host: case TAG_arg: + case TAG_t: case TAG_alphtype: + case TAG_text: case TAG_goto: + case TAG_call: case TAG_next: + case TAG_entry: case TAG_set_tokend: + case TAG_set_act: case TAG_start_state: + case TAG_error_state: case TAG_state_actions: + case TAG_action_table: case TAG_cond_space: + case TAG_c: case TAG_ex: + tag->content = new char[scanner.buffer.length+1]; + memcpy( tag->content, scanner.buffer.data, + scanner.buffer.length ); + tag->content[scanner.buffer.length] = 0; + break; + } + } + } + + #if 0 + cerr << "parser_driver: " << (tag->type == XMLTag::Open ? "open" : "close") << + ": " << (tag->tagId != 0 ? tag->tagId->name : "<unknown>") << endl; + if ( tag->attrList != 0 ) { + for ( AttrList::Iter attr = *tag->attrList; attr.lte(); attr++ ) + cerr << " " << attr->id << ": " << attr->value << endl; + } + if ( tag->content != 0 ) + cerr << " content: " << tag->content << endl; + #endif + + parser.token( tag, scanner.token_col, scanner.token_line ); + } + } + + return 0; +} + +std::ostream &Scanner::error() +{ + cerr << fileName << ":" << curline << ":" << curcol << ": "; + return cerr; +} diff --git a/contrib/tools/ragel5/redfsm/xmltags.cpp b/contrib/tools/ragel5/redfsm/xmltags.cpp new file mode 100644 index 0000000000..5fbfabab1d --- /dev/null +++ b/contrib/tools/ragel5/redfsm/xmltags.cpp @@ -0,0 +1,244 @@ +/* C++ code produced by gperf version 3.0.1 */ +/* Command-line: gperf -L C++ -t xmltags.gperf */ +/* Computed positions: -k'1,3' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." +#endif + +#line 23 "xmltags.gperf" + +#include <string.h> +#include "xmlparse.h" +#line 28 "xmltags.gperf" +struct XMLTagHashPair; + +#define TOTAL_KEYWORDS 55 +#define MIN_WORD_LENGTH 1 +#define MAX_WORD_LENGTH 17 +#define MIN_HASH_VALUE 5 +#define MAX_HASH_VALUE 84 +/* maximum key range = 80, duplicates = 0 */ + +#include "phash.h" + +inline unsigned int +Perfect_Hash::hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 20, 85, 5, 41, 35, + 5, 35, 85, 15, 10, 0, 85, 85, 40, 0, + 15, 85, 40, 85, 25, 0, 10, 85, 85, 0, + 56, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85 + }; + int hval = len; + + switch (hval) + { + default: + hval += asso_values[(unsigned char)str[2]]; + /*FALLTHROUGH*/ + case 2: + case 1: + hval += asso_values[(unsigned char)str[0]]; + break; + } + return hval; +} + +struct XMLTagHashPair * +Perfect_Hash::in_word_set (register const char *str, register unsigned int len) +{ + static struct XMLTagHashPair wordlist[] = + { + {""}, {""}, {""}, {""}, {""}, +#line 74 "xmltags.gperf" + {"write", TAG_write}, + {""}, {""}, +#line 68 "xmltags.gperf" + {"init_act", TAG_init_act}, + {""}, +#line 34 "xmltags.gperf" + {"state", TAG_state}, +#line 36 "xmltags.gperf" + {"t", TAG_t}, + {""}, +#line 72 "xmltags.gperf" + {"init_tokstart", TAG_init_tokstart}, +#line 32 "xmltags.gperf" + {"host", TAG_host}, +#line 33 "xmltags.gperf" + {"state_list", TAG_state_list}, +#line 38 "xmltags.gperf" + {"start_state", TAG_start_state}, +#line 69 "xmltags.gperf" + {"set_act", TAG_set_act}, +#line 46 "xmltags.gperf" + {"state_actions", TAG_state_actions}, +#line 65 "xmltags.gperf" + {"data", TAG_data}, +#line 71 "xmltags.gperf" + {"set_tokend", TAG_set_tokend}, +#line 41 "xmltags.gperf" + {"action", TAG_action}, +#line 73 "xmltags.gperf" + {"set_tokstart", TAG_set_tokstart}, +#line 78 "xmltags.gperf" + {"arg", TAG_arg}, + {""}, +#line 35 "xmltags.gperf" + {"trans_list", TAG_trans_list}, +#line 40 "xmltags.gperf" + {"action_list", TAG_action_list}, +#line 43 "xmltags.gperf" + {"action_table", TAG_action_table}, + {""}, +#line 49 "xmltags.gperf" + {"goto", TAG_goto}, + {""}, +#line 45 "xmltags.gperf" + {"getkey", TAG_getkey}, +#line 42 "xmltags.gperf" + {"action_table_list", TAG_action_table_list}, + {""}, +#line 52 "xmltags.gperf" + {"goto_expr", TAG_goto_expr}, +#line 70 "xmltags.gperf" + {"get_tokend", TAG_get_tokend}, +#line 82 "xmltags.gperf" + {"c", TAG_c}, +#line 84 "xmltags.gperf" + {"ex", TAG_ex}, +#line 55 "xmltags.gperf" + {"ret", TAG_ret}, + {""}, +#line 63 "xmltags.gperf" + {"targs", TAG_targs}, + {""}, +#line 37 "xmltags.gperf" + {"machine", TAG_machine}, + {""}, +#line 57 "xmltags.gperf" + {"char", TAG_char}, +#line 30 "xmltags.gperf" + {"ragel", TAG_ragel}, +#line 76 "xmltags.gperf" + {"access", TAG_access}, + {""}, {""}, +#line 31 "xmltags.gperf" + {"ragel_def", TAG_ragel_def}, +#line 64 "xmltags.gperf" + {"entry", TAG_entry}, +#line 67 "xmltags.gperf" + {"sub_action", TAG_sub_action}, + {""}, +#line 44 "xmltags.gperf" + {"alphtype", TAG_alphtype}, +#line 58 "xmltags.gperf" + {"hold", TAG_hold}, +#line 56 "xmltags.gperf" + {"pchar", TAG_pchar}, +#line 60 "xmltags.gperf" + {"holdte", TAG_holdte}, +#line 47 "xmltags.gperf" + {"entry_points", TAG_entry_points}, + {""}, +#line 81 "xmltags.gperf" + {"cond_list", TAG_cond_list}, +#line 80 "xmltags.gperf" + {"cond_space", TAG_cond_space}, + {""}, {""}, {""}, +#line 62 "xmltags.gperf" + {"curs", TAG_curs}, +#line 79 "xmltags.gperf" + {"cond_space_list", TAG_cond_space_list}, + {""}, {""}, +#line 75 "xmltags.gperf" + {"curstate", TAG_curstate}, +#line 66 "xmltags.gperf" + {"lm_switch", TAG_lm_switch}, +#line 48 "xmltags.gperf" + {"text", TAG_text}, +#line 39 "xmltags.gperf" + {"error_state", TAG_error_state}, + {""}, {""}, +#line 59 "xmltags.gperf" + {"exec", TAG_exec}, +#line 51 "xmltags.gperf" + {"next", TAG_next}, +#line 61 "xmltags.gperf" + {"execte", TAG_execte}, + {""}, {""}, +#line 50 "xmltags.gperf" + {"call", TAG_call}, +#line 54 "xmltags.gperf" + {"next_expr", TAG_next_expr}, +#line 77 "xmltags.gperf" + {"break", TAG_break}, +#line 83 "xmltags.gperf" + {"exports", TAG_exports}, + {""}, +#line 53 "xmltags.gperf" + {"call_expr", TAG_call_expr} + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + const char *s = wordlist[key].name; + + if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') + return &wordlist[key]; + } + } + return 0; +} diff --git a/contrib/tools/ragel5/redfsm/ya.make b/contrib/tools/ragel5/redfsm/ya.make new file mode 100644 index 0000000000..8bb2b97d44 --- /dev/null +++ b/contrib/tools/ragel5/redfsm/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +LICENSE(GPL-2.0-or-later) + +NO_UTIL() +NO_COMPILER_WARNINGS() + +ADDINCL( + GLOBAL contrib/tools/ragel5/redfsm +) + +PEERDIR( + contrib/tools/ragel5/aapl + contrib/tools/ragel5/common +) + +SRCS( + gendata.cpp + redfsm.cpp + xmlparse.cpp + xmlscan.cpp + xmltags.cpp +) + +END() |