summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colm/Makefile.am3
-rw-r--r--colm/colm.lm6
-rw-r--r--colm/colmex.h77
-rw-r--r--colm/exports.cc56
-rw-r--r--colm/loadfinal.cc171
-rw-r--r--colm/loadinit.cc7
-rw-r--r--test/rlparse.d/load.cc90
-rw-r--r--test/rlparse.d/reducer.cc7
8 files changed, 259 insertions, 158 deletions
diff --git a/colm/Makefile.am b/colm/Makefile.am
index 583aae43..aafef201 100644
--- a/colm/Makefile.am
+++ b/colm/Makefile.am
@@ -34,7 +34,8 @@ RUNTIME_SRC = \
RUNTIME_HDR = \
config.h bytecode.h defs.h debug.h pool.h input.h \
- pdarun.h map.h type.h tree.h struct.h program.h colm.h internal.h
+ pdarun.h map.h type.h tree.h struct.h program.h colm.h \
+ internal.h colmex.h
lib_LTLIBRARIES = libcolm.la
noinst_LIBRARIES = libprog.a
diff --git a/colm/colm.lm b/colm/colm.lm
index 4ebe11b8..9052f325 100644
--- a/colm/colm.lm
+++ b/colm/colm.lm
@@ -76,7 +76,7 @@ lex
token id /
( 'a' .. 'z' | 'A' .. 'Z' | '_' ) .
- ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' ) *
+ ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )*
/
token number
@@ -156,7 +156,7 @@ end
lex
token lex_id /
( 'a' .. 'z' | 'A' .. 'Z' | '_' ) .
- ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' ) *
+ ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )*
/
token lex_uint
@@ -352,7 +352,7 @@ lex
token red_id /
( 'a' .. 'z' | 'A' .. 'Z' | '_' ) .
- ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' ) *
+ ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )*
/
token red_comment /
diff --git a/colm/colmex.h b/colm/colmex.h
new file mode 100644
index 00000000..5786b0a7
--- /dev/null
+++ b/colm/colmex.h
@@ -0,0 +1,77 @@
+#ifndef _COLMEX_H
+#define _COLMEX_H
+
+#include <colm/colm.h>
+#include <colm/tree.h>
+#include <colm/colmex.h>
+#include <string.h>
+#include <string>
+#include <vector>
+
+/* Non-recursive tree iterator. Runs an in-order traversal and when it finds a
+ * search target it yields it and then resumes searching the next child. It
+ * does not go into what it finds. This iterator can be used to search lists,
+ * regardless if they are left-recursive or right-recursive. */
+template <class RootType, class SearchType> struct RepeatIter
+{
+ RepeatIter( const RootType &root )
+ :
+ prg(root.__prg),
+ search_id(SearchType::ID)
+ {
+ /* We use one code path for the first call to forward and all
+ * subsequent calls. To achieve this we create a sentinal in front of
+ * root called first and point cur to it. On the first forward() call
+ * it will be as if we just visited the sentinal.
+ *
+ * Note that we are also creating a kid for root, rather than
+ * jump into root's child list so we can entertain the
+ * possiblity that root is exactly the thing we want to visit.
+ */
+
+ memset( &first, 0, sizeof(first) );
+ memset( &kid, 0, sizeof(kid) );
+
+ first.next = &kid;
+ kid.tree = root.__tree;
+ cur = &first;
+ next();
+ }
+
+ colm_program *prg;
+ colm_kid first, kid, *cur;
+ int search_id;
+ std::vector<colm_kid*> stack;
+
+ void next()
+ {
+ goto return_to;
+ recurse:
+
+ if ( cur->tree->id == search_id )
+ return;
+ else {
+ stack.push_back( cur );
+ cur = tree_child( prg, cur->tree );
+ while ( cur != 0 ) {
+ goto recurse;
+ return_to: cur = cur->next;
+ }
+ if ( stack.size() == 0 ) {
+ cur = 0;
+ return;
+ }
+ cur = stack.back();
+ stack.pop_back();
+ goto return_to;
+ }
+ }
+
+ bool end()
+ { return cur == 0; }
+
+ SearchType value()
+ { return SearchType( prg, cur->tree ); }
+};
+
+#endif
diff --git a/colm/exports.cc b/colm/exports.cc
index 2259c3c6..cc040d57 100644
--- a/colm/exports.cc
+++ b/colm/exports.cc
@@ -59,8 +59,9 @@ void Compiler::generateExports()
"#define _EXPORTS_H\n"
"\n"
"#include <colm/colm.h>\n"
+ "#include <colm/tree.h>\n"
+ "#include <colm/colmex.h>\n"
"#include <string>\n"
- "#include <vector>\n"
"\n";
out <<
@@ -102,6 +103,7 @@ void Compiler::generateExports()
openNameSpace( out, lel->nspace );
out << "struct " << lel->fullName << "\n";
out << "{\n";
+ out << " static const int ID = " << lel->id << ";\n";
out << " std::string text() { return printTreeStr( __prg, __tree, true ); }\n";
out << " colm_location *loc() { return colm_find_location( __prg, __tree ); }\n";
out << " std::string text_notrim() { return printTreeStr( __prg, __tree, false ); }\n";
@@ -120,14 +122,6 @@ void Compiler::generateExports()
out << " " << lel->fullName <<
"( colm_program *prg, colm_tree *tree ) : __prg(prg), __tree(tree) {\n";
- if ( lel->isRepeat && lel->leftRecursive ) {
- out <<
- " while ( ! colm_repeat_end( __tree ) ) {\n"
- " stack.push_back( colm_get_left_repeat_val( __tree ) );\n"
- " __tree = colm_get_left_repeat_next( __tree );\n"
- " }\n";
- }
-
out << "}\n";
if ( lel->objectDef != 0 ) {
@@ -159,27 +153,6 @@ void Compiler::generateExports()
out << " enum prod_name prodName() " <<
"{ return (enum prod_name)__tree->prod_num; }\n";
}
-
- if ( lel->isRepeat ) {
- if ( lel->leftRecursive ) {
- out << " " << "std::vector<colm_tree*> stack;\n";
- out << " " << "int end() { return stack.size() == 0; }\n";
- out << " " << lel->refName << " next() { stack.pop_back(); return *this; }\n";
- out << " " << lel->repeatOf->refName << " value() { return " <<
- lel->repeatOf->refName << "( __prg, stack[stack.size()-1] ); }\n";
- }
- else {
- out << " " << "int end() { return colm_repeat_end( __tree ); }\n";
- out << " " << lel->refName << " next();\n";
- out << " " << lel->repeatOf->refName << " value();\n";
- }
- }
-
- if ( lel->isList ) {
- out << " " << "int last() { return colm_list_last( __tree ); }\n";
- out << " " << lel->refName << " next();\n";
- out << " " << lel->repeatOf->refName << " value();\n";
- }
out << "};";
closeNameSpace( out, lel->nspace );
@@ -223,6 +196,9 @@ void Compiler::generateExportsImpl()
out << "#include \"" << exportHeaderFn << "\"\n";
}
+ out << "#include <colm/tree.h>\n";
+ out << "#include <string.h>\n";
+
/* Function implementations. */
for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) {
if ( lel->objectDef != 0 ) {
@@ -260,26 +236,6 @@ void Compiler::generateExportsImpl()
}
}
}
-
- if ( lel->isRepeat && !lel->leftRecursive ) {
- out << lel->refName << " " << lel->declName << "::" << "next"
- "() { return " << lel->refName <<
- "( __prg, colm_get_repeat_next( __tree ) ); }\n";
-
- out << lel->repeatOf->refName << " " << lel->declName << "::" << " value"
- "() { return " << lel->repeatOf->refName <<
- "( __prg, colm_get_repeat_val( __tree ) ); }\n";
- }
-
- if ( lel->isList ) {
- out << lel->refName << " " << lel->declName << "::" << "next"
- "() { return " << lel->refName <<
- "( __prg, colm_get_repeat_next( __tree ) ); }\n";
-
- out << lel->repeatOf->refName << " " << lel->declName << "::" << " value"
- "() { return " << lel->repeatOf->refName <<
- "( __prg, colm_get_repeat_val( __tree ) ); }\n";
- }
}
out << "\n";
diff --git a/colm/loadfinal.cc b/colm/loadfinal.cc
index 54f2c6ab..01101973 100644
--- a/colm/loadfinal.cc
+++ b/colm/loadfinal.cc
@@ -76,7 +76,6 @@ String unescape( const String &s )
return out;
}
-
struct LoadColm
:
public BaseParser
@@ -313,15 +312,16 @@ struct LoadColm
StmtList *walkLangStmtList( lang_stmt_list langStmtList )
{
StmtList *retList = new StmtList;
- _repeat_statement stmtList = langStmtList.StmtList();
- /* Walk the list of items. */
- while ( !stmtList.end() ) {
- statement Statement = stmtList.value();
+ /* Walk the list of statements. */
+ RepeatIter<_repeat_statement, statement> ri( langStmtList.StmtList() );
+
+ while ( !ri.end() ) {
+ statement Statement = ri.value();
LangStmt *stmt = walkStatement( Statement );
if ( stmt != 0 )
retList->append( stmt );
- stmtList = stmtList.next();
+ ri.next();
}
require_pattern require = langStmtList.opt_require_stmt().require_pattern();
@@ -385,11 +385,13 @@ struct LoadColm
ObjectDef *objectDef = ObjectDef::cons( ObjectDef::UserType,
String(), pd->nextObjectId++ );
- while ( !varDefList.end() ) {
- ObjectField *varDef = walkVarDef( varDefList.value(),
+ RepeatIter<_repeat_var_def, var_def> varDefIter( varDefList );
+
+ while ( !varDefIter.end() ) {
+ ObjectField *varDef = walkVarDef( varDefIter.value(),
ObjectField::UserFieldType );
objVarDef( objectDef, varDef );
- varDefList = varDefList.next();
+ varDefIter.next();
}
return objectDef;
@@ -531,14 +533,17 @@ struct LoadColm
PatternItemList *walkPatSqConsDataList( _repeat_sq_cons_data sqConsDataList, CONS_SQ_NL Nl )
{
PatternItemList *list = new PatternItemList;
- while ( !sqConsDataList.end() ) {
- String consData = unescape( sqConsDataList.value().text().c_str() );
+
+ RepeatIter<_repeat_sq_cons_data, sq_cons_data> sqConsDataIter( sqConsDataList );
+
+ while ( !sqConsDataIter.end() ) {
+ String consData = unescape( sqConsDataIter.value().text().c_str() );
PatternItem *patternItem = PatternItem::cons( PatternItem::InputTextForm,
- sqConsDataList.value().loc(), consData );
+ sqConsDataIter.value().loc(), consData );
PatternItemList *tail = PatternItemList::cons( patternItem );
list = patListConcat( list, tail );
- sqConsDataList = sqConsDataList.next();
+ sqConsDataIter.next();
}
if ( Nl != 0 ) {
@@ -555,14 +560,17 @@ struct LoadColm
ConsItemList *walkConsSqConsDataList( _repeat_sq_cons_data sqConsDataList, CONS_SQ_NL Nl )
{
ConsItemList *list = new ConsItemList;
- while ( !sqConsDataList.end() ) {
- String consData = unescape( sqConsDataList.value().text().c_str() );
+
+ RepeatIter<_repeat_sq_cons_data, sq_cons_data> sqConsDataIter( sqConsDataList );
+
+ while ( !sqConsDataIter.end() ) {
+ String consData = unescape( sqConsDataIter.value().text().c_str() );
ConsItem *consItem = ConsItem::cons(
- sqConsDataList.value().loc(), ConsItem::InputText, consData );
+ sqConsDataIter.value().loc(), ConsItem::InputText, consData );
ConsItemList *tail = ConsItemList::cons( consItem );
list = consListConcat( list, tail );
- sqConsDataList = sqConsDataList.next();
+ sqConsDataIter.next();
}
if ( Nl != 0 ) {
@@ -580,10 +588,13 @@ struct LoadColm
LangVarRef *patternVarRef )
{
PatternItemList *list = new PatternItemList;
- while ( !litpatElList.end() ) {
- PatternItemList *tail = walkLitpatEl( litpatElList.value(), patternVarRef );
+
+ RepeatIter<_repeat_litpat_el, litpat_el> litpatElIter( litpatElList );
+
+ while ( !litpatElIter.end() ) {
+ PatternItemList *tail = walkLitpatEl( litpatElIter.value(), patternVarRef );
list = patListConcat( list, tail );
- litpatElList = litpatElList.next();
+ litpatElIter.next();
}
if ( Nl != 0 ) {
@@ -601,10 +612,13 @@ struct LoadColm
LangVarRef *patternVarRef )
{
PatternItemList *list = new PatternItemList;
- while ( !patternElList.end() ) {
- PatternItemList *tail = walkPatternEl( patternElList.value(), patternVarRef );
+
+ RepeatIter<_repeat_pattern_el, pattern_el> patternElIter( patternElList );
+
+ while ( !patternElIter.end() ) {
+ PatternItemList *tail = walkPatternEl( patternElIter.value(), patternVarRef );
list = patListConcat( list, tail );
- patternElList = patternElList.next();
+ patternElIter.next();
}
return list;
}
@@ -768,10 +782,13 @@ struct LoadColm
{
String lit = "";
_repeat_sq_cons_data sqConsDataList = Include.SqConsDataList();
- while ( !sqConsDataList.end() ) {
- colm_data *data = sqConsDataList.value().data();
+
+ RepeatIter<_repeat_sq_cons_data, sq_cons_data> sqConsDataIter( sqConsDataList );
+
+ while ( !sqConsDataIter.end() ) {
+ colm_data *data = sqConsDataIter.value().data();
lit.append( data->data, data->length );
- sqConsDataList = sqConsDataList.next();
+ sqConsDataIter.next();
}
String file = unescape( lit );
@@ -1447,10 +1464,13 @@ struct LoadColm
LIT_DQ_NL Nl, TypeRef *consTypeRef )
{
ConsItemList *list = new ConsItemList;
- while ( !litConsElList.end() ) {
- ConsItemList *extension = walkLitConsEl( litConsElList.value(), consTypeRef );
+
+ RepeatIter<_repeat_lit_cons_el, lit_cons_el> litConsElIter( litConsElList );
+
+ while ( !litConsElIter.end() ) {
+ ConsItemList *extension = walkLitConsEl( litConsElIter.value(), consTypeRef );
list = consListConcat( list, extension );
- litConsElList = litConsElList.next();
+ litConsElIter.next();
}
if ( Nl != 0 ) {
@@ -1505,10 +1525,13 @@ struct LoadColm
ConsItemList *walkConsElList( _repeat_cons_el consElList, TypeRef *consTypeRef )
{
ConsItemList *list = new ConsItemList;
- while ( !consElList.end() ) {
- ConsItemList *extension = walkConsEl( consElList.value(), consTypeRef );
+
+ RepeatIter<_repeat_cons_el, cons_el> consElIter( consElList );
+
+ while ( !consElIter.end() ) {
+ ConsItemList *extension = walkConsEl( consElIter.value(), consTypeRef );
list = consListConcat( list, extension );
- consElList = consElList.next();
+ consElIter.next();
}
return list;
}
@@ -1577,10 +1600,13 @@ struct LoadColm
ConsItemList *walkLitStringElList( _repeat_lit_string_el litStringElList, LIT_DQ_NL Nl )
{
ConsItemList *list = new ConsItemList;
- while ( !litStringElList.end() ) {
- ConsItemList *extension = walkLitStringEl( litStringElList.value() );
+
+ RepeatIter<_repeat_lit_string_el, lit_string_el> litStringElIter( litStringElList );
+
+ while ( !litStringElIter.end() ) {
+ ConsItemList *extension = walkLitStringEl( litStringElIter.value() );
list = consListConcat( list, extension );
- litStringElList = litStringElList.next();
+ litStringElIter.next();
}
if ( Nl != 0 ) {
@@ -1630,10 +1656,13 @@ struct LoadColm
ConsItemList *walkStringElList( _repeat_string_el stringElList )
{
ConsItemList *list = new ConsItemList;
- while ( !stringElList.end() ) {
- ConsItemList *extension = walkStringEl( stringElList.value() );
+
+ RepeatIter<_repeat_string_el, string_el> stringElIter( stringElList );
+
+ while ( !stringElIter.end() ) {
+ ConsItemList *extension = walkStringEl( stringElIter.value() );
list = consListConcat( list, extension );
- stringElList = stringElList.next();
+ stringElIter.next();
}
return list;
}
@@ -1703,10 +1732,13 @@ struct LoadColm
ConsItemList *walkLitAccumElList( _repeat_lit_accum_el litAccumElList, LIT_DQ_NL Nl )
{
ConsItemList *list = new ConsItemList;
- while ( !litAccumElList.end() ) {
- ConsItemList *extension = walkLitAccumEl( litAccumElList.value() );
+
+ RepeatIter<_repeat_lit_accum_el, lit_accum_el> litAccumElIter( litAccumElList );
+
+ while ( !litAccumElIter.end() ) {
+ ConsItemList *extension = walkLitAccumEl( litAccumElIter.value() );
list = consListConcat( list, extension );
- litAccumElList = litAccumElList.next();
+ litAccumElIter.next();
}
if ( Nl != 0 ) {
@@ -1756,10 +1788,13 @@ struct LoadColm
ConsItemList *walkAccumElList( _repeat_accum_el accumElList )
{
ConsItemList *list = new ConsItemList;
- while ( !accumElList.end() ) {
- ConsItemList *extension = walkAccumEl( accumElList.value() );
+
+ RepeatIter<_repeat_accum_el, accum_el> accumElIter( accumElList );
+
+ while ( !accumElIter.end() ) {
+ ConsItemList *extension = walkAccumEl( accumElIter.value() );
list = consListConcat( list, extension );
- accumElList = accumElList.next();
+ accumElIter.next();
}
return list;
}
@@ -1821,9 +1856,12 @@ struct LoadColm
FieldInitVect *walkFieldInit( _repeat_field_init fieldInitList )
{
FieldInitVect *list = new FieldInitVect;
- while ( !fieldInitList.end() ) {
- walkFieldInit( list, fieldInitList.value() );
- fieldInitList = fieldInitList.next();
+
+ RepeatIter<_repeat_field_init, field_init> fieldInitIter( fieldInitList );
+
+ while ( !fieldInitIter.end() ) {
+ walkFieldInit( list, fieldInitIter.value() );
+ fieldInitIter.next();
}
return list;
}
@@ -2478,9 +2516,12 @@ struct LoadColm
structHead( structDef.id().loc(), curNspace(), name, ObjectDef::StructType );
_repeat_struct_item structItemList = structDef.ItemList();
- while ( !structItemList.end() ) {
- walkStructItem( structItemList.value() );
- structItemList = structItemList.next();
+
+ RepeatIter<_repeat_struct_item, struct_item> structItemIter( structItemList );
+
+ while ( !structItemIter.end() ) {
+ walkStructItem( structItemIter.value() );
+ structItemIter.next();
}
structStack.pop();
@@ -2567,9 +2608,11 @@ struct LoadColm
void walkRedItemList( _repeat_host_item itemList, ReduceTextItemList &list )
{
- while ( !itemList.end() ) {
- walkRedItem( itemList.value(), list );
- itemList = itemList.next();
+ RepeatIter<_repeat_host_item, host_item> itemIter( itemList );
+
+ while ( !itemIter.end() ) {
+ walkRedItem( itemIter.value(), list );
+ itemIter.next();
}
}
@@ -2616,9 +2659,11 @@ struct LoadColm
void walkReductionList( _repeat_reduction_item itemList )
{
- while ( !itemList.end() ) {
- walkReductionItem( itemList.value() );
- itemList = itemList.next();
+ RepeatIter<_repeat_reduction_item, reduction_item> itemIter( itemList );
+
+ while ( !itemIter.end() ) {
+ walkReductionItem( itemIter.value() );
+ itemIter.next();
}
}
@@ -2810,9 +2855,10 @@ struct LoadColm
void walkNamespaceItemList( _repeat_namespace_item itemList, StmtList *stmtList )
{
/* Walk the list of items. */
- while ( !itemList.end() ) {
- walkNamespaceItem( itemList.value(), stmtList );
- itemList = itemList.next();
+ RepeatIter<_repeat_namespace_item, namespace_item> itemIter( itemList );
+ while ( !itemIter.end() ) {
+ walkNamespaceItem( itemIter.value(), stmtList );
+ itemIter.next();
}
}
@@ -2821,9 +2867,10 @@ struct LoadColm
StmtList *stmtList = new StmtList;
/* Walk the list of items. */
- while ( !rootItemList.end() ) {
- walkRootItem( rootItemList.value(), stmtList );
- rootItemList = rootItemList.next();
+ RepeatIter<_repeat_root_item, root_item> rootItemIter( rootItemList );
+ while ( !rootItemIter.end() ) {
+ walkRootItem( rootItemIter.value(), stmtList );
+ rootItemIter.next();
}
return stmtList;
}
diff --git a/colm/loadinit.cc b/colm/loadinit.cc
index ea5e7f00..027a1018 100644
--- a/colm/loadinit.cc
+++ b/colm/loadinit.cc
@@ -394,14 +394,15 @@ void LoadInit::go( long activeRealm )
/* Walk the list of items. */
_repeat_item ItemList = Start.ItemList();
- while ( !ItemList.end() ) {
+ RepeatIter<_repeat_item, item> itemIter( ItemList );
+ while ( !itemIter.end() ) {
- item Item = ItemList.value();
+ item Item = itemIter.value();
if ( Item.DefId() != 0 )
walkDefinition( Item );
else if ( Item.TokenList() != 0 )
walkLexRegion( Item );
- ItemList = ItemList.next();
+ itemIter.next();
}
pd->streamFileNames.append( colm_extract_fns( program ) );
diff --git a/test/rlparse.d/load.cc b/test/rlparse.d/load.cc
index 2f5d363f..3d6e297b 100644
--- a/test/rlparse.d/load.cc
+++ b/test/rlparse.d/load.cc
@@ -318,9 +318,11 @@ struct LoadRagel
InlineList *loadInlineBlock( InlineList *inlineList, ruby_inline::inline_block RubyInlineBlock )
{
ruby_inline::_repeat_block_item BlockItemList = RubyInlineBlock._repeat_block_item();
- while ( !BlockItemList.end() ) {
- loadBlockItem( inlineList, BlockItemList.value() );
- BlockItemList = BlockItemList.next();
+
+ RepeatIter<ruby_inline::_repeat_block_item, ruby_inline::block_item> BlockItemIter( BlockItemList );
+ while ( !BlockItemIter.end() ) {
+ loadBlockItem( inlineList, BlockItemIter.value() );
+ BlockItemIter.next();
}
return inlineList;
}
@@ -362,10 +364,11 @@ struct LoadRagel
{
InlineList *inlineList = new InlineList;
ruby_inline::_repeat_expr_item ExprItemList = InlineExpr._repeat_expr_item();
- while ( !ExprItemList.end() ) {
- InlineItem *inlineItem = loadExprItem( ExprItemList.value() );
+ RepeatIter<ruby_inline::_repeat_expr_item, ruby_inline::expr_item> ExprItemIter( ExprItemList );
+ while ( !ExprItemIter.end() ) {
+ InlineItem *inlineItem = loadExprItem( ExprItemIter.value() );
inlineList->append( inlineItem );
- ExprItemList = ExprItemList.next();
+ ExprItemIter.next();
}
return inlineList;
}
@@ -529,9 +532,11 @@ struct LoadRagel
InlineList *loadInlineBlock( InlineList *inlineList, ocaml_inline::inline_block OCamlInlineBlock )
{
ocaml_inline::_repeat_block_item BlockItemList = OCamlInlineBlock._repeat_block_item();
- while ( !BlockItemList.end() ) {
- loadBlockItem( inlineList, BlockItemList.value() );
- BlockItemList = BlockItemList.next();
+
+ RepeatIter<ocaml_inline::_repeat_block_item, ocaml_inline::block_item> BlockItemIter( BlockItemList );
+ while ( !BlockItemIter.end() ) {
+ loadBlockItem( inlineList, BlockItemIter.value() );
+ BlockItemIter.next();
}
return inlineList;
}
@@ -573,10 +578,12 @@ struct LoadRagel
{
InlineList *inlineList = new InlineList;
ocaml_inline::_repeat_expr_item ExprItemList = InlineExpr._repeat_expr_item();
- while ( !ExprItemList.end() ) {
- InlineItem *inlineItem = loadExprItem( ExprItemList.value() );
+
+ RepeatIter<ocaml_inline::_repeat_expr_item, ocaml_inline::expr_item> ExprItemIter( ExprItemList );
+ while ( !ExprItemIter.end() ) {
+ InlineItem *inlineItem = loadExprItem( ExprItemIter.value() );
inlineList->append( inlineItem );
- ExprItemList = ExprItemList.next();
+ ExprItemIter.next();
}
return inlineList;
}
@@ -740,9 +747,11 @@ struct LoadRagel
InlineList *loadInlineBlock( InlineList *inlineList, crack_inline::inline_block CrackInlineBlock )
{
crack_inline::_repeat_block_item BlockItemList = CrackInlineBlock._repeat_block_item();
- while ( !BlockItemList.end() ) {
- loadBlockItem( inlineList, BlockItemList.value() );
- BlockItemList = BlockItemList.next();
+
+ RepeatIter<crack_inline::_repeat_block_item, crack_inline::block_item> BlockItemIter( BlockItemList );
+ while ( !BlockItemIter.end() ) {
+ loadBlockItem( inlineList, BlockItemIter.value() );
+ BlockItemIter.next();
}
return inlineList;
}
@@ -784,10 +793,12 @@ struct LoadRagel
{
InlineList *inlineList = new InlineList;
crack_inline::_repeat_expr_item ExprItemList = InlineExpr._repeat_expr_item();
- while ( !ExprItemList.end() ) {
- InlineItem *inlineItem = loadExprItem( ExprItemList.value() );
+
+ RepeatIter<crack_inline::_repeat_expr_item, crack_inline::expr_item> ExprItemIter( ExprItemList );
+ while ( !ExprItemIter.end() ) {
+ InlineItem *inlineItem = loadExprItem( ExprItemIter.value() );
inlineList->append( inlineItem );
- ExprItemList = ExprItemList.next();
+ ExprItemIter.next();
}
return inlineList;
}
@@ -2287,9 +2298,10 @@ struct LoadRagel
inputItem->writeArgs.push_back( Cmd.text() );
- while ( !WordList.end() ) {
- inputItem->writeArgs.push_back( WordList.value().text() );
- WordList = WordList.next();
+ RepeatIter<ragel::_repeat_write_arg, ragel::write_arg> WordIter( WordList );
+ while ( !WordIter.end() ) {
+ inputItem->writeArgs.push_back( WordIter.value().text() );
+ WordIter.next();
}
id.inputItems.append( inputItem );
@@ -2460,9 +2472,10 @@ struct LoadRagel
void loadImportList( _repeat_import ImportList )
{
- while ( !ImportList.end() ) {
- loadImport( ImportList.value() );
- ImportList = ImportList.next();
+ RepeatIter<_repeat_import, import> ImportIter( ImportList );
+ while ( !ImportIter.end() ) {
+ loadImport( ImportIter.value() );
+ ImportIter.next();
}
}
@@ -2588,11 +2601,13 @@ struct LoadRagel
}
ragel::_repeat_statement StmtList = RagelStart._repeat_statement();
- while ( !StmtList.end() ) {
- bool stop = loadStatement( StmtList.value() );
+
+ RepeatIter<ragel::_repeat_statement, ragel::statement> StmtIter( StmtList );
+ while ( !StmtIter.end() ) {
+ bool stop = loadStatement( StmtIter.value() );
if ( stop )
break;
- StmtList = StmtList.next();
+ StmtIter.next();
}
}
@@ -2691,26 +2706,29 @@ struct LoadRagel
c_host::_repeat_section SectionList = Start.SectionList();
if ( SectionList ) {
- while ( !SectionList.end() ) {
- loadSection( SectionList.value(), targetMachine, searchMachine );
- SectionList = SectionList.next();
+ RepeatIter<c_host::_repeat_section, c_host::section> SectionIter( SectionList );
+ while ( !SectionIter.end() ) {
+ loadSection( SectionIter.value(), targetMachine, searchMachine );
+ SectionIter.next();
}
}
else if ( Start.RSectionList() ) {
ruby_host::_repeat_section RSectionList = Start.RSectionList();
if ( RSectionList ) {
- while ( !RSectionList.end() ) {
- loadSection( RSectionList.value(), targetMachine, searchMachine );
- RSectionList = RSectionList.next();
+ RepeatIter<ruby_host::_repeat_section, ruby_host::section> RSectionIter( RSectionList );
+ while ( !RSectionIter.end() ) {
+ loadSection( RSectionIter.value(), targetMachine, searchMachine );
+ RSectionIter.next();
}
}
}
else {
ocaml_host::_repeat_section OSectionList = Start.OSectionList();
if ( OSectionList ) {
- while ( !OSectionList.end() ) {
- loadSection( OSectionList.value(), targetMachine, searchMachine );
- OSectionList = OSectionList.next();
+ RepeatIter<ocaml_host::_repeat_section, ocaml_host::section> OSectionIter( OSectionList );
+ while ( !OSectionIter.end() ) {
+ loadSection( OSectionIter.value(), targetMachine, searchMachine );
+ OSectionIter.next();
}
}
}
diff --git a/test/rlparse.d/reducer.cc b/test/rlparse.d/reducer.cc
index d22b6622..b3bd32ba 100644
--- a/test/rlparse.d/reducer.cc
+++ b/test/rlparse.d/reducer.cc
@@ -248,8 +248,9 @@ void TopLevel::loadImport( std::string fileName )
return;
}
- while ( !ImportList.end() ) {
- import Import = ImportList.value();
+ RepeatIter<_repeat_import, import> ImportIter( ImportList );
+ while ( !ImportIter.end() ) {
+ import Import = ImportIter.value();
InputLoc loc = Import.loc();
string name = Import.Name().text();
@@ -292,7 +293,7 @@ void TopLevel::loadImport( std::string fileName )
tryMachineDef( loc, name, machineDef, false );
machineDef->join->loc = loc;
- ImportList = ImportList.next();
+ ImportIter.next();
}
id->streamFileNames.append( colm_extract_fns( program ) );