diff options
author | Adrian Thurston <thurston@complang.org> | 2011-07-09 17:08:50 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2011-07-09 17:08:50 +0000 |
commit | b550a23dc3e3a3b3d58f3cb8749c703900914a03 (patch) | |
tree | b857a3166169230e1d8c716be88d83083946b37f | |
parent | 19236920277b438cf55d1fe105a4f4551fbae91d (diff) | |
download | colm-b550a23dc3e3a3b3d58f3cb8749c703900914a03.tar.gz |
More cleanup of ProdEl.
-rw-r--r-- | colm/lmparse.kl | 25 | ||||
-rw-r--r-- | colm/parsedata.cc | 18 | ||||
-rw-r--r-- | colm/parsedata.h | 18 |
3 files changed, 19 insertions, 42 deletions
diff --git a/colm/lmparse.kl b/colm/lmparse.kl index 322f8307..a8739d0f 100644 --- a/colm/lmparse.kl +++ b/colm/lmparse.kl @@ -289,8 +289,7 @@ nonterm pred_token pred_token: region_qual TK_Word final { - $$->factor = new ProdEl( $2->loc, false, 0, $1->nspaceQual, - $2->data, 0, RepeatNone, false, false ); + $$->factor = new ProdEl( ProdEl::ReferenceType, $2->loc, false, 0, 0 ); pd->resolveReferenceFactor( $$->factor ); }; @@ -298,8 +297,7 @@ pred_token: region_qual TK_Literal final { PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 ); - $$->factor = new ProdEl( $2->loc, false, 0, $1->nspaceQual, - literal, 0, RepeatNone, false, false ); + $$->factor = new ProdEl( ProdEl::LiteralType, $2->loc, false, 0, 0 ); pd->resolveLiteralFactor( $$->factor ); }; @@ -641,8 +639,7 @@ pattern_el_type_or_lit: region_qual TK_Word opt_repeat final { TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, $2->data ); typeRef->repeatType = $3->repeatType; - ProdEl *factor = new ProdEl( $2->loc, false, typeRef, $1->nspaceQual, - $2->data, 0, $3->repeatType, $3->opt, $3->repeat ); + ProdEl *factor = new ProdEl( ProdEl::ReferenceType, $2->loc, false, typeRef, 0 ); $$->patternItem = new PatternItem( $2->loc, factor, PatternItem::FactorType ); patternItemList->append( $$->patternItem ); }; @@ -653,8 +650,7 @@ pattern_el_type_or_lit: region_qual TK_Literal opt_repeat TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, literal ); typeRef->repeatType = $3->repeatType; - ProdEl *factor = new ProdEl( $2->loc, false, typeRef, $1->nspaceQual, - literal, 0, $3->repeatType, $3->opt, $3->repeat ); + ProdEl *factor = new ProdEl( ProdEl::ReferenceType, $2->loc, false, typeRef, 0 ); $$->patternItem = new PatternItem( $2->loc, factor, PatternItem::FactorType ); patternItemList->append( $$->patternItem ); }; @@ -708,8 +704,7 @@ repl_el: region_qual TK_Literal PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 ); TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, literal ); typeRef->repeatType = RepeatNone; - ProdEl *factor = new ProdEl( $2->loc, false, typeRef, $1->nspaceQual, - literal, 0, RepeatNone, false, false ); + ProdEl *factor = new ProdEl( ProdEl::LiteralType, $2->loc, false, typeRef, 0 ); ReplItem *replItem = new ReplItem( $2->loc, ReplItem::FactorType, factor ); replItemList->append( replItem ); }; @@ -760,7 +755,7 @@ accum_el_list: ; # final { # PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 ); # ProdEl *factor = new ProdEl( $2->loc, false, $1->nspaceQual, -# literal, 0, RepeatNone, false, false ); +# literal, 0 ); # ReplItem *replItem = new ReplItem( $2->loc, ReplItem::FactorType, factor ); # replItemList->append( replItem ); # }; @@ -806,7 +801,7 @@ string_el_list: ; # final { # PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 ); # ProdEl *factor = new ProdEl( $2->loc, false, $1->nspaceQual, -# literal, 0, RepeatNone, false, false ); +# literal, 0 ); # ReplItem *replItem = new ReplItem( $2->loc, ReplItem::FactorType, factor ); # replItemList->append( replItem ); # }; @@ -837,8 +832,7 @@ prod_el: final { TypeRef *typeRef = new TypeRef( $3->loc, $2->nspaceQual, $3->data ); typeRef->repeatType = $4->repeatType; - $$->factor = new ProdEl( $3->loc, $1->commit, typeRef, - $2->nspaceQual, $3->data, 0, $4->repeatType, $4->opt, $4->repeat ); + $$->factor = new ProdEl( ProdEl::ReferenceType, $3->loc, $1->commit, typeRef, 0 ); }; prod_el: @@ -848,8 +842,7 @@ prod_el: PdaLiteral *literal = new PdaLiteral( $3->loc, *$3 ); TypeRef *typeRef = new TypeRef( $3->loc, $2->nspaceQual, literal ); typeRef->repeatType = $4->repeatType; - $$->factor = new ProdEl( $3->loc, $1->commit, typeRef, $2->nspaceQual, - literal, 0, $4->repeatType, $4->opt, $4->repeat ); + $$->factor = new ProdEl( ProdEl::LiteralType, $3->loc, $1->commit, typeRef, 0 ); }; nonterm opt_repeat diff --git a/colm/parsedata.cc b/colm/parsedata.cc index ccbbbbfd..a91f18d8 100644 --- a/colm/parsedata.cc +++ b/colm/parsedata.cc @@ -1127,12 +1127,10 @@ LangEl *ParseData::makeRepeatProd( Namespace *nspace, const String &repeatName, /* Build the first production of the repeat. */ TypeRef *typeRef1 = new TypeRef( InputLoc(), nspaceQual, name ); - ProdEl *factor1 = new ProdEl( InputLoc(), false, typeRef1, nspaceQual, - name, 0, RepeatNone, false, false ); + ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), false, typeRef1, 0 ); TypeRef *typeRef2 = new TypeRef( InputLoc(), nspaceQual, repeatName ); - ProdEl *factor2 = new ProdEl( InputLoc(), false, typeRef2, nspaceQual, - repeatName, 0, RepeatNone, false, false ); + ProdEl *factor2 = new ProdEl( ProdEl::ReferenceType, InputLoc(), false, typeRef2, 0 ); prodElList1->append( factor1 ); prodElList1->append( factor2 ); @@ -1165,12 +1163,10 @@ LangEl *ParseData::makeListProd( Namespace *nspace, const String &listName, Name /* Build the first production of the list. */ TypeRef *typeRef1 = new TypeRef( InputLoc(), nspaceQual, name ); - ProdEl *factor1 = new ProdEl( InputLoc(), false, typeRef1, nspaceQual, - name, 0, RepeatNone, false, false ); + ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), false, typeRef1, 0 ); TypeRef *typeRef2 = new TypeRef( InputLoc(), nspaceQual, listName ); - ProdEl *factor2 = new ProdEl( InputLoc(), false, typeRef2, nspaceQual, - listName, 0, RepeatNone, false, false ); + ProdEl *factor2 = new ProdEl( ProdEl::ReferenceType, InputLoc(), false, typeRef2, 0 ); ProdElList *prodElList1 = new ProdElList; prodElList1->append( factor1 ); @@ -1185,8 +1181,7 @@ LangEl *ParseData::makeListProd( Namespace *nspace, const String &listName, Name /* Build the second production of the list. */ TypeRef *typeRef3 = new TypeRef( InputLoc(), nspaceQual, name ); - ProdEl *factor3 = new ProdEl( InputLoc(), false, typeRef3, nspaceQual, - name, 0, RepeatNone, false, false ); + ProdEl *factor3 = new ProdEl( ProdEl::ReferenceType, InputLoc(), false, typeRef3, 0 ); ProdElList *prodElList2 = new ProdElList; prodElList2->append( factor3 ); @@ -1211,8 +1206,7 @@ LangEl *ParseData::makeOptProd( Namespace *nspace, const String &optName, Namesp /* Build the first production of the repeat. */ TypeRef *typeRef1 = new TypeRef( InputLoc(), nspaceQual, name ); - ProdEl *factor1 = new ProdEl( InputLoc(), false, typeRef1, nspaceQual, - name, 0, RepeatNone, false, false ); + ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), false, typeRef1, 0 ); prodElList1->append( factor1 ); Definition *newDef1 = new Definition( InputLoc(), diff --git a/colm/parsedata.h b/colm/parsedata.h index d03b0d5f..880aa798 100644 --- a/colm/parsedata.h +++ b/colm/parsedata.h @@ -245,23 +245,15 @@ struct ProdEl ReferenceType }; - /* Construct with a literal fsm. */ - ProdEl( const InputLoc &loc, bool commit, TypeRef *typeRef, NamespaceQual *nspaceQual, - PdaLiteral *literal, int priorVal, RepeatType repeatType, bool opt, bool repeat ) : - commit(commit), typeRef(typeRef), - langEl(0), priorVal(priorVal), repeatType(repeatType), - nspace(0), type(LiteralType), objField(0) {} - /* Construct with a reference to a var def. */ - ProdEl( const InputLoc &loc, bool commit, TypeRef *typeRef, NamespaceQual *nspaceQual, - const String &refName, int priorVal, RepeatType repeatType, bool opt, bool repeat ) : + ProdEl( Type type, const InputLoc &loc, bool commit, TypeRef *typeRef, int priorVal ) : commit(commit), typeRef(typeRef), - langEl(0), priorVal(priorVal), repeatType(repeatType), - nspace(0), type(ReferenceType), objField(0) {} + langEl(0), priorVal(priorVal), + type(type), objField(0) {} ProdEl( const InputLoc &loc, TypeRef *typeRef ) : commit(false), typeRef(typeRef), langEl(0), - priorVal(0), repeatType(RepeatNone), nspace(0), + priorVal(0), type(ReferenceType), objField(0) {} bool commit; @@ -270,8 +262,6 @@ struct ProdEl LangEl *langEl; int priorVal; - RepeatType repeatType; - Namespace *nspace; Type type; ObjField *objField; ProdEl *prev, *next; |