diff options
author | Adrian Thurston <thurston@colm.net> | 2020-01-03 14:47:15 +0200 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2020-01-03 14:47:15 +0200 |
commit | a8b2047e0043649bbd3a33d7c7ba67b6af57594b (patch) | |
tree | b815f43b7908c7827d6e3c64a458732c3d4f739e | |
parent | 4c641cd2f8c9e8959c73ed64c6df7c0f8c8e7d4f (diff) | |
parent | a1028d7f79c71a1e52ae11071b69adaec593cbdb (diff) | |
download | colm-a8b2047e0043649bbd3a33d7c7ba67b6af57594b.tar.gz |
merge branch 'literal-concatenation'
Pushing forward with the literal-concatenation patch. This brings back lists of
literals strings at the top level of strings, constructors and patterns.
-rw-r--r-- | colm/colm.lm | 21 | ||||
-rw-r--r-- | colm/loadfinal.cc | 64 |
2 files changed, 51 insertions, 34 deletions
diff --git a/colm/colm.lm b/colm/colm.lm index 9052f325..c95d0c41 100644 --- a/colm/colm.lm +++ b/colm/colm.lm @@ -736,13 +736,14 @@ def pattern_top_el [DQ LitpatElList: litpat_el<* dq_lit_term] :Dq | [SQ SqConsDataList: sq_cons_data<* sq_lit_term] :Sq | [TILDE opt_tilde_data TILDE_NL] :Tilde -| [SQOPEN PatternElList: pattern_el<* SQCLOSE] :SubList def pattern_list - [pattern_top_el] :Base + [pattern_top_el pattern_list] :List +| [pattern_top_el] :Base def pattern - [pattern_list] + [pattern_list] :TopList +| [SQOPEN PatternElList: pattern_el<* SQCLOSE] :SubList # # Constructor List @@ -768,13 +769,14 @@ def cons_top_el [DQ LitConsElList: lit_cons_el<* dq_lit_term] :Dq | [SQ SqConsDataList: sq_cons_data<* sq_lit_term] :Sq | [TILDE opt_tilde_data TILDE_NL] :Tilde -| [SQOPEN ConsElList: cons_el<* SQCLOSE] :SubList def cons_list - [cons_top_el] :Base + [cons_top_el cons_list] :List +| [cons_top_el] :Base def constructor - [cons_list] + [cons_list] :TopList +| [SQOPEN ConsElList: cons_el<* SQCLOSE] :SubList # # Accumulate @@ -821,13 +823,14 @@ def string_top_el [DQ LitStringElList: lit_string_el<* dq_lit_term] :Dq | [SQ SqConsDataList: sq_cons_data<* sq_lit_term] :Sq | [TILDE opt_tilde_data TILDE_NL] :Tilde -| [SQOPEN StringElList: string_el<* SQCLOSE] :SubList def string_list - [string_top_el] :Base + [string_top_el string_list] :List +| [string_top_el] :Base def string - [string_list] + [string_list] :TopList +| [SQOPEN StringElList: string_el<* SQCLOSE] :SubList # # Variable References diff --git a/colm/loadfinal.cc b/colm/loadfinal.cc index 35381729..6c8eb847 100644 --- a/colm/loadfinal.cc +++ b/colm/loadfinal.cc @@ -645,28 +645,29 @@ struct LoadColm patternTopEl.opt_tilde_data().loc(), patternData ); list = PatternItemList::cons( patternItem ); break; - } - case pattern_top_el::SubList: { - list = walkPatternElList( patternTopEl.PatternElList(), patternVarRef ); - break; }} return list; } PatternItemList *walkPatternList( pattern_list patternList, LangVarRef *patternVarRef ) { - PatternItemList *list = 0; - switch ( patternList.prodName() ) { - case pattern_list::Base: { - list = walkPattternTopEl( patternList.pattern_top_el(), patternVarRef ); - break; - }} - return list; + PatternItemList *ret = new PatternItemList; + RepeatIter<pattern_top_el> patternTopElIter ( patternList ); + while ( !patternTopElIter.end() ) { + PatternItemList *list = walkPattternTopEl( patternTopElIter.value(), patternVarRef ); + ret->append( *list ); + delete list; + patternTopElIter.next(); + } + return ret; } PatternItemList *walkPattern( pattern Pattern, LangVarRef *patternVarRef ) { - return walkPatternList( Pattern.pattern_list(), patternVarRef ); + if ( Pattern.prodName() == pattern::TopList ) + return walkPatternList( Pattern.pattern_list(), patternVarRef ); + else + return walkPatternElList( Pattern.PatternElList(), patternVarRef ); } LangExpr *walkOptDefInit( opt_def_init optDefInit ) @@ -1560,22 +1561,29 @@ struct LoadColm ConsItem::InputText, consData ); list = ConsItemList::cons( consItem ); break; - } - case cons_top_el::SubList: { - list = walkConsElList( consTopEl.ConsElList(), consTypeRef ); - break; }} return list; } ConsItemList *walkConsList( cons_list consList, TypeRef *consTypeRef ) { - return walkConsTopEl( consList.cons_top_el(), consTypeRef ); + ConsItemList *ret = new ConsItemList; + RepeatIter<cons_top_el> consTopElIter ( consList ); + while ( !consTopElIter.end() ) { + ConsItemList *list = walkConsTopEl( consTopElIter.value(), consTypeRef ); + ret->append( *list ); + delete list; + consTopElIter.next(); + } + return ret; } ConsItemList *walkConstructor( constructor Constructor, TypeRef *consTypeRef ) { - return walkConsList( Constructor.cons_list(), consTypeRef ); + if ( Constructor.prodName() == constructor::TopList ) + return walkConsList( Constructor.cons_list(), consTypeRef ); + else + return walkConsElList( Constructor.ConsElList(), consTypeRef ); } /* @@ -1691,23 +1699,29 @@ struct LoadColm ConsItem::InputText, consData ); list = ConsItemList::cons( consItem ); break; - } - case string_top_el::SubList: { - list = walkStringElList( stringTopEl.StringElList() ); - break; }} return list; } ConsItemList *walkStringList( string_list stringList ) { - return walkStringTopEl( stringList.string_top_el() ); + ConsItemList *ret = new ConsItemList; + RepeatIter<string_top_el> stringTopElIter( stringList ); + while ( !stringTopElIter.end() ) { + ConsItemList *list = walkStringTopEl( stringTopElIter.value() ); + ret->append( *list ); + delete list; + stringTopElIter.next(); + } + return ret; } ConsItemList *walkString( string String ) { - ConsItemList *list = walkStringList( String.string_list() ); - return list; + if ( String.prodName() == string::TopList ) + return walkStringList( String.string_list() ); + else + return walkStringElList( String.StringElList() ); } /* |