summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/colm.lm4
-rw-r--r--src/loadcolm.cc17
-rw-r--r--src/parsetree.h18
3 files changed, 34 insertions, 5 deletions
diff --git a/src/colm.lm b/src/colm.lm
index 5420014e..c7c72c2a 100644
--- a/src/colm.lm
+++ b/src/colm.lm
@@ -364,10 +364,10 @@ lex
end
def red_nonterm
- [id ROPEN host_item* RCLOSE]
+ [type_ref ROPEN HostItems: host_item* RCLOSE]
def red_action
- [NonTerm: type_ref COLON Prod: id ROPEN HostItems: host_item* RCLOSE]
+ [type_ref COLON id ROPEN HostItems: host_item* RCLOSE]
def host_item
[red_id]
diff --git a/src/loadcolm.cc b/src/loadcolm.cc
index dedb4353..374793cc 100644
--- a/src/loadcolm.cc
+++ b/src/loadcolm.cc
@@ -2346,14 +2346,24 @@ struct LoadColm
namespaceStack.pop();
}
+ void walkRedNonTerm( red_nonterm RN )
+ {
+ InputLoc loc = RN.ROPEN().loc();
+ String text = RN.HostItems().text().c_str();
+ TypeRef *typeRef = walkTypeRef( RN.type_ref() );
+
+ ReduceNonTerm *rnt = new ReduceNonTerm( loc, typeRef, text );
+ curReduction()->reduceNonTerms.append( rnt );
+ }
+
void walkRedAction( red_action RA )
{
- InputLoc loc = RA.NonTerm().loc();
+ InputLoc loc = RA.id().loc();
String text = RA.HostItems().text().c_str();
- TypeRef *typeRef = walkTypeRef( RA.NonTerm() );
+ TypeRef *typeRef = walkTypeRef( RA.type_ref() );
- ReduceAction *ra = new ReduceAction( loc, typeRef, RA.Prod().data(), text );
+ ReduceAction *ra = new ReduceAction( loc, typeRef, RA.id().data(), text );
curReduction()->reduceActions.append( ra );
}
@@ -2361,6 +2371,7 @@ struct LoadColm
{
switch ( reductionItem.prodName() ) {
case reduction_item::NonTerm: {
+ walkRedNonTerm( reductionItem.red_nonterm() );
break;
}
case reduction_item::Action: {
diff --git a/src/parsetree.h b/src/parsetree.h
index 7fc37231..b4cbcf1f 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -917,6 +917,22 @@ struct Namespace
typedef DList<Namespace> NamespaceList;
typedef BstSet< Namespace*, CmpOrd<Namespace*> > NamespaceSet;
+struct ReduceNonTerm
+{
+ ReduceNonTerm( const InputLoc &loc, TypeRef *nonterm, const String &txt )
+ :
+ loc(loc),
+ nonterm(nonterm),
+ txt(txt)
+ {}
+
+ InputLoc loc;
+ TypeRef *nonterm;
+ String txt;
+
+ ReduceNonTerm *prev, *next;
+};
+
struct ReduceAction
{
ReduceAction( const InputLoc &loc, TypeRef *nonterm,
@@ -937,6 +953,7 @@ struct ReduceAction
};
typedef DList<ReduceAction> ReduceActionList;
+typedef DList<ReduceNonTerm> ReduceNonTermList;
struct Reduction
{
@@ -948,6 +965,7 @@ struct Reduction
int id;
ReduceActionList reduceActions;
+ ReduceNonTermList reduceNonTerms;
};
/*