diff options
author | Adrian Thurston <thurston@complang.org> | 2013-04-07 12:19:41 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2013-04-07 12:19:41 -0400 |
commit | 2e827cbafe81c13ece6ad2e3309c1401932b75dc (patch) | |
tree | c26bbab90cbfbc4153dbcbaca8c63dde3b43ce48 | |
parent | 8ec3a5a4c25c6be546d6c4b951e2c0678a5cdc2c (diff) | |
download | colm-2e827cbafe81c13ece6ad2e3309c1401932b75dc.tar.gz |
eliminated the default region and namespace
-rw-r--r-- | colm/compiler.cc | 42 | ||||
-rw-r--r-- | colm/declare.cc | 4 | ||||
-rw-r--r-- | colm/exports.cc | 4 | ||||
-rw-r--r-- | colm/parsedata.h | 4 | ||||
-rw-r--r-- | colm/pdabuild.cc | 2 |
5 files changed, 4 insertions, 52 deletions
diff --git a/colm/compiler.cc b/colm/compiler.cc index 8a89f211..72cdd9a8 100644 --- a/colm/compiler.cc +++ b/colm/compiler.cc @@ -373,11 +373,9 @@ Compiler::Compiler( ) noTokenLangEl(0), eofLangEl(0), errorLangEl(0), - defaultCharLangEl(0), ignoreLangEl(0), rootRegion(0), - defaultRegion(0), firstNonTermId(0), prodIdIndex(0), @@ -744,46 +742,6 @@ FsmGraph *Compiler::makeScanner() return fsmGraph; } -void Compiler::createDefaultScanner() -{ - InputLoc loc; - - const char *name = "___DEFAULT_SCANNER"; - - /* Create the default namespace. */ - defaultNamespace = new Namespace( InputLoc(), name, - namespaceList.length(), 0 ); - namespaceList.append( defaultNamespace ); - - /* Create a scanner which will be used when no other scanner can be - * figured out. It returns single characters. */ - RegionImpl *impl = new RegionImpl; - regionImplList.append( impl ); - defaultRegion = new TokenRegion( internal, regionList.length(), impl ); - regionList.append( defaultRegion ); - - RegionSet *regionSet = new RegionSet( impl, 0, 0, defaultRegion, 0, 0, 0 ); - regionSetList.append( regionSet ); - - LexJoin *join = LexJoin::cons( LexExpression::cons( BT_Any ) ); - - TokenDef *tokenDef = TokenDef::cons( name, String(), false, false, - join, 0, loc, 0, rootNamespace, regionSet, 0, 0 ); - - TokenInstance *tokenInstance = TokenInstance::cons( tokenDef, - join, loc, nextTokenId++, - rootNamespace, defaultRegion ); - - defaultRegion->impl->tokenInstanceList.append( tokenInstance ); - - /* Now create the one and only token -> "<chr>" / any / */ - name = "___DEFAULT_SCANNER_CHR"; - defaultCharLangEl = addLangEl( this, defaultNamespace, name, LangEl::Term ); - - tokenInstance->tokenDef->tdLangEl = defaultCharLangEl; - defaultCharLangEl->tokenDef = tokenDef; -} - LangEl *Compiler::makeRepeatProd( const InputLoc &loc, Namespace *nspace, const String &repeatName, NamespaceQual *nspaceQual, const String &name ) { diff --git a/colm/declare.cc b/colm/declare.cc index faa4f7dc..76a4bd5e 100644 --- a/colm/declare.cc +++ b/colm/declare.cc @@ -424,7 +424,7 @@ void Compiler::setPrecedence() void Compiler::makeIgnoreCollectors() { for ( RegionSetList::Iter regionSet = regionSetList; regionSet.lte(); regionSet++ ) { - if ( regionSet->tokenIgnore != rootRegion && regionSet->tokenIgnore != defaultRegion ) { + if ( regionSet->tokenIgnore != rootRegion ) { String name( 128, "_ign_%p", regionSet->tokenIgnore ); LangEl *zeroLel = new LangEl( rootNamespace, name, LangEl::Term ); langEls.append( zeroLel ); @@ -450,7 +450,5 @@ void Compiler::typeDeclaration() /* Create the default scanner which will return single characters for us * when we have no other scanner */ - createDefaultScanner(); - setPrecedence(); } diff --git a/colm/exports.cc b/colm/exports.cc index b15af16b..d7d8640c 100644 --- a/colm/exports.cc +++ b/colm/exports.cc @@ -35,7 +35,7 @@ using std::endl; void Compiler::openNameSpace( ostream &out, Namespace *nspace ) { - if ( nspace == defaultNamespace || nspace == rootNamespace ) + if ( nspace == rootNamespace ) return; openNameSpace( out, nspace->parentNamespace ); @@ -44,7 +44,7 @@ void Compiler::openNameSpace( ostream &out, Namespace *nspace ) void Compiler::closeNameSpace( ostream &out, Namespace *nspace ) { - if ( nspace == defaultNamespace || nspace == rootNamespace ) + if ( nspace == rootNamespace ) return; openNameSpace( out, nspace->parentNamespace ); diff --git a/colm/parsedata.h b/colm/parsedata.h index b6907134..cbd6c93c 100644 --- a/colm/parsedata.h +++ b/colm/parsedata.h @@ -803,7 +803,6 @@ struct Compiler void compileByteCode(); void resolveUses(); - void createDefaultScanner(); void generateOutput( long activeRealm ); void compile(); @@ -858,14 +857,11 @@ struct Compiler LangEl *noTokenLangEl; LangEl *eofLangEl; LangEl *errorLangEl; - LangEl *defaultCharLangEl; LangEl *ignoreLangEl; TokenRegion *rootRegion; - TokenRegion *defaultRegion; TokenRegion *eofTokenRegion; - Namespace *defaultNamespace; Namespace *rootNamespace; int nextSymbolId; diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc index 703c9c5f..57f54d20 100644 --- a/colm/pdabuild.cc +++ b/colm/pdabuild.cc @@ -218,7 +218,7 @@ void Compiler::makeLangElIds() void Compiler::refNameSpace( LangEl *lel, Namespace *nspace ) { - if ( nspace == defaultNamespace || nspace == rootNamespace ) { + if ( nspace == rootNamespace ) { lel->refName = "::" + lel->refName; return; } |