summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-01-03 21:03:31 -0500
committerAdrian Thurston <thurston@complang.org>2014-01-03 21:03:31 -0500
commit0681e8d12912b147a98f9328db6e1e55762f690c (patch)
tree9eed8f7df83f67f74ff431a4d432e8137ea0b369
parenteaa8e91ffcf86479ed332281948c9799976fbb9a (diff)
downloadcolm-0681e8d12912b147a98f9328db6e1e55762f690c.tar.gz
use found UniqueType when consing type refs for repeat prods
-rw-r--r--src/compiler.cc14
-rw-r--r--src/parsedata.h12
-rw-r--r--src/resolve.cc6
3 files changed, 16 insertions, 16 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index e2c0282a..63656e59 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -748,7 +748,7 @@ FsmGraph *Compiler::makeScanner()
}
LangEl *Compiler::makeRepeatProd( const InputLoc &loc, Namespace *nspace,
- const String &repeatName, NamespaceQual *nspaceQual, const String &name )
+ const String &repeatName, UniqueType *ut )
{
LangEl *prodName = addLangEl( this, nspace, repeatName, LangEl::NonTerm );
prodName->isRepeat = true;
@@ -756,7 +756,7 @@ LangEl *Compiler::makeRepeatProd( const InputLoc &loc, Namespace *nspace,
ProdElList *prodElList1 = new ProdElList;
/* Build the first production of the repeat. */
- TypeRef *typeRef1 = TypeRef::cons( loc, nspaceQual, name );
+ TypeRef *typeRef1 = TypeRef::cons( loc, ut );
ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef1, 0 );
UniqueType *prodNameUT = findUniqueType( TYPE_TREE, prodName );
@@ -787,13 +787,13 @@ LangEl *Compiler::makeRepeatProd( const InputLoc &loc, Namespace *nspace,
}
LangEl *Compiler::makeListProd( const InputLoc &loc, Namespace *nspace,
- const String &listName, NamespaceQual *nspaceQual, const String &name )
+ const String &listName, UniqueType *ut )
{
LangEl *prodName = addLangEl( this, nspace, listName, LangEl::NonTerm );
prodName->isList = true;
/* Build the first production of the list. */
- TypeRef *typeRef1 = TypeRef::cons( loc, nspaceQual, name );
+ TypeRef *typeRef1 = TypeRef::cons( loc, ut );
ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef1, 0 );
UniqueType *prodNameUT = findUniqueType( TYPE_TREE, prodName );
@@ -812,7 +812,7 @@ LangEl *Compiler::makeListProd( const InputLoc &loc, Namespace *nspace,
prodList.append( newDef1 );
/* Build the second production of the list. */
- TypeRef *typeRef3 = TypeRef::cons( loc, nspaceQual, name );
+ TypeRef *typeRef3 = TypeRef::cons( loc, ut );
ProdEl *factor3 = new ProdEl( ProdEl::ReferenceType, loc, 0, false, typeRef3, 0 );
ProdElList *prodElList2 = new ProdElList;
@@ -829,7 +829,7 @@ LangEl *Compiler::makeListProd( const InputLoc &loc, Namespace *nspace,
}
LangEl *Compiler::makeOptProd( const InputLoc &loc, Namespace *nspace,
- const String &optName, NamespaceQual *nspaceQual, const String &name )
+ const String &optName, UniqueType *ut )
{
LangEl *prodName = addLangEl( this, nspace, optName, LangEl::NonTerm );
prodName->isOpt = true;
@@ -837,7 +837,7 @@ LangEl *Compiler::makeOptProd( const InputLoc &loc, Namespace *nspace,
ProdElList *prodElList1 = new ProdElList;
/* Build the first production of the repeat. */
- TypeRef *typeRef1 = TypeRef::cons( loc, nspaceQual, name );
+ TypeRef *typeRef1 = TypeRef::cons( loc, ut );
ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, loc, 0, false, typeRef1, 0 );
prodElList1->append( factor1 );
diff --git a/src/parsedata.h b/src/parsedata.h
index f37ed8d7..51a7e76c 100644
--- a/src/parsedata.h
+++ b/src/parsedata.h
@@ -706,12 +706,12 @@ struct Compiler
void printNonTermFirstSets();
void printFirstSets();
- LangEl *makeRepeatProd( const InputLoc &loc, Namespace *nspace, const String &repeatName,
- NamespaceQual *nspaceQual, const String &name );
- LangEl *makeListProd( const InputLoc &loc, Namespace *nspace, const String &listName,
- NamespaceQual *nspaceQual, const String &name );
- LangEl *makeOptProd( const InputLoc &loc, Namespace *nspace, const String &optName,
- NamespaceQual *nspaceQual, const String &name );
+ LangEl *makeRepeatProd( const InputLoc &loc, Namespace *nspace,
+ const String &repeatName, UniqueType *ut );
+ LangEl *makeListProd( const InputLoc &loc, Namespace *nspace,
+ const String &listName, UniqueType *ut );
+ LangEl *makeOptProd( const InputLoc &loc, Namespace *nspace,
+ const String &optName, UniqueType *ut );
void resolveProdEl( ProdEl *prodEl );
void resolveProductionEls();
diff --git a/src/resolve.cc b/src/resolve.cc
index c52d03e8..774a8394 100644
--- a/src/resolve.cc
+++ b/src/resolve.cc
@@ -258,21 +258,21 @@ void TypeRef::resolveRepeat( Compiler *pd )
/* If the factor is a repeat, create the repeat element and link the
* factor to it. */
String repeatName( 128, "_repeat_%s", typeName.data );
- declLangEl = pd->makeRepeatProd( loc, nspace, repeatName, nspaceQual, typeName );
+ declLangEl = pd->makeRepeatProd( loc, nspace, repeatName, uniqueType );
break;
}
case RepeatList: {
/* If the factor is a repeat, create the repeat element and link the
* factor to it. */
String listName( 128, "_list_%s", typeName.data );
- declLangEl = pd->makeListProd( loc, nspace, listName, nspaceQual, typeName );
+ declLangEl = pd->makeListProd( loc, nspace, listName, uniqueType );
break;
}
case RepeatOpt: {
/* If the factor is an opt, create the opt element and link the factor
* to it. */
String optName( 128, "_opt_%s", typeName.data );
- declLangEl = pd->makeOptProd( loc, nspace, optName, nspaceQual, typeName );
+ declLangEl = pd->makeOptProd( loc, nspace, optName, uniqueType );
break;
}