summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler.cc17
-rw-r--r--src/parser.cc13
-rw-r--r--src/parsetree.h8
-rw-r--r--src/pdabuild.cc32
-rw-r--r--src/synthesis.cc11
5 files changed, 31 insertions, 50 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index aff10b6a..0bc57caf 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1042,16 +1042,13 @@ void Compiler::collectParserEls( BstSet<LangEl*> &parserEls )
}
for ( ConsList::Iter repl = replList; repl.lte(); repl++ ) {
- /* FIXME: should be able to remove this test. */
- if ( repl->langEl != 0 ) {
- /* We need the the language element from the compilation process. */
- assert( repl->langEl != 0 );
-
- if ( repl->langEl->parserId < 0 ) {
- /* Make a parser for the language element. */
- parserEls.insert( repl->langEl );
- repl->langEl->parserId = nextParserId++;
- }
+ /* We need the the language element from the compilation process. */
+ assert( repl->langEl != 0 );
+
+ if ( repl->langEl->parserId < 0 ) {
+ /* Make a parser for the language element. */
+ parserEls.insert( repl->langEl );
+ repl->langEl->parserId = nextParserId++;
}
}
diff --git a/src/parser.cc b/src/parser.cc
index 8606254a..95ddbc40 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -553,13 +553,8 @@ LangExpr *BaseParser::parseCmd( const InputLoc &loc, bool tree, bool stop,
{
LangExpr *expr = 0;
- /* We are constructing a parser, sending it items, then returning it.
- * Thisis the constructor for the parser. */
- ConsItemList *emptyConsItemList = new ConsItemList;
-
- Constructor *constructor = Constructor::cons( loc, curNspace(),
- emptyConsItemList, pd->nextPatConsId++ );
- pd->replList.append( constructor );
+ /* Item list for what we are sending to the parser. */
+ ConsItemList *consItemList = new ConsItemList;
/* The parser may be referenced. */
LangVarRef *varRef = 0;
@@ -579,7 +574,7 @@ LangExpr *BaseParser::parseCmd( const InputLoc &loc, bool tree, bool stop,
LangTerm::ParseTreeType : LangTerm::ParseType );
expr = LangExpr::cons( LangTerm::cons( loc, langTermType,
- varRef, objField, parserTypeRef, fieldInitVect, constructor,
+ varRef, objField, parserTypeRef, fieldInitVect, consItemList,
parserText ) );
/* Check for redeclaration. */
@@ -896,7 +891,7 @@ void BaseParser::structHead( const InputLoc &loc,
inNspace->structDefList.append( context );
/* Make the namespace for the struct. */
- Namespace *structNspace = createNamespace( loc, data );
+ createNamespace( loc, data );
}
StmtList *BaseParser::appendStatement( StmtList *stmtList, LangStmt *stmt )
diff --git a/src/parsetree.h b/src/parsetree.h
index 9a3c7f2e..f81fcc6b 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -2776,6 +2776,8 @@ struct LangTerm
LangTerm()
:
generic(0),
+ constructor(0),
+ consItemList(0),
parserText(0)
{}
@@ -2888,7 +2890,7 @@ struct LangTerm
static LangTerm *cons( const InputLoc &loc, Type type, LangVarRef *varRef,
ObjectField *objField, TypeRef *typeRef, FieldInitVect *fieldInitArgs,
- Constructor *constructor, ParserText *parserText )
+ ConsItemList *consItemList, ParserText *parserText )
{
LangTerm *t = new LangTerm;
t->loc = loc;
@@ -2897,7 +2899,7 @@ struct LangTerm
t->objField = objField;
t->typeRef = typeRef;
t->fieldInitArgs = fieldInitArgs;
- t->constructor = constructor;
+ t->consItemList = consItemList;
t->parserText = parserText;
return t;
}
@@ -2987,9 +2989,9 @@ struct LangTerm
FieldInitVect *fieldInitArgs;
GenericType *generic;
Constructor *constructor;
+ ConsItemList *consItemList;
ParserText *parserText;
LangExpr *expr;
- ConsItemList *consItemList;
bool eof;
};
diff --git a/src/pdabuild.cc b/src/pdabuild.cc
index c8db886b..29f71be9 100644
--- a/src/pdabuild.cc
+++ b/src/pdabuild.cc
@@ -1810,11 +1810,9 @@ void Compiler::fillInPatterns( Program *prg )
}
for ( ConsList::Iter repl = replList; repl.lte(); repl++ ) {
- if ( repl->langEl != 0 ) {
- countNodes( prg, count,
- repl->pdaRun->stackTop->next,
- repl->pdaRun->stackTop->next->shadow );
- }
+ countNodes( prg, count,
+ repl->pdaRun->stackTop->next,
+ repl->pdaRun->stackTop->next->shadow );
}
runtimeData->patReplNodes = new PatConsNode[count];
@@ -1840,21 +1838,19 @@ void Compiler::fillInPatterns( Program *prg )
}
for ( ConsList::Iter repl = replList; repl.lte(); repl++ ) {
- if ( repl->langEl != 0 ) {
- int ind = nextAvail++;
- runtimeData->patReplInfo[repl->patRepId].offset = ind;
+ int ind = nextAvail++;
+ runtimeData->patReplInfo[repl->patRepId].offset = ind;
- /* BindIds are indexed base one. */
- runtimeData->patReplInfo[repl->patRepId].numBindings =
- repl->pdaRun->bindings->length() - 1;
+ /* BindIds are indexed base one. */
+ runtimeData->patReplInfo[repl->patRepId].numBindings =
+ repl->pdaRun->bindings->length() - 1;
- long bindId = 1;
- fillNodes( prg, nextAvail, repl->pdaRun->bindings, bindId,
- runtimeData->patReplNodes,
- repl->pdaRun->stackTop->next,
- repl->pdaRun->stackTop->next->shadow,
- ind );
- }
+ long bindId = 1;
+ fillNodes( prg, nextAvail, repl->pdaRun->bindings, bindId,
+ runtimeData->patReplNodes,
+ repl->pdaRun->stackTop->next,
+ repl->pdaRun->stackTop->next->shadow,
+ ind );
}
assert( nextAvail == count );
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 1e5b328c..c3098cc6 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -1257,14 +1257,8 @@ UniqueType *LangTerm::evaluateParse( Compiler *pd, CodeVect &code,
context = true;
}
- /* Assign bind ids to the variables in the replacement. */
- for ( ConsItemList::Iter item = *constructor->list; item.lte(); item++ ) {
- if ( item->expr != 0 )
- item->bindId = constructor->nextBindId++;
- }
-
/* Evaluate variable references. */
- for ( ConsItemList::Iter item = constructor->list->last(); item.gtb(); item-- ) {
+ for ( ConsItemList::Iter item = consItemList->last(); item.gtb(); item-- ) {
if ( item->type == ConsItem::ExprType ) {
UniqueType *ut = item->expr->evaluate( pd, code );
@@ -1300,9 +1294,6 @@ UniqueType *LangTerm::evaluateParse( Compiler *pd, CodeVect &code,
code.append( IN_SET_PARSER_CTX_WC );
}
- /* For access to the replacement pattern. */
- constructor->langEl = parserUT->langEl;
-
/*****************************/
code.append( IN_DUP_TOP );