summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-02-23 22:51:38 -0500
committerAdrian Thurston <thurston@complang.org>2013-02-23 22:51:38 -0500
commitaeef465c0e89d5b689d349370329baef4c67b7eb (patch)
treec868f173f39aecfee4b5804f8970fd363f0ed2a4
parente6acde465c0cdaed67cbf463522faa093485d50b (diff)
downloadcolm-aeef465c0e89d5b689d349370329baef4c67b7eb.tar.gz
renamed TokenDef to TokenInstance
Will add back token def as the thing the user declares. Instances go into regions and a def can cause more than one instance to be created.
-rw-r--r--colm/compiler.cc22
-rw-r--r--colm/declare.cc10
-rw-r--r--colm/exports.cc12
-rw-r--r--colm/fsmap.cc4
-rw-r--r--colm/fsmcodegen.cc2
-rw-r--r--colm/fsmcodegen.h2
-rw-r--r--colm/fsmexec.cc2
-rw-r--r--colm/fsmgraph.h12
-rw-r--r--colm/lmparse.kh4
-rw-r--r--colm/lmparse.kl60
-rw-r--r--colm/parsedata.h4
-rw-r--r--colm/parsetree.cc20
-rw-r--r--colm/parsetree.h48
-rw-r--r--colm/pdabuild.cc18
-rw-r--r--colm/pdagraph.h2
-rw-r--r--colm/resolve.cc2
-rw-r--r--colm/synthesis.cc6
17 files changed, 115 insertions, 115 deletions
diff --git a/colm/compiler.cc b/colm/compiler.cc
index 4ec77ce7..0a38ab18 100644
--- a/colm/compiler.cc
+++ b/colm/compiler.cc
@@ -673,7 +673,7 @@ void Compiler::analyzeAction( Action *action, InlineList *inlineList )
/* Need to recurse into longest match items. */
if ( item->type == InlineItem::LmSwitch ) {
TokenRegion *lm = item->tokenRegion;
- for ( TokenDefListReg::Iter lmi = lm->tokenDefList; lmi.lte(); lmi++ ) {
+ for ( TokenInstanceListReg::Iter lmi = lm->tokenInstanceList; lmi.lte(); lmi++ ) {
if ( lmi->action != 0 )
analyzeAction( action, lmi->action->inlineList );
}
@@ -683,7 +683,7 @@ void Compiler::analyzeAction( Action *action, InlineList *inlineList )
item->type == InlineItem::LmOnNext ||
item->type == InlineItem::LmOnLagBehind )
{
- TokenDef *lmi = item->longestMatchPart;
+ TokenInstance *lmi = item->longestMatchPart;
if ( lmi->action != 0 )
analyzeAction( action, lmi->action->inlineList );
}
@@ -771,18 +771,18 @@ void Compiler::createDefaultScanner()
LexJoin *join = LexJoin::cons( LexExpression::cons( BT_Any ) );
- TokenDef *tokenDef = TokenDef::cons( name, String(), false, false,
+ TokenInstance *tokenInstance = TokenInstance::cons( name, String(), false, false,
join, 0, loc, nextTokenId++,
rootNamespace, defaultRegion, 0, 0, 0 );
- defaultRegion->tokenDefList.append( tokenDef );
+ defaultRegion->tokenInstanceList.append( tokenInstance );
/* Now create the one and only token -> "<chr>" / any / */
name = "___DEFAULT_SCANNER_CHR";
defaultCharLangEl = addLangEl( this, defaultNamespace, name, LangEl::Term );
- tokenDef->tdLangEl = defaultCharLangEl;
- defaultCharLangEl->tokenDef = tokenDef;
+ tokenInstance->tdLangEl = defaultCharLangEl;
+ defaultCharLangEl->tokenInstance = tokenInstance;
}
LangEl *Compiler::makeRepeatProd( const InputLoc &loc, Namespace *nspace,
@@ -972,7 +972,7 @@ Namespace *NamespaceQual::getQual( Compiler *pd )
void Compiler::initEmptyScanners()
{
for ( RegionList::Iter reg = regionList; reg.lte(); reg++ ) {
- if ( reg->tokenDefList.length() == 0 ) {
+ if ( reg->tokenInstanceList.length() == 0 ) {
reg->wasEmpty = true;
static int def = 1;
@@ -980,16 +980,16 @@ void Compiler::initEmptyScanners()
LexJoin *join = LexJoin::cons( LexExpression::cons( BT_Any ) );
- TokenDef *tokenDef = TokenDef::cons( name, String(), false, false, join,
+ TokenInstance *tokenInstance = TokenInstance::cons( name, String(), false, false, join,
0, internal, nextTokenId++, rootNamespace, reg, 0, 0, 0 );
- reg->tokenDefList.append( tokenDef );
+ reg->tokenInstanceList.append( tokenInstance );
/* These do not go in the namespace so so they cannot get declared
* in the declare pass. */
LangEl *lel = addLangEl( this, rootNamespace, name, LangEl::Term );
- tokenDef->tdLangEl = lel;
- lel->tokenDef = tokenDef;
+ tokenInstance->tdLangEl = lel;
+ lel->tokenInstance = tokenInstance;
}
}
}
diff --git a/colm/declare.cc b/colm/declare.cc
index daf6a57d..134e74bb 100644
--- a/colm/declare.cc
+++ b/colm/declare.cc
@@ -75,7 +75,7 @@ void LexFactorAug::varDecl( Compiler *pd, ObjectDef *objectDef )
void Compiler::varDeclaration()
{
for ( NamespaceList::Iter n = namespaceList; n.lte(); n++ ) {
- for ( TokenDefListNs::Iter tok = n->tokenDefList; tok.lte(); tok++ ) {
+ for ( TokenInstanceListNs::Iter tok = n->tokenInstanceList; tok.lte(); tok++ ) {
if ( tok->join != 0 )
tok->join->varDecl( this, tok->objectDef );
}
@@ -282,7 +282,7 @@ void Namespace::declare( Compiler *pd )
for ( GenericList::Iter g = genericList; g.lte(); g++ )
g->declare( pd, this );
- for ( TokenDefListNs::Iter l = tokenDefList; l.lte(); l++ ) {
+ for ( TokenInstanceListNs::Iter l = tokenInstanceList; l.lte(); l++ ) {
if ( l->isLiteral ) {
if ( l->dupOf != 0 ) {
/* Duplicate of another. Use the lang el of that token. */
@@ -300,7 +300,7 @@ void Namespace::declare( Compiler *pd )
newLangEl->lit = l->literal;
newLangEl->isLiteral = true;
- newLangEl->tokenDef = l;
+ newLangEl->tokenInstance = l;
l->tdLangEl = newLangEl;
@@ -345,7 +345,7 @@ void Namespace::declare( Compiler *pd )
lel->objectDef = c->context->contextObjDef;
}
- for ( TokenDefListNs::Iter t = tokenDefList; t.lte(); t++ ) {
+ for ( TokenInstanceListNs::Iter t = tokenInstanceList; t.lte(); t++ ) {
/* Literals already taken care of. */
if ( ! t->isLiteral ) {
if ( t->dupOf != 0 ) {
@@ -360,7 +360,7 @@ void Namespace::declare( Compiler *pd )
tokEl->transBlock = t->codeBlock;
tokEl->objectDef = t->objectDef;
tokEl->contextIn = t->contextIn;
- tokEl->tokenDef = t;
+ tokEl->tokenInstance = t;
if ( t->noPreIgnore )
tokEl->noPreIgnore = true;
diff --git a/colm/exports.cc b/colm/exports.cc
index e9ff5e4c..0f348a58 100644
--- a/colm/exports.cc
+++ b/colm/exports.cc
@@ -88,15 +88,15 @@ void Compiler::generateExports()
out << "// isEOF\n";
continue;
}
- if ( lel->tokenDef != 0 && lel->tokenDef->tokenRegion != 0 && lel->tokenDef->tokenRegion->isTokenOnly ) {
+ if ( lel->tokenInstance != 0 && lel->tokenInstance->tokenRegion != 0 && lel->tokenInstance->tokenRegion->isTokenOnly ) {
out << "// isTokenOnly\n";
continue;
}
- if ( lel->tokenDef != 0 && lel->tokenDef->tokenRegion != 0 && lel->tokenDef->tokenRegion->isIgnoreOnly ) {
+ if ( lel->tokenInstance != 0 && lel->tokenInstance->tokenRegion != 0 && lel->tokenInstance->tokenRegion->isIgnoreOnly ) {
out << "// isIgnoreOnly\n";
continue;
}
- if ( lel->tokenDef != 0 && lel->tokenDef->tokenRegion != 0 && lel->tokenDef->tokenRegion->isCiOnly ) {
+ if ( lel->tokenInstance != 0 && lel->tokenInstance->tokenRegion != 0 && lel->tokenInstance->tokenRegion->isCiOnly ) {
out << "// isCiOnly\n";
continue;
}
@@ -116,15 +116,15 @@ void Compiler::generateExports()
out << "// isTokenOnly\n";
continue;
}
- if ( lel->tokenDef != 0 && lel->tokenDef->tokenRegion != 0 && lel->tokenDef->tokenRegion->isTokenOnly ) {
+ if ( lel->tokenInstance != 0 && lel->tokenInstance->tokenRegion != 0 && lel->tokenInstance->tokenRegion->isTokenOnly ) {
out << "// isTokenOnly\n";
continue;
}
- if ( lel->tokenDef != 0 && lel->tokenDef->tokenRegion != 0 && lel->tokenDef->tokenRegion->isIgnoreOnly ) {
+ if ( lel->tokenInstance != 0 && lel->tokenInstance->tokenRegion != 0 && lel->tokenInstance->tokenRegion->isIgnoreOnly ) {
out << "// isIgnoreOnly\n";
continue;
}
- if ( lel->tokenDef != 0 && lel->tokenDef->tokenRegion != 0 && lel->tokenDef->tokenRegion->isCiOnly ) {
+ if ( lel->tokenInstance != 0 && lel->tokenInstance->tokenRegion != 0 && lel->tokenInstance->tokenRegion->isCiOnly ) {
out << "// isCiOnly\n";
continue;
}
diff --git a/colm/fsmap.cc b/colm/fsmap.cc
index e70e5887..cd955614 100644
--- a/colm/fsmap.cc
+++ b/colm/fsmap.cc
@@ -60,7 +60,7 @@ bool ActionTable::hasAction( Action *action )
}
/* Insert an action into an action table. */
-void LmActionTable::setAction( int ordering, TokenDef *action )
+void LmActionTable::setAction( int ordering, TokenInstance *action )
{
/* Multi-insert in case specific instances of an action appear in a
* transition more than once. */
@@ -222,7 +222,7 @@ void FsmGraph::leaveFsmAction( int ordering, Action *action )
}
/* Add functions to the longest match action table for constructing scanners. */
-void FsmGraph::longMatchAction( int ordering, TokenDef *lmPart )
+void FsmGraph::longMatchAction( int ordering, TokenInstance *lmPart )
{
/* Walk all final states. */
for ( StateSet::Iter state = finStateSet; state.lte(); state++ ) {
diff --git a/colm/fsmcodegen.cc b/colm/fsmcodegen.cc
index ce357e13..cb1e8a5f 100644
--- a/colm/fsmcodegen.cc
+++ b/colm/fsmcodegen.cc
@@ -182,7 +182,7 @@ void FsmCodeGen::LM_SWITCH( ostream &ret, InlineItem *item,
"goto st" << redFsm->errState->id << ";\n";
}
- for ( TokenDefListReg::Iter lmi = item->tokenRegion->tokenDefList; lmi.lte(); lmi++ ) {
+ for ( TokenInstanceListReg::Iter lmi = item->tokenRegion->tokenInstanceList; lmi.lte(); lmi++ ) {
if ( lmi->inLmSelect ) {
assert( lmi->tdLangEl != 0 );
ret << " case " << lmi->longestMatchId << ":\n";
diff --git a/colm/fsmcodegen.h b/colm/fsmcodegen.h
index 29fcb98d..bc75e854 100644
--- a/colm/fsmcodegen.h
+++ b/colm/fsmcodegen.h
@@ -42,7 +42,7 @@ struct GenAction;
struct NameInst;
struct RedAction;
struct LongestMatch;
-struct TokenDef;
+struct TokenInstance;
struct InlineList;
struct InlineItem;
struct NameInst;
diff --git a/colm/fsmexec.cc b/colm/fsmexec.cc
index 905f1d80..4381dda2 100644
--- a/colm/fsmexec.cc
+++ b/colm/fsmexec.cc
@@ -60,7 +60,7 @@ void execAction( FsmRun *fsmRun, GenAction *genAction )
fsmRun->cs = fsmRun->tables->errorState;
}
else {
- for ( TokenDefListReg::Iter lmi = item->tokenRegion->tokenDefList;
+ for ( TokenInstanceListReg::Iter lmi = item->tokenRegion->tokenInstanceList;
lmi.lte(); lmi++ )
{
if ( lmi->inLmSelect && fsmRun->act == lmi->longestMatchId )
diff --git a/colm/fsmgraph.h b/colm/fsmgraph.h
index 3cfe9eca..9a0f2aea 100644
--- a/colm/fsmgraph.h
+++ b/colm/fsmgraph.h
@@ -48,7 +48,7 @@ struct FsmTrans;
struct FsmState;
struct FsmGraph;
struct Action;
-struct TokenDef;
+struct TokenInstance;
struct NameInst;
/* State list element for unambiguous access to list element. */
@@ -92,13 +92,13 @@ typedef SBstSet< Action*, CmpOrd<Action*> > ActionSet;
typedef CmpSTable< Action*, CmpOrd<Action*> > CmpActionSet;
/* Transistion Action Element. */
-typedef SBstMapEl< int, TokenDef* > LmActionTableEl;
+typedef SBstMapEl< int, TokenInstance* > LmActionTableEl;
/* Transition Action Table. */
struct LmActionTable
- : public SBstMap< int, TokenDef*, CmpOrd<int> >
+ : public SBstMap< int, TokenInstance*, CmpOrd<int> >
{
- void setAction( int ordering, TokenDef *action );
+ void setAction( int ordering, TokenInstance *action );
void setActions( const LmActionTable &other );
};
@@ -440,7 +440,7 @@ typedef Vector<EptVectEl> EptVect;
typedef BstSet<int> EntryIdSet;
/* Set of longest match items that may be active in a given state. */
-typedef BstSet<TokenDef*> LmItemSet;
+typedef BstSet<TokenInstance*> LmItemSet;
/* Conditions. */
typedef BstSet< Action*, CmpOrd<Action*> > CondSet;
@@ -961,7 +961,7 @@ struct FsmGraph
void allTransAction( int ordering, Action *action );
void finishFsmAction( int ordering, Action *action );
void leaveFsmAction( int ordering, Action *action );
- void longMatchAction( int ordering, TokenDef *lmPart );
+ void longMatchAction( int ordering, TokenInstance *lmPart );
/* Set error actions to execute. */
void startErrorAction( int ordering, Action *action, int transferPoint );
diff --git a/colm/lmparse.kh b/colm/lmparse.kh
index b0722b13..824cfe43 100644
--- a/colm/lmparse.kh
+++ b/colm/lmparse.kh
@@ -112,7 +112,7 @@ struct ColmParser
/* Report an error encountered by the parser. */
ostream &parse_error( int tokId, Token &token );
- void tokenDef( const InputLoc &loc, String name, LexJoin *join,
+ void tokenInstance( const InputLoc &loc, String name, LexJoin *join,
CodeBlock *transBlock, bool ignore, bool noPreIgnore, bool noPostIgnore );
void literalDef( const InputLoc &loc, const String &data,
@@ -168,7 +168,7 @@ struct ColmParser
LangExpr *require( const InputLoc &loc, LangVarRef *varRef, PatternItemList *list );
void contextVarDef( const InputLoc &loc, ObjectField *objField );
void contextHead( const InputLoc &loc, const String &data );
- void tokenDefName( const String &name );
+ void tokenInstanceName( const String &name );
StmtList *appendStatement( StmtList *stmtList, LangStmt *stmt );
ParameterList *appendParam( ParameterList *paramList, ObjectField *objField );
ObjectField *addParam( const InputLoc &loc, TypeRef *typeRef, const String &name );
diff --git a/colm/lmparse.kl b/colm/lmparse.kl
index 02eeadca..7822f03d 100644
--- a/colm/lmparse.kl
+++ b/colm/lmparse.kl
@@ -183,7 +183,7 @@ LexJoin *ColmParser::literalJoin( const InputLoc &loc, const String &data )
return join;
}
-void ColmParser::tokenDef( const InputLoc &loc, String name, LexJoin *join,
+void ColmParser::tokenInstance( const InputLoc &loc, String name, LexJoin *join,
CodeBlock *transBlock, bool ignore, bool noPreIgnore, bool noPostIgnore )
{
/* Check the region if this is for an ignore. */
@@ -201,39 +201,39 @@ void ColmParser::tokenDef( const InputLoc &loc, String name, LexJoin *join,
Namespace *nspace = namespaceStack.top();
RegionSet *regionSet = regionStack.top();
- TokenDef *tokenDef = TokenDef::cons( name, String(), false, ignore, join,
+ TokenInstance *tokenInstance = TokenInstance::cons( name, String(), false, ignore, join,
transBlock, loc, pd->nextTokenId++, nspace, regionSet->tokenIgnore,
&reCaptureVect, curObjectDef,
contextStack.top() );
- regionSet->tokenIgnore->tokenDefList.append( tokenDef );
- nspace->tokenDefList.append( tokenDef );
+ regionSet->tokenIgnore->tokenInstanceList.append( tokenInstance );
+ nspace->tokenInstanceList.append( tokenInstance );
- tokenDef->noPreIgnore = noPreIgnore;
- tokenDef->noPostIgnore = noPostIgnore;
+ tokenInstance->noPreIgnore = noPreIgnore;
+ tokenInstance->noPostIgnore = noPostIgnore;
/* All again for the ignore. */
if ( ignore ) {
- TokenDef *tokenDefIgn = TokenDef::cons( name + "_ign", String(), false, ignore, join,
+ TokenInstance *tokenInstanceIgn = TokenInstance::cons( name + "_ign", String(), false, ignore, join,
0, loc, pd->nextTokenId++, nspace, regionSet->ignoreOnly,
&reCaptureVect, curObjectDef,
contextStack.top() );
- tokenDefIgn->dupOf = tokenDef;
+ tokenInstanceIgn->dupOf = tokenInstance;
- regionSet->ignoreOnly->tokenDefList.append( tokenDefIgn );
- nspace->tokenDefList.append( tokenDefIgn );
+ regionSet->ignoreOnly->tokenInstanceList.append( tokenInstanceIgn );
+ nspace->tokenInstanceList.append( tokenInstanceIgn );
}
else {
- TokenDef *tokenDefTok = TokenDef::cons( name + "_tok", String(), false, ignore, join,
+ TokenInstance *tokenInstanceTok = TokenInstance::cons( name + "_tok", String(), false, ignore, join,
0, loc, pd->nextTokenId++, nspace, regionSet->tokenOnly,
&reCaptureVect, curObjectDef,
contextStack.top() );
- tokenDefTok->dupOf = tokenDef;
+ tokenInstanceTok->dupOf = tokenInstance;
- regionSet->tokenOnly->tokenDefList.append( tokenDefTok );
- nspace->tokenDefList.append( tokenDefTok );
+ regionSet->tokenOnly->tokenInstanceList.append( tokenInstanceTok );
+ nspace->tokenInstanceList.append( tokenInstanceTok );
}
/* This is created and pushed in the name. */
@@ -273,31 +273,31 @@ void ColmParser::literalDef( const InputLoc &loc, const String &data,
LexJoin *join = literalJoin( loc, data );
- TokenDef *tokenDef = TokenDef::cons( name, data, true, false, join,
+ TokenInstance *tokenInstance = TokenInstance::cons( name, data, true, false, join,
0, loc, pd->nextTokenId++, nspace, regionSet->tokenIgnore, 0, 0, 0 );
bool isZero = strcmp( interp.data, "" ) == 0;
- tokenDef->isZero = isZero;
+ tokenInstance->isZero = isZero;
if ( !isZero )
- regionSet->tokenIgnore->tokenDefList.append( tokenDef );
+ regionSet->tokenIgnore->tokenInstanceList.append( tokenInstance );
- ldel = nspace->literalDict.insert( interp, tokenDef );
- nspace->tokenDefList.append( tokenDef );
+ ldel = nspace->literalDict.insert( interp, tokenInstance );
+ nspace->tokenInstanceList.append( tokenInstance );
if ( !isZero ) {
/* Make the duplicate for the token-only region. */
- tokenDef->noPreIgnore = noPreIgnore;
- tokenDef->noPostIgnore = noPostIgnore;
+ tokenInstance->noPreIgnore = noPreIgnore;
+ tokenInstance->noPostIgnore = noPostIgnore;
- TokenDef *tokenDefTok = TokenDef::cons( name + "_tok", data, true, false, join,
+ TokenInstance *tokenInstanceTok = TokenInstance::cons( name + "_tok", data, true, false, join,
0, loc, pd->nextTokenId++, nspace, regionSet->tokenOnly, 0, 0, 0 );
- tokenDefTok->dupOf = tokenDef;
+ tokenInstanceTok->dupOf = tokenInstance;
- regionSet->tokenOnly->tokenDefList.append( tokenDefTok );
+ regionSet->tokenOnly->tokenInstanceList.append( tokenInstanceTok );
- nspace->tokenDefList.append( tokenDefTok );
+ nspace->tokenInstanceList.append( tokenInstanceTok );
}
if ( !insideRegion )
@@ -881,7 +881,7 @@ void ColmParser::contextHead( const InputLoc &loc, const String &data )
data, pd->nextObjectId++ );
}
-void ColmParser::tokenDefName( const String &name )
+void ColmParser::tokenInstanceName( const String &name )
{
pd->insideRegion = regionStack.length() > 1;
curDefineId = name;
@@ -1802,7 +1802,7 @@ token_def:
enter_rl opt_no_ignore '/' opt_lex_join leave_rl '/' opt_no_ignore
opt_translate
final {
- tokenDef( $1->loc, $2->name, $7->join, $11->transBlock, $1->ignore,
+ tokenInstance( $1->loc, $2->name, $7->join, $11->transBlock, $1->ignore,
$5->noIgnore, $10->noIgnore );
};
@@ -1826,7 +1826,7 @@ nonterm class token_def_name
token_def_name:
opt_name
final {
- tokenDefName( $1->name );
+ tokenInstanceName( $1->name );
$$->name = $1->name;
};
@@ -3032,7 +3032,7 @@ void ColmParser::go()
/* The token region */
pushRegionSet( internal );
- tokenDefName( String( "hello" ) );
+ tokenInstanceName( String( "hello" ) );
curObjectDef = ObjectDef::cons( ObjectDef::UserType, curDefineId, pd->nextObjectId++ );
@@ -3045,7 +3045,7 @@ void ColmParser::go()
LexExpression *lexExpr = LexExpression::cons( term );
LexJoin *join = LexJoin::cons( lexExpr );
- tokenDef( internal, "hello", join, 0, false, false, false );
+ tokenInstance( internal, "hello", join, 0, false, false, false );
popRegionSet();
diff --git a/colm/parsedata.h b/colm/parsedata.h
index a2455434..58db0130 100644
--- a/colm/parsedata.h
+++ b/colm/parsedata.h
@@ -201,7 +201,7 @@ typedef Vector< PdaGraph* > Machines;
/* List of language elements. */
typedef DList<LangEl> LelList;
-typedef Vector< TokenDef* > TokenDefVect;
+typedef Vector< TokenInstance* > TokenInstanceVect;
struct UniqueType;
@@ -254,7 +254,7 @@ struct LangEl : public DListEl<LangEl>
/* Productions from the language element if it is a non-terminal. */
LelDefList defList;
- TokenDef *tokenDef;
+ TokenInstance *tokenInstance;
Production *rootDef;
LangEl *termDup;
LangEl *eofLel;
diff --git a/colm/parsetree.cc b/colm/parsetree.cc
index 358df0bd..c90a79c8 100644
--- a/colm/parsetree.cc
+++ b/colm/parsetree.cc
@@ -221,7 +221,7 @@ void RegionDef::makeNameTree( const InputLoc &loc, Compiler *pd )
tokenRegion->regionNameInst = nameInst;
}
-InputLoc TokenDef::getLoc()
+InputLoc TokenInstance::getLoc()
{
return action != 0 ? action->loc : semiLoc;
}
@@ -248,7 +248,7 @@ Action *TokenRegion::newAction( Compiler *pd, const InputLoc &loc,
void TokenRegion::makeActions( Compiler *pd )
{
/* Make actions that set the action id. */
- for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
+ for ( TokenInstanceListReg::Iter lmi = tokenInstanceList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
InlineList *inlineList = InlineList::cons();
@@ -260,7 +260,7 @@ void TokenRegion::makeActions( Compiler *pd )
}
/* Make actions that execute the user action and restart on the last character. */
- for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
+ for ( TokenInstanceListReg::Iter lmi = tokenInstanceList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
InlineList *inlineList = InlineList::cons();
@@ -274,7 +274,7 @@ void TokenRegion::makeActions( Compiler *pd )
/* Make actions that execute the user action and restart on the next
* character. These actions will set tokend themselves (it is the current
* char). */
- for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
+ for ( TokenInstanceListReg::Iter lmi = tokenInstanceList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
InlineList *inlineList = InlineList::cons();
@@ -287,7 +287,7 @@ void TokenRegion::makeActions( Compiler *pd )
/* Make actions that execute the user action and restart at tokend. These
* actions execute some time after matching the last char. */
- for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
+ for ( TokenInstanceListReg::Iter lmi = tokenInstanceList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
InlineList *inlineList = InlineList::cons();
@@ -500,8 +500,8 @@ FsmGraph *TokenRegion::walk( Compiler *pd )
{
/* Make each part of the longest match. */
int numParts = 0;
- FsmGraph **parts = new FsmGraph*[tokenDefList.length()];
- for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
+ FsmGraph **parts = new FsmGraph*[tokenInstanceList.length()];
+ for ( TokenInstanceListReg::Iter lmi = tokenInstanceList; lmi.lte(); lmi++ ) {
/* Watch out for patternless tokens. */
if ( lmi->join != 0 ) {
/* Create the machine and embed the setting of the longest match id. */
@@ -510,15 +510,15 @@ FsmGraph *TokenRegion::walk( Compiler *pd )
/* Look for tokens that accept the zero length-word. The first one found
* will be used as the default token. */
- if ( defaultTokenDef == 0 && parts[numParts]->startState->isFinState() )
- defaultTokenDef = lmi;
+ if ( defaultTokenInstance == 0 && parts[numParts]->startState->isFinState() )
+ defaultTokenInstance = lmi;
numParts += 1;
}
}
FsmGraph *retFsm = parts[0];
- if ( defaultTokenDef != 0 && defaultTokenDef->tdLangEl->isIgnore )
+ if ( defaultTokenInstance != 0 && defaultTokenInstance->tdLangEl->isIgnore )
error() << "ignore token cannot be a scanner's zero-length token" << endp;
/* The region is empty. Return the empty set. */
diff --git a/colm/parsetree.h b/colm/parsetree.h
index 27af0a54..174a0a30 100644
--- a/colm/parsetree.h
+++ b/colm/parsetree.h
@@ -170,9 +170,9 @@ struct RegionJoinOrLm;
struct TokenRegion;
struct Namespace;
struct Context;
-struct TokenDef;
-struct TokenDefListReg;
-struct TokenDefListNs;
+struct TokenInstance;
+struct TokenInstanceListReg;
+struct TokenInstanceListNs;
struct Range;
struct LangEl;
@@ -241,8 +241,8 @@ void prepareLitString( String &result, bool &caseInsensitive,
std::ostream &operator<<(std::ostream &out, const Token &token );
-typedef AvlMap< String, TokenDef*, CmpStr > LiteralDict;
-typedef AvlMapEl< String, TokenDef* > LiteralDictEl;
+typedef AvlMap< String, TokenInstance*, CmpStr > LiteralDict;
+typedef AvlMapEl< String, TokenInstance* > LiteralDictEl;
/* Store the value and type of a priority augmentation. */
struct PriorityAug
@@ -350,33 +350,33 @@ struct Context
typedef Vector<ReCapture> ReCaptureVect;
-struct TokenDefPtr1
+struct TokenInstancePtr1
{
- TokenDef *prev, *next;
+ TokenInstance *prev, *next;
};
-struct TokenDefPtr2
+struct TokenInstancePtr2
{
- TokenDef *prev, *next;
+ TokenInstance *prev, *next;
};
-struct TokenDef
+struct TokenInstance
:
- public TokenDefPtr1,
- public TokenDefPtr2
+ public TokenInstancePtr1,
+ public TokenInstancePtr2
{
- TokenDef()
+ TokenInstance()
:
action(0), tdLangEl(0), inLmSelect(false), dupOf(0),
noPostIgnore(false), noPreIgnore(false), isZero(false)
{}
- static TokenDef *cons( const String &name, const String &literal, bool isLiteral, bool isIgnore,
+ static TokenInstance *cons( const String &name, const String &literal, bool isLiteral, bool isIgnore,
LexJoin *join, CodeBlock *codeBlock, const InputLoc &semiLoc,
int longestMatchId, Namespace *nspace, TokenRegion *tokenRegion,
ReCaptureVect *pReCaptureVect, ObjectDef *objectDef, Context *contextIn )
{
- TokenDef *t = new TokenDef;
+ TokenInstance *t = new TokenInstance;
t->name = name;
t->literal = literal;
@@ -428,7 +428,7 @@ struct TokenDef
ObjectDef *objectDef;
Context *contextIn;
- TokenDef *dupOf;
+ TokenInstance *dupOf;
bool noPostIgnore;
bool noPreIgnore;
bool isZero;
@@ -482,8 +482,8 @@ struct NtDef
struct NtDefList : DList<NtDef> {};
/* Declare a new type so that ptreetypes.h need not include dlist.h. */
-struct TokenDefListReg : DListMel<TokenDef, TokenDefPtr1> {};
-struct TokenDefListNs : DListMel<TokenDef, TokenDefPtr2> {};
+struct TokenInstanceListReg : DListMel<TokenInstance, TokenInstancePtr1> {};
+struct TokenInstanceListNs : DListMel<TokenInstance, TokenInstancePtr2> {};
struct ContextDef
{
@@ -538,7 +538,7 @@ struct TokenRegion
id(id),
lmSwitchHandlesError(false),
regionNameInst(0),
- defaultTokenDef(0),
+ defaultTokenInstance(0),
preEofBlock(0),
ignoreOnlyRegion(0),
tokenOnlyRegion(0),
@@ -564,7 +564,7 @@ struct TokenRegion
void restart( FsmGraph *graph, FsmTrans *trans );
InputLoc loc;
- TokenDefListReg tokenDefList;
+ TokenInstanceListReg tokenInstanceList;
int id;
Action *lmActSelect;
@@ -574,7 +574,7 @@ struct TokenRegion
* regions are referenced once only. */
NameInst *regionNameInst;
- TokenDef *defaultTokenDef;
+ TokenInstance *defaultTokenInstance;
CodeBlock *preEofBlock;
@@ -726,7 +726,7 @@ struct Namespace
LiteralDict literalDict;
/* List of tokens defs in the namespace. */
- TokenDefListNs tokenDefList;
+ TokenInstanceListNs tokenInstanceList;
/* List of nonterminal defs in the namespace. */
NtDefList ntDefList;
@@ -1367,7 +1367,7 @@ struct InlineItem
}
static InlineItem *cons( const InputLoc &loc, TokenRegion *tokenRegion,
- TokenDef *longestMatchPart, Type type )
+ TokenInstance *longestMatchPart, Type type )
{
InlineItem *i = new InlineItem;
i->loc = loc;
@@ -1406,7 +1406,7 @@ struct InlineItem
NameInst *nameTarg;
InlineList *children;
TokenRegion *tokenRegion;
- TokenDef *longestMatchPart;
+ TokenInstance *longestMatchPart;
Type type;
InlineItem *prev, *next;
diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc
index e2985471..6a4fa598 100644
--- a/colm/pdabuild.cc
+++ b/colm/pdabuild.cc
@@ -75,7 +75,7 @@ LangEl::LangEl( Namespace *nspace, const String &name, Type type )
parseStop(false),
isEOF(false),
repeatOf(0),
- tokenDef(0),
+ tokenInstance(0),
rootDef(0),
termDup(0),
eofLel(0),
@@ -498,8 +498,8 @@ void Compiler::addRegion( PdaState *tabState, PdaTrans *tabTrans,
//cerr << "isCI" << endl;
region = langEl->ciRegion->ciRegion;
}
- else if ( !langEl->isEOF && langEl->tokenDef != 0 ) {
- region = langEl->tokenDef->tokenRegion;
+ else if ( !langEl->isEOF && langEl->tokenInstance != 0 ) {
+ region = langEl->tokenInstance->tokenRegion;
}
if ( region != 0 ) {
@@ -1365,7 +1365,7 @@ void Compiler::makeRuntimeData()
for ( RegionList::Iter reg = regionList; reg.lte(); reg++ ) {
long regId = reg->id+1;
runtimeData->regionInfo[regId].defaultToken =
- reg->defaultTokenDef == 0 ? -1 : reg->defaultTokenDef->tdLangEl->id;
+ reg->defaultTokenInstance == 0 ? -1 : reg->defaultTokenInstance->tdLangEl->id;
runtimeData->regionInfo[regId].eofFrameId = -1;
runtimeData->regionInfo[regId].isIgnoreOnly = reg->isIgnoreOnly;
runtimeData->regionInfo[regId].isCiOnly = reg->isCiOnly;
@@ -1438,9 +1438,9 @@ void Compiler::makeRuntimeData()
runtimeData->lelInfo[i].termDupId = lel->termDup == 0 ? 0 : lel->termDup->id;
runtimeData->lelInfo[i].genericId = lel->generic == 0 ? 0 : lel->generic->id;
- if ( lel->tokenDef != 0 && lel->tokenDef->join != 0 &&
- lel->tokenDef->join->context != 0 )
- runtimeData->lelInfo[i].markId = lel->tokenDef->join->mark->markId;
+ if ( lel->tokenInstance != 0 && lel->tokenInstance->join != 0 &&
+ lel->tokenInstance->join->context != 0 )
+ runtimeData->lelInfo[i].markId = lel->tokenInstance->join->mark->markId;
else
runtimeData->lelInfo[i].markId = -1;
@@ -1545,7 +1545,7 @@ void Compiler::makeRuntimeData()
/* Captured attributes. Loop over tokens and count first. */
long numCapturedAttr = 0;
// for ( RegionList::Iter reg = regionList; reg.lte(); reg++ ) {
-// for ( TokenDefListReg::Iter td = reg->tokenDefList; td.lte(); td++ )
+// for ( TokenInstanceListReg::Iter td = reg->tokenInstanceList; td.lte(); td++ )
// numCapturedAttr += td->reCaptureVect.length();
// }
runtimeData->captureAttr = new CaptureAttr[numCapturedAttr];
@@ -1554,7 +1554,7 @@ void Compiler::makeRuntimeData()
count = 0;
// for ( RegionList::Iter reg = regionList; reg.lte(); reg++ ) {
-// for ( TokenDefListReg::Iter td = reg->tokenDefList; td.lte(); td++ ) {
+// for ( TokenInstanceListReg::Iter td = reg->tokenInstanceList; td.lte(); td++ ) {
// runtimeData->lelInfo[td->token->id].captureAttr = count;
// runtimeData->lelInfo[td->token->id].numCaptureAttr = td->reCaptureVect.length();
// for ( ReCaptureVect::Iter c = td->reCaptureVect; c.lte(); c++ ) {
diff --git a/colm/pdagraph.h b/colm/pdagraph.h
index 742fb047..af6eb3d5 100644
--- a/colm/pdagraph.h
+++ b/colm/pdagraph.h
@@ -47,7 +47,7 @@
struct PdaTrans;
struct PdaState;
struct PdaGraph;
-struct TokenDef;
+struct TokenInstance;
struct Production;
struct LangEl;
struct TokenRegion;
diff --git a/colm/resolve.cc b/colm/resolve.cc
index c37c0822..541a44bf 100644
--- a/colm/resolve.cc
+++ b/colm/resolve.cc
@@ -746,7 +746,7 @@ void Compiler::makeEofElements()
lel != eofLangEl &&
lel != errorLangEl &&
lel != noTokenLangEl &&
- !( lel->tokenDef != 0 && lel->tokenDef->dupOf != 0 ) )
+ !( lel->tokenInstance != 0 && lel->tokenInstance->dupOf != 0 ) )
{
String name( lel->name.length() + 5, "_eof_%s", lel->name.data );
LangEl *eofLel = new LangEl( lel->nspace, name, LangEl::Term );
diff --git a/colm/synthesis.cc b/colm/synthesis.cc
index 4707e52e..5ab22b3a 100644
--- a/colm/synthesis.cc
+++ b/colm/synthesis.cc
@@ -2714,12 +2714,12 @@ void Compiler::compileTranslateBlock( LangEl *langEl )
code.append( IN_INIT_LOCALS );
code.appendHalf( 0 );
- if ( langEl->tokenDef->reCaptureVect.length() > 0 ) {
+ if ( langEl->tokenInstance->reCaptureVect.length() > 0 ) {
code.append( IN_INIT_CAPTURES );
- code.append( langEl->tokenDef->reCaptureVect.length() );
+ code.append( langEl->tokenInstance->reCaptureVect.length() );
ObjFieldList::Iter f = *curLocalFrame->objFieldList;
- for ( int i = 0; i < langEl->tokenDef->reCaptureVect.length(); i++, f++ )
+ for ( int i = 0; i < langEl->tokenInstance->reCaptureVect.length(); i++, f++ )
curLocalFrame->referenceField( this, f->value );
}