summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colm/bytecode.h1
-rw-r--r--colm/codegen.cc4
-rw-r--r--colm/parsedata.h2
-rw-r--r--colm/pdabuild.cc1
-rw-r--r--colm/resolve.cc1
-rw-r--r--colm/tree.c12
6 files changed, 21 insertions, 0 deletions
diff --git a/colm/bytecode.h b/colm/bytecode.h
index 53f23e16..9424697b 100644
--- a/colm/bytecode.h
+++ b/colm/bytecode.h
@@ -466,6 +466,7 @@ Tree *getAttr( Tree *tree, long pos );
Kid *getAttrKid( Tree *tree, long pos );
Tree *getRepeatNext( Tree *tree );
int repeatEnd( Tree *tree );
+Tree *getRepeatVal( Tree *tree );
Tree *splitTree( Program *prg, Tree *t );
void rcodeDownrefAll( Program *prg, Tree **sp, RtCodeVect *cv );
diff --git a/colm/codegen.cc b/colm/codegen.cc
index dc5fc029..d7abf435 100644
--- a/colm/codegen.cc
+++ b/colm/codegen.cc
@@ -73,6 +73,10 @@ void ParseData::generateExports()
out << " " <<
"int end() { return repeatEnd( (Tree*)this ); }\n";
+
+ out << " " << lel->repeatOf->fullName << " *value"
+ "() { return (" << lel->repeatOf->fullName <<
+ "*)getRepeatVal( (Tree*)this ); }\n";
}
out << "};\n";
}
diff --git a/colm/parsedata.h b/colm/parsedata.h
index 9fe67251..4583ac53 100644
--- a/colm/parsedata.h
+++ b/colm/parsedata.h
@@ -224,6 +224,8 @@ struct LangEl : public DListEl<LangEl>
bool parseStop;
bool isEOF;
+ LangEl *repeatOf;
+
/* Productions from the language element if it is a non-terminal. */
LelDefList defList;
diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc
index 4f88ceb0..39a7d71b 100644
--- a/colm/pdabuild.cc
+++ b/colm/pdabuild.cc
@@ -75,6 +75,7 @@ LangEl::LangEl( Namespace *nspace, const String &name, Type type )
isOpt(false),
parseStop(false),
isEOF(false),
+ repeatOf(0),
tokenDef(0),
rootDef(0),
termDup(0),
diff --git a/colm/resolve.cc b/colm/resolve.cc
index aae2a8ec..8e8ab630 100644
--- a/colm/resolve.cc
+++ b/colm/resolve.cc
@@ -265,6 +265,7 @@ void TypeRef::resolveRepeat( ParseData *pd )
}
uniqueRepeat->declLangEl = declLangEl;
+ declLangEl->repeatOf = uniqueRepeat->langEl;
}
uniqueType = pd->findUniqueType( TYPE_TREE, uniqueRepeat->declLangEl );
diff --git a/colm/tree.c b/colm/tree.c
index d2107108..5e51748e 100644
--- a/colm/tree.c
+++ b/colm/tree.c
@@ -111,6 +111,18 @@ Tree *getRepeatNext( Tree *tree )
return kid->next->tree;
}
+Tree *getRepeatVal( Tree *tree )
+{
+ Kid *kid = tree->child;
+
+ if ( tree->flags & AF_LEFT_IGNORE )
+ kid = kid->next;
+ if ( tree->flags & AF_RIGHT_IGNORE )
+ kid = kid->next;
+
+ return kid->tree;
+}
+
int repeatEnd( Tree *tree )
{
Kid *kid = tree->child;