diff options
author | Adrian Thurston <thurston@complang.org> | 2015-10-04 23:16:46 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-10-04 23:16:46 -0400 |
commit | 13d7c884e2a855418d68b8e45041b8ab4a20a85c (patch) | |
tree | eccbfb13e83812b01858317938f972913c7b7bf1 /src/resolve.cc | |
parent | 6fb0cdffbafb135edaec7d927e5e508997c1d826 (diff) | |
download | colm-13d7c884e2a855418d68b8e45041b8ab4a20a85c.tar.gz |
load reduction actions and generate a commit containing them
Diffstat (limited to 'src/resolve.cc')
-rw-r--r-- | src/resolve.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/resolve.cc b/src/resolve.cc index 95221bcb..38c7b169 100644 --- a/src/resolve.cc +++ b/src/resolve.cc @@ -882,7 +882,39 @@ void Compiler::resolvePrecedence() } } +void Compiler::resolveReductionActions() +{ + for ( ReductionVect::Iter r = rootNamespace->reductions; r.lte(); r++ ) { + for ( ReduceActionList::Iter rai = (*r)->reduceActions; rai.lte(); rai++ ) { + rai->nonterm->resolveType( this ); + } + } +} +void Compiler::findReductionActionProds() +{ + for ( ReductionVect::Iter r = rootNamespace->reductions; r.lte(); r++ ) { + for ( ReduceActionList::Iter rai = (*r)->reduceActions; rai.lte(); rai++ ) { + rai->nonterm->resolveType( this ); + LangEl *langEl = rai->nonterm->uniqueType->langEl; + + Production *prod = 0; + for ( LelDefList::Iter ldi = langEl->defList; ldi.lte(); ldi++ ) { + if ( strcmp( ldi->name, rai->prod ) == 0 ) { + prod = ldi; + break; + } + } + + if ( prod == 0 ) { + error(rai->loc) << "could not find production \"" << + rai->prod << "\"" << endp; + } + + rai->production = prod; + } + } +} void Compiler::resolvePass() { /* @@ -896,9 +928,13 @@ void Compiler::resolvePass() UniqueType *argvUT = argvTypeRef->resolveType( this ); argvElSel = argvUT->generic->elUt->structEl; + resolveReductionActions(); + /* We must do this as the last step in the type resolution process because * all type resolves can cause new language elments with associated * productions. They get tacked onto the end of the list of productions. * Doing it at the end results processing a growing list. */ resolveProductionEls(); + + findReductionActionProds(); } |