summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler.cc14
-rw-r--r--src/lmparse.kl64
-rw-r--r--src/parsedata.h64
-rw-r--r--src/parsetree.cc22
-rw-r--r--src/parsetree.h314
5 files changed, 329 insertions, 149 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index e5cdfbb1..1e955fd7 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -789,7 +789,7 @@ Action *Compiler::newAction( const String &name, InlineList *inlineList )
loc.col = 1;
loc.fileName = 0;
- Action *action = new Action( loc, name, inlineList );
+ Action *action = Action::cons( loc, name, inlineList );
actionList.append( action );
return action;
}
@@ -798,20 +798,20 @@ void Compiler::initLongestMatchData()
{
if ( regionList.length() > 0 ) {
/* The initActId action gives act a default value. */
- InlineList *il4 = new InlineList;
- il4->append( new InlineItem( InputLoc(), InlineItem::LmInitAct ) );
+ InlineList *il4 = InlineList::cons();
+ il4->append( InlineItem::cons( InputLoc(), InlineItem::LmInitAct ) );
initActId = newAction( "initact", il4 );
initActId->isLmAction = true;
/* The setTokStart action sets tokstart. */
- InlineList *il5 = new InlineList;
- il5->append( new InlineItem( InputLoc(), InlineItem::LmSetTokStart ) );
+ InlineList *il5 = InlineList::cons();
+ il5->append( InlineItem::cons( InputLoc(), InlineItem::LmSetTokStart ) );
setTokStart = newAction( "tokstart", il5 );
setTokStart->isLmAction = true;
/* The setTokEnd action sets tokend. */
- InlineList *il3 = new InlineList;
- il3->append( new InlineItem( InputLoc(), InlineItem::LmSetTokEnd ) );
+ InlineList *il3 = InlineList::cons();
+ il3->append( InlineItem::cons( InputLoc(), InlineItem::LmSetTokEnd ) );
setTokEnd = newAction( "tokend", il3 );
setTokEnd->isLmAction = true;
diff --git a/src/lmparse.kl b/src/lmparse.kl
index 16c7b656..bf1b6a7a 100644
--- a/src/lmparse.kl
+++ b/src/lmparse.kl
@@ -608,7 +608,7 @@ litpat_el_list: ;
litpat_el: TK_LitPat
final {
- PatternItem *patternItem = new PatternItem( $1->loc, $1->data,
+ PatternItem *patternItem = PatternItem::cons( $1->loc, $1->data,
PatternItem::InputText );
patternItemList->append( patternItem );
};
@@ -654,7 +654,7 @@ pattern_el_type_or_lit: region_qual TK_Word opt_repeat
TypeRef *typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, $2->data );
typeRef->repeatType = $3->repeatType;
ProdEl *factor = new ProdEl( ProdEl::ReferenceType, $2->loc, 0, false, typeRef, 0 );
- $$->patternItem = new PatternItem( $2->loc, factor, PatternItem::FactorType );
+ $$->patternItem = PatternItem::cons( $2->loc, factor, PatternItem::FactorType );
patternItemList->append( $$->patternItem );
};
@@ -665,7 +665,7 @@ pattern_el_type_or_lit: region_qual TK_Literal opt_repeat
typeRef->repeatType = $3->repeatType;
ProdEl *factor = new ProdEl( ProdEl::ReferenceType, $2->loc, 0, false, typeRef, 0 );
- $$->patternItem = new PatternItem( $2->loc, factor, PatternItem::FactorType );
+ $$->patternItem = PatternItem::cons( $2->loc, factor, PatternItem::FactorType );
patternItemList->append( $$->patternItem );
};
@@ -704,7 +704,7 @@ lit_repl_el_list: ;
lit_repl_el: TK_LitPat
final {
- ReplItem *replItem = new ReplItem( $1->loc, ReplItem::InputText, $1->data );
+ ReplItem *replItem = ReplItem::cons( $1->loc, ReplItem::InputText, $1->data );
replItemList->append( replItem );
};
@@ -719,14 +719,14 @@ repl_el: region_qual TK_Literal
TypeRef *typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, literal );
typeRef->repeatType = RepeatNone;
ProdEl *factor = new ProdEl( ProdEl::LiteralType, $2->loc, 0, false, typeRef, 0 );
- ReplItem *replItem = new ReplItem( $2->loc, ReplItem::FactorType, factor );
+ ReplItem *replItem = ReplItem::cons( $2->loc, ReplItem::FactorType, factor );
replItemList->append( replItem );
};
repl_el: '"' lit_repl_el_list '"';
repl_el: code_expr
final {
- ReplItem *replItem = new ReplItem( $1->expr->loc, ReplItem::ExprType, $1->expr );
+ ReplItem *replItem = ReplItem::cons( $1->expr->loc, ReplItem::ExprType, $1->expr );
replItemList->append( replItem );
};
@@ -736,7 +736,7 @@ repl_el: code_expr
accumulate: init_repl_list accum_list;
accumulate: init_repl_list code_expr
final {
- ReplItem *replItem = new ReplItem( $2->expr->loc, ReplItem::ExprType, $2->expr );
+ ReplItem *replItem = ReplItem::cons( $2->expr->loc, ReplItem::ExprType, $2->expr );
replItemList->append( replItem );
};
@@ -756,7 +756,7 @@ lit_accum_el_list: ;
lit_accum_el: TK_LitPat
final {
- ReplItem *replItem = new ReplItem( $1->loc, ReplItem::InputText, $1->data );
+ ReplItem *replItem = ReplItem::cons( $1->loc, ReplItem::InputText, $1->data );
replItemList->append( replItem );
};
@@ -775,7 +775,7 @@ accum_el_list: ;
# };
accum_el: code_expr
final {
- ReplItem *replItem = new ReplItem( $1->expr->loc, ReplItem::ExprType, $1->expr );
+ ReplItem *replItem = ReplItem::cons( $1->expr->loc, ReplItem::ExprType, $1->expr );
replItemList->append( replItem );
};
@@ -802,7 +802,7 @@ lit_string_el_list: ;
lit_string_el: TK_LitPat
final {
- ReplItem *replItem = new ReplItem( $1->loc, ReplItem::InputText, $1->data );
+ ReplItem *replItem = ReplItem::cons( $1->loc, ReplItem::InputText, $1->data );
replItemList->append( replItem );
};
@@ -821,7 +821,7 @@ string_el_list: ;
# };
string_el: code_expr
final {
- ReplItem *replItem = new ReplItem( $1->expr->loc, ReplItem::ExprType, $1->expr );
+ ReplItem *replItem = ReplItem::cons( $1->expr->loc, ReplItem::ExprType, $1->expr );
replItemList->append( replItem );
};
@@ -978,7 +978,7 @@ literal_item: opt_no_ignore TK_Literal opt_no_ignore
else {
Join *join = new Join( Expression::cons( Term::cons( FactorWithAug::cons(
FactorWithRep::cons( $2->loc, FactorWithNeg::cons( $2->loc, Factor::cons(
- new Literal( $2->loc, $2->data,
+ Literal::cons( $2->loc, $2->data,
Literal::LitString ) ) ) ) ) ) ) );
if ( strcmp( interp.data, "" ) == 0 ) {
@@ -1445,7 +1445,7 @@ statement: var_ref TK_LtLt accumulate
final {
Namespace *nspace = namespaceStack.top();
TokenRegion *region = regionStack.top();
- ParserText *parserText = new ParserText( $2->loc, nspace, region, replItemList );
+ ParserText *parserText = ParserText::cons( $2->loc, nspace, region, replItemList );
pd->parserTextList.append( parserText );
$$->stmt = LangStmt::cons( LangStmt::ParserType, $1->varRef, parserText );
@@ -1454,7 +1454,7 @@ statement: KW_Send var_ref accumulate
final {
Namespace *nspace = namespaceStack.top();
TokenRegion *region = regionStack.top();
- ParserText *parserText = new ParserText( $1->loc, nspace, region, replItemList );
+ ParserText *parserText = ParserText::cons( $1->loc, nspace, region, replItemList );
pd->parserTextList.append( parserText );
$$->stmt = LangStmt::cons( LangStmt::ParserType, $2->varRef, parserText );
@@ -1479,7 +1479,7 @@ require_pattern:
final {
Namespace *nspace = namespaceStack.top();
TokenRegion *region = regionStack.top();
- Pattern *pattern = new Pattern( $1->loc, nspace, region,
+ Pattern *pattern = Pattern::cons( $1->loc, nspace, region,
patternItemList, pd->nextPatReplId++ );
pd->patternList.append( pattern );
@@ -1819,7 +1819,7 @@ code_factor: KW_Match var_ref pattern_list
final {
Namespace *nspace = namespaceStack.top();
TokenRegion *region = regionStack.top();
- Pattern *pattern = new Pattern( $1->loc, nspace, region,
+ Pattern *pattern = Pattern::cons( $1->loc, nspace, region,
patternItemList, pd->nextPatReplId++ );
pd->patternList.append( pattern );
@@ -1834,7 +1834,7 @@ code_factor:
final {
Namespace *nspace = namespaceStack.top();
TokenRegion *region = regionStack.top();
- Replacement *replacement = new Replacement( $1->loc, nspace, region,
+ Replacement *replacement = Replacement::cons( $1->loc, nspace, region,
replItemList, pd->nextPatReplId++ );
pd->replList.append( replacement );
@@ -1871,7 +1871,7 @@ code_factor: KW_Parse opt_capture type_ref '(' opt_code_expr_list ')'
TypeRef *parserTypeRef = TypeRef::cons( TypeRef::Parser,
InputLoc(), nspaceQual, $3->typeRef, 0 );
- Replacement *replacement = new Replacement( $1->loc, nspace, pd->rootRegion,
+ Replacement *replacement = Replacement::cons( $1->loc, nspace, pd->rootRegion,
new ReplItemList, pd->nextPatReplId++ );
pd->replList.append( replacement );
@@ -1910,7 +1910,7 @@ code_factor: KW_ParseStop opt_capture type_ref '(' opt_code_expr_list ')'
TypeRef *parserTypeRef = TypeRef::cons( TypeRef::Parser,
InputLoc(), nspaceQual, $3->typeRef, 0 );
- Replacement *replacement = new Replacement( $1->loc, nspace, pd->rootRegion,
+ Replacement *replacement = Replacement::cons( $1->loc, nspace, pd->rootRegion,
new ReplItemList, pd->nextPatReplId++ );
pd->replList.append( replacement );
@@ -2044,7 +2044,7 @@ opt_rl_join: rl_join opt_context
if ( $2->context != 0 ) {
/* Create the enter and leaving actions that will mark the substring. */
- Action *mark = new Action( MarkMark, pd->nextMatchEndNum++ );
+ Action *mark = Action::cons( MarkMark, pd->nextMatchEndNum++ );
pd->actionList.append( mark );
$$->join->context = $2->context;
@@ -2182,8 +2182,8 @@ factor_with_label:
pd->objectDef->insertField( $1->data, objField );
/* Create the enter and leaving actions that will mark the substring. */
- Action *enter = new Action( MarkMark, pd->nextMatchEndNum++ );
- Action *leave = new Action( MarkMark, pd->nextMatchEndNum++ );
+ Action *enter = Action::cons( MarkMark, pd->nextMatchEndNum++ );
+ Action *leave = Action::cons( MarkMark, pd->nextMatchEndNum++ );
pd->actionList.append( enter );
pd->actionList.append( leave );
@@ -2323,12 +2323,12 @@ nonterm rl_factor
rl_factor:
TK_Literal final {
/* Create a new factor node going to a concat literal. */
- $$->factor = Factor::cons( new Literal( $1->loc, $1->data, Literal::LitString ) );
+ $$->factor = Factor::cons( Literal::cons( $1->loc, $1->data, Literal::LitString ) );
};
rl_factor:
alphabet_num final {
/* Create a new factor node going to a literal number. */
- $$->factor = Factor::cons( new Literal( $1->loc,
+ $$->factor = Factor::cons( Literal::cons( $1->loc,
$1->data, Literal::Number ) );
};
rl_factor:
@@ -2364,17 +2364,17 @@ rl_factor:
rl_factor:
TK_SqOpen regular_expr_or_data TK_SqClose final {
/* Create a new factor node going to an OR expression. */
- $$->factor = Factor::cons( new ReItem( $1->loc, $2->reOrBlock, ReItem::OrBlock ) );
+ $$->factor = Factor::cons( ReItem::cons( $1->loc, $2->reOrBlock, ReItem::OrBlock ) );
};
rl_factor:
TK_SqOpenNeg regular_expr_or_data TK_SqClose final {
/* Create a new factor node going to a negated OR expression. */
- $$->factor = Factor::cons( new ReItem( $1->loc, $2->reOrBlock, ReItem::NegOrBlock ) );
+ $$->factor = Factor::cons( ReItem::cons( $1->loc, $2->reOrBlock, ReItem::NegOrBlock ) );
};
rl_factor:
range_lit TK_DotDot range_lit final {
/* Create a new factor node going to a range. */
- $$->factor = Factor::cons( new Range( $1->literal, $3->literal ) );
+ $$->factor = Factor::cons( Range::cons( $1->literal, $3->literal ) );
};
rl_factor:
'(' rl_join ')' final {
@@ -2391,12 +2391,12 @@ nonterm range_lit
range_lit:
TK_Literal final {
/* Range literas must have only one char. We restrict this in the parse tree. */
- $$->literal = new Literal( $1->loc, $1->data, Literal::LitString );
+ $$->literal = Literal::cons( $1->loc, $1->data, Literal::LitString );
};
range_lit:
alphabet_num final {
/* Create a new literal number. */
- $$->literal = new Literal( $1->loc, $1->data, Literal::Number );
+ $$->literal = Literal::cons( $1->loc, $1->data, Literal::Number );
};
nonterm alphabet_num uses token_data;
@@ -2449,7 +2449,7 @@ regular_expr_or_data:
}
else {
/* Can't optimize, put the left and right under a new node. */
- $$->reOrBlock = new ReOrBlock( $1->reOrBlock, $2->reOrItem );
+ $$->reOrBlock = ReOrBlock::cons( $1->reOrBlock, $2->reOrItem );
}
};
regular_expr_or_data:
@@ -2466,11 +2466,11 @@ nonterm regular_expr_or_char
regular_expr_or_char:
TK_ReChar final {
- $$->reOrItem = new ReOrItem( $1->loc, $1->data );
+ $$->reOrItem = ReOrItem::cons( $1->loc, $1->data );
};
regular_expr_or_char:
TK_ReChar TK_Dash TK_ReChar final {
- $$->reOrItem = new ReOrItem( $2->loc, $1->data[0], $3->data[0] );
+ $$->reOrItem = ReOrItem::cons( $2->loc, $1->data[0], $3->data[0] );
};
# A local state reference. Cannot have :: prefix.
diff --git a/src/parsedata.h b/src/parsedata.h
index 79ba08c1..66437422 100644
--- a/src/parsedata.h
+++ b/src/parsedata.h
@@ -349,41 +349,43 @@ struct Action
{
public:
- Action( const InputLoc &loc, const String &name, InlineList *inlineList )
- :
- loc(loc),
- name(name),
- markType(MarkNone),
- objField(0),
- markId(-1),
- inlineList(inlineList),
- actionId(-1),
- numTransRefs(0),
- numToStateRefs(0),
- numFromStateRefs(0),
- numEofRefs(0),
- numCondRefs(0),
- anyCall(false),
- isLmAction(false)
+ static Action *cons( const InputLoc &loc, const String &name, InlineList *inlineList )
{
+ Action *a = new Action;
+ a->loc = (loc);
+ a->name = (name);
+ a->markType = (MarkNone);
+ a->objField = (0);
+ a->markId = (-1);
+ a->inlineList = (inlineList);
+ a->actionId = (-1);
+ a->numTransRefs = (0);
+ a->numToStateRefs = (0);
+ a->numFromStateRefs = (0);
+ a->numEofRefs = (0);
+ a->numCondRefs = (0);
+ a->anyCall = (false);
+ a->isLmAction = (false);
+ return a;
}
- Action( MarkType markType, long markId )
- :
- name("mark"),
- markType(markType),
- objField(0),
- markId(markId),
- inlineList(new InlineList),
- actionId(-1),
- numTransRefs(0),
- numToStateRefs(0),
- numFromStateRefs(0),
- numEofRefs(0),
- numCondRefs(0),
- anyCall(false),
- isLmAction(false)
+ static Action *cons( MarkType markType, long markId )
{
+ Action *a = new Action;
+ a->name = ("mark");
+ a->markType = (markType);
+ a->objField = (0);
+ a->markId = (markId);
+ a->inlineList = (InlineList::cons());
+ a->actionId = (-1);
+ a->numTransRefs = (0);
+ a->numToStateRefs = (0);
+ a->numFromStateRefs = (0);
+ a->numEofRefs = (0);
+ a->numCondRefs = (0);
+ a->anyCall = (false);
+ a->isLmAction = (false);
+ return a;
}
/* Key for action dictionary. */
diff --git a/src/parsetree.cc b/src/parsetree.cc
index 084ffbb8..ddd0f15d 100644
--- a/src/parsetree.cc
+++ b/src/parsetree.cc
@@ -271,7 +271,7 @@ InputLoc TokenDef::getLoc()
Action *TokenRegion::newAction( Compiler *pd, const InputLoc &loc,
const String &name, InlineList *inlineList )
{
- Action *action = new Action( loc, name, inlineList );
+ Action *action = Action::cons( loc, name, inlineList );
pd->actionList.append( action );
action->isLmAction = true;
return action;
@@ -283,8 +283,8 @@ void TokenRegion::makeActions( Compiler *pd )
for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
- InlineList *inlineList = new InlineList;
- inlineList->append( new InlineItem( lmi->getLoc(), this, lmi,
+ InlineList *inlineList = InlineList::cons();
+ inlineList->append( InlineItem::cons( lmi->getLoc(), this, lmi,
InlineItem::LmSetActId ) );
char *actName = new char[50];
sprintf( actName, "store%i", lmi->longestMatchId );
@@ -295,8 +295,8 @@ void TokenRegion::makeActions( Compiler *pd )
for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
- InlineList *inlineList = new InlineList;
- inlineList->append( new InlineItem( lmi->getLoc(), this, lmi,
+ InlineList *inlineList = InlineList::cons();
+ inlineList->append( InlineItem::cons( lmi->getLoc(), this, lmi,
InlineItem::LmOnLast ) );
char *actName = new char[50];
sprintf( actName, "imm%i", lmi->longestMatchId );
@@ -309,8 +309,8 @@ void TokenRegion::makeActions( Compiler *pd )
for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
- InlineList *inlineList = new InlineList;
- inlineList->append( new InlineItem( lmi->getLoc(), this, lmi,
+ InlineList *inlineList = InlineList::cons();
+ inlineList->append( InlineItem::cons( lmi->getLoc(), this, lmi,
InlineItem::LmOnNext ) );
char *actName = new char[50];
sprintf( actName, "lagh%i", lmi->longestMatchId );
@@ -322,8 +322,8 @@ void TokenRegion::makeActions( Compiler *pd )
for ( TokenDefListReg::Iter lmi = tokenDefList; lmi.lte(); lmi++ ) {
/* For each part create actions for setting the match type. We need
* to do this so that the actions will go into the actionIndex. */
- InlineList *inlineList = new InlineList;
- inlineList->append( new InlineItem( lmi->getLoc(), this, lmi,
+ InlineList *inlineList = InlineList::cons();
+ inlineList->append( InlineItem::cons( lmi->getLoc(), this, lmi,
InlineItem::LmOnLagBehind ) );
char *actName = new char[50];
sprintf( actName, "lag%i", lmi->longestMatchId );
@@ -335,8 +335,8 @@ void TokenRegion::makeActions( Compiler *pd )
loc.col = 1;
/* Create the error action. */
- InlineList *il6 = new InlineList;
- il6->append( new InlineItem( loc, this, 0, InlineItem::LmSwitch ) );
+ InlineList *il6 = InlineList::cons();
+ il6->append( InlineItem::cons( loc, this, 0, InlineItem::LmSwitch ) );
lmActSelect = newAction( pd, loc, "lagsel", il6 );
}
diff --git a/src/parsetree.h b/src/parsetree.h
index 45bc5b13..9dee081d 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -1168,8 +1168,13 @@ struct Factor
/* A range machine. Only ever composed of two literals. */
struct Range
{
- Range( Literal *lowerLit, Literal *upperLit )
- : lowerLit(lowerLit), upperLit(upperLit) { }
+ static Range *cons( Literal *lowerLit, Literal *upperLit )
+ {
+ Range *r = new Range;
+ r->lowerLit = (lowerLit);
+ r->upperLit = (upperLit);
+ return r;
+ }
~Range();
FsmGraph *walk( Compiler *pd );
@@ -1184,8 +1189,14 @@ struct Literal
{
enum LiteralType { Number, LitString };
- Literal( const InputLoc &loc, const String &literal, LiteralType type )
- : loc(loc), literal(literal), type(type) { }
+ static Literal *cons( const InputLoc &loc, const String &literal, LiteralType type )
+ {
+ Literal *l = new Literal;
+ l->loc = (loc);
+ l->literal = (literal);
+ l->type = (type);
+ return l;
+ }
FsmGraph *walk( Compiler *pd );
@@ -1200,11 +1211,23 @@ struct RegExpr
enum RegExpType { RecurseItem, Empty };
/* Constructors. */
- RegExpr() :
- type(Empty), caseInsensitive(false) { }
- RegExpr(RegExpr *regExp, ReItem *item) :
- regExp(regExp), item(item),
- type(RecurseItem), caseInsensitive(false) { }
+ static RegExpr *cons()
+ {
+ RegExpr *r = new RegExpr;
+ r->type = (Empty);
+ r->caseInsensitive = (false);
+ return r;
+ }
+
+ static RegExpr *cons( RegExpr *regExp, ReItem *item )
+ {
+ RegExpr *r = new RegExpr;
+ r->regExp = (regExp);
+ r->item = (item);
+ r->type = (RecurseItem);
+ r->caseInsensitive = (false);
+ return r;
+ }
~RegExpr();
FsmGraph *walk( Compiler *pd, RegExpr *rootRegex );
@@ -1220,12 +1243,34 @@ struct ReItem
{
enum ReItemType { Data, Dot, OrBlock, NegOrBlock };
- ReItem( const InputLoc &loc, const String &data )
- : loc(loc), data(data), star(false), type(Data) { }
- ReItem( const InputLoc &loc, ReItemType type )
- : loc(loc), star(false), type(type) { }
- ReItem( const InputLoc &loc, ReOrBlock *orBlock, ReItemType type )
- : loc(loc), orBlock(orBlock), star(false), type(type) { }
+ static ReItem *cons( const InputLoc &loc, const String &data )
+ {
+ ReItem *r = new ReItem;
+ r->loc = (loc);
+ r->data = (data);
+ r->star = (false);
+ r->type = (Data);
+ return r;
+ }
+
+ static ReItem *cons( const InputLoc &loc, ReItemType type )
+ {
+ ReItem *r = new ReItem;
+ r->loc = (loc);
+ r->star = (false);
+ r->type = (type);
+ return r;
+ }
+
+ static ReItem *cons( const InputLoc &loc, ReOrBlock *orBlock, ReItemType type )
+ {
+ ReItem *r = new ReItem;
+ r->loc = (loc);
+ r->orBlock = (orBlock);
+ r->star = (false);
+ r->type = (type);
+ return r;
+ }
~ReItem();
FsmGraph *walk( Compiler *pd, RegExpr *rootRegex );
@@ -1243,10 +1288,21 @@ struct ReOrBlock
enum ReOrBlockType { RecurseItem, Empty };
/* Constructors. */
- ReOrBlock()
- : type(Empty) { }
- ReOrBlock(ReOrBlock *orBlock, ReOrItem *item)
- : orBlock(orBlock), item(item), type(RecurseItem) { }
+ static ReOrBlock *cons()
+ {
+ ReOrBlock *r = new ReOrBlock;
+ r->type = (Empty);
+ return r;
+ }
+
+ static ReOrBlock *cons( ReOrBlock *orBlock, ReOrItem *item )
+ {
+ ReOrBlock *r = new ReOrBlock;
+ r->orBlock = (orBlock);
+ r->item = (item);
+ r->type = (RecurseItem);
+ return r;
+ }
~ReOrBlock();
FsmGraph *walk( Compiler *pd, RegExpr *rootRegex );
@@ -1261,10 +1317,24 @@ struct ReOrItem
{
enum ReOrItemType { Data, Range };
- ReOrItem( const InputLoc &loc, const String &data )
- : loc(loc), data(data), type(Data) {}
- ReOrItem( const InputLoc &loc, char lower, char upper )
- : loc(loc), lower(lower), upper(upper), type(Range) { }
+ static ReOrItem *cons( const InputLoc &loc, const String &data )
+ {
+ ReOrItem *r = new ReOrItem;
+ r->loc = (loc);
+ r->data = (data);
+ r->type = (Data);
+ return r;
+ }
+
+ static ReOrItem *cons( const InputLoc &loc, char lower, char upper )
+ {
+ ReOrItem *r = new ReOrItem;
+ r->loc = (loc);
+ r->lower = (lower);
+ r->upper = (upper);
+ r->type = (Range);
+ return r;
+ }
FsmGraph *walk( Compiler *pd, RegExpr *rootRegex );
@@ -1296,23 +1366,60 @@ struct InlineItem
LmSetTokStart
};
- InlineItem( const InputLoc &loc, const String &data, Type type ) :
- loc(loc), data(data), nameRef(0), children(0), type(type) { }
+ static InlineItem *cons( const InputLoc &loc, const String &data, Type type )
+ {
+ InlineItem *i = new InlineItem;
+ i->loc = (loc);
+ i->data = (data);
+ i->nameRef = (0);
+ i->children = (0);
+ i->type = (type);
+ return i;
+ }
- InlineItem( const InputLoc &loc, NameRef *nameRef, Type type ) :
- loc(loc), nameRef(nameRef), children(0), type(type) { }
+ static InlineItem *cons( const InputLoc &loc, NameRef *nameRef, Type type )
+ {
+ InlineItem *i = new InlineItem;
+ i->loc = (loc);
+ i->nameRef = (nameRef);
+ i->children = (0);
+ i->type = (type);
+ return i;
+ }
- InlineItem( const InputLoc &loc, TokenRegion *tokenRegion,
- TokenDef *longestMatchPart, Type type ) : loc(loc),
- nameRef(0), children(0), tokenRegion(tokenRegion),
- longestMatchPart(longestMatchPart), type(type) { }
+ static InlineItem *cons( const InputLoc &loc, TokenRegion *tokenRegion,
+ TokenDef *longestMatchPart, Type type )
+ {
+ InlineItem *i = new InlineItem;
+ i->loc = (loc);
+ i->nameRef = (0);
+ i->children = (0);
+ i->tokenRegion = (tokenRegion);
+ i->longestMatchPart = (longestMatchPart);
+ i->type = (type);
+ return i;
+ }
- InlineItem( const InputLoc &loc, NameInst *nameTarg, Type type ) :
- loc(loc), nameRef(0), nameTarg(nameTarg), children(0),
- type(type) { }
+ static InlineItem *cons( const InputLoc &loc, NameInst *nameTarg, Type type )
+ {
+ InlineItem *i = new InlineItem;
+ i->loc = (loc);
+ i->nameRef = (0);
+ i->nameTarg = (nameTarg);
+ i->children = (0);
+ i->type = (type);
+ return i;
+ }
- InlineItem( const InputLoc &loc, Type type ) :
- loc(loc), nameRef(0), children(0), type(type) { }
+ static InlineItem *cons( const InputLoc &loc, Type type )
+ {
+ InlineItem *i = new InlineItem;
+ i->loc = (loc);
+ i->nameRef = (0);
+ i->children = (0);
+ i->type = (type);
+ return i;
+ }
InputLoc loc;
String data;
@@ -1326,9 +1433,18 @@ struct InlineItem
InlineItem *prev, *next;
};
-/* Normally this would be atypedef, but that would entail including DList from
- * ptreetypes, which should be just typedef forwards. */
-struct InlineList : public DList<InlineItem> { };
+struct InlineList
+:
+ public DList<InlineItem>
+{
+ InlineList( int i ) {}
+
+ static InlineList *cons()
+ {
+ return new InlineList( 0 );
+ }
+};
+
struct ProdEl;
struct LangVarRef;
@@ -1341,13 +1457,30 @@ struct PatternItem
InputText
};
- PatternItem( const InputLoc &loc, const String &data, Type type ) :
- loc(loc), factor(0), data(data), type(type), region(0),
- varRef(0), bindId(0) {}
+ static PatternItem *cons( const InputLoc &loc, const String &data, Type type )
+ {
+ PatternItem *p = new PatternItem;
+ p->loc = (loc);
+ p->factor = (0);
+ p->data = (data);
+ p->type = (type);
+ p->region = (0);
+ p->varRef = (0);
+ p->bindId = (0);
+ return p;
+ }
- PatternItem( const InputLoc &loc, ProdEl *factor, Type type ) :
- loc(loc), factor(factor), type(type), region(0),
- varRef(0), bindId(0) {}
+ static PatternItem *cons( const InputLoc &loc, ProdEl *factor, Type type )
+ {
+ PatternItem *p = new PatternItem;
+ p->loc = (loc);
+ p->factor = (factor);
+ p->type = (type);
+ p->region = (0);
+ p->varRef = (0);
+ p->bindId = (0);
+ return p;
+ }
InputLoc loc;
ProdEl *factor;
@@ -1356,7 +1489,6 @@ struct PatternItem
TokenRegion *region;
LangVarRef *varRef;
long bindId;
-
PatternItem *prev, *next;
};
@@ -1371,14 +1503,33 @@ struct ReplItem
FactorType
};
- ReplItem( const InputLoc &loc, Type type, const String &data ) :
- loc(loc), type(type), data(data), expr(0), bindId(0) {}
+ static ReplItem *cons( const InputLoc &loc, Type type, const String &data )
+ {
+ ReplItem *r = new ReplItem;
+ r->loc = (loc);
+ r->type = (type);
+ r->data = (data);
+ return r;
+ }
- ReplItem( const InputLoc &loc, Type type, LangExpr *expr ) :
- loc(loc), type(type), expr(expr), bindId(0) {}
+ static ReplItem *cons( const InputLoc &loc, Type type, LangExpr *expr )
+ {
+ ReplItem *r = new ReplItem;
+ r->loc = (loc);
+ r->type = (type);
+ r->expr = (expr);
+ return r;
+ }
- ReplItem( const InputLoc &loc, Type type, ProdEl *factor ) :
- loc(loc), type(type), expr(expr), factor(factor), bindId(0) {}
+ static ReplItem *cons( const InputLoc &loc, Type type, ProdEl *factor )
+ {
+ ReplItem *r = new ReplItem;
+ r->loc = (loc);
+ r->type = (type);
+ r->expr = (0);
+ r->factor = (factor);
+ return r;
+ }
InputLoc loc;
Type type;
@@ -1387,19 +1538,27 @@ struct ReplItem
LangEl *langEl;
ProdEl *factor;
long bindId;
-
ReplItem *prev, *next;
};
typedef DList<ReplItem> ReplItemList;
-
struct Pattern
{
- Pattern( const InputLoc &loc, Namespace *nspace, TokenRegion *region,
- PatternItemList *list, int patRepId ) :
- loc(loc), nspace(nspace), region(region), list(list), patRepId(patRepId),
- langEl(0), pdaRun(0), nextBindId(1) {}
+ static Pattern *cons( const InputLoc &loc, Namespace *nspace, TokenRegion *region,
+ PatternItemList *list, int patRepId )
+ {
+ Pattern *p = new Pattern;
+ p->loc = (loc);
+ p->nspace = (nspace);
+ p->region = (region);
+ p->list = (list);
+ p->patRepId = (patRepId);
+ p->langEl = (0);
+ p->pdaRun = (0);
+ p->nextBindId = (1);
+ return p;
+ }
InputLoc loc;
Namespace *nspace;
@@ -1409,7 +1568,6 @@ struct Pattern
LangEl *langEl;
PdaRun *pdaRun;
long nextBindId;
-
Pattern *prev, *next;
};
@@ -1417,10 +1575,21 @@ typedef DList<Pattern> PatternList;
struct Replacement
{
- Replacement( const InputLoc &loc, Namespace *nspace,
- TokenRegion *region, ReplItemList *list, int patRepId ) :
- loc(loc), nspace(nspace), region(region), list(list),
- patRepId(patRepId), langEl(0), pdaRun(0), nextBindId(1), parse(true) {}
+ static Replacement *cons( const InputLoc &loc, Namespace *nspace,
+ TokenRegion *region, ReplItemList *list, int patRepId )
+ {
+ Replacement *r = new Replacement;
+ r->loc = (loc);
+ r->nspace = (nspace);
+ r->region = (region);
+ r->list = (list);
+ r->patRepId = (patRepId);
+ r->langEl = (0);
+ r->pdaRun = (0);
+ r->nextBindId = (1);
+ r->parse = (true);
+ return r;
+ }
InputLoc loc;
Namespace *nspace;
@@ -1439,10 +1608,20 @@ typedef DList<Replacement> ReplList;
struct ParserText
{
- ParserText( const InputLoc &loc, Namespace *nspace,
- TokenRegion *region, ReplItemList *list ) :
- loc(loc), nspace(nspace), region(region), list(list),
- langEl(0), pdaRun(0), nextBindId(1), parse(true) {}
+ static ParserText *cons( const InputLoc &loc, Namespace *nspace,
+ TokenRegion *region, ReplItemList *list )
+ {
+ ParserText *p = new ParserText;
+ p->loc = (loc);
+ p->nspace = (nspace);
+ p->region = (region);
+ p->list = (list);
+ p->langEl = (0);
+ p->pdaRun = (0);
+ p->nextBindId = (1);
+ p->parse = (true);
+ return p;
+ }
InputLoc loc;
Namespace *nspace;
@@ -1452,7 +1631,6 @@ struct ParserText
PdaRun *pdaRun;
long nextBindId;
bool parse;
-
ParserText *prev, *next;
};