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/loadcolm.cc | |
parent | 6fb0cdffbafb135edaec7d927e5e508997c1d826 (diff) | |
download | colm-13d7c884e2a855418d68b8e45041b8ab4a20a85c.tar.gz |
load reduction actions and generate a commit containing them
Diffstat (limited to 'src/loadcolm.cc')
-rw-r--r-- | src/loadcolm.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/loadcolm.cc b/src/loadcolm.cc index 5c8212c8..c0e06468 100644 --- a/src/loadcolm.cc +++ b/src/loadcolm.cc @@ -2335,6 +2335,38 @@ struct LoadColm namespaceStack.pop(); } + void walkRedAction( red_action RA ) + { + InputLoc loc = RA.NonTerm().loc(); + String text = RA.HostItems().text().c_str(); + + TypeRef *typeRef = walkTypeRef( RA.NonTerm() ); + + ReduceAction *ra = new ReduceAction( loc, typeRef, RA.Prod().data(), text ); + curReduction()->reduceActions.append( ra ); + } + + void walkReductionItem( reduction_item reductionItem ) + { + switch ( reductionItem.prodName() ) { + case reduction_item::NonTerm: { + break; + } + case reduction_item::Action: { + walkRedAction( reductionItem.red_action() ); + break; + } + } + } + + void walkReductionList( _repeat_reduction_item itemList ) + { + while ( !itemList.end() ) { + walkReductionItem( itemList.value() ); + itemList = itemList.next(); + } + } + void walkRootItem( root_item rootItem, StmtList *stmtList ) { switch ( rootItem.prodName() ) { @@ -2406,6 +2438,19 @@ struct LoadColm if ( stmt != 0 ) stmtList->append( stmt ); break; + } + case root_item::Reduction: { + reduction_def RD = rootItem.reduction_def(); + + InputLoc loc = RD.REDUCTION().loc(); + String id = RD.id().data(); + + createReduction( loc, id ); + + walkReductionList( RD.ItemList() ); + + reductionStack.pop(); + break; }} } |