summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-05-20 14:22:35 -0400
committerAdrian Thurston <thurston@complang.org>2013-05-20 14:22:35 -0400
commit95fde45b0b7bb9026108b8bf4f95ccdbbf098467 (patch)
tree8f1f6371f40f3ecb7059af3accddeaa2b932e0f1
parent26dd574284aecedaada76026817bd1d66117bcc6 (diff)
downloadcolm-95fde45b0b7bb9026108b8bf4f95ccdbbf098467.tar.gz
more use of production names
-rw-r--r--colm/colm.lm38
-rw-r--r--colm/loadcolm.cc93
2 files changed, 66 insertions, 65 deletions
diff --git a/colm/colm.lm b/colm/colm.lm
index 59e77161..e925c597 100644
--- a/colm/colm.lm
+++ b/colm/colm.lm
@@ -652,10 +652,10 @@ def qual
#
def lex_expr
- [Expr: lex_expr Bar: LEX_BAR Term: lex_term] :Bar
-| [Expr: lex_expr Amp: LEX_AMP Term: lex_term] :Amp
-| [Expr: lex_expr Dash: LEX_DASH Term: lex_term] :Dash
-| [Expr: lex_expr DashDash: LEX_DASHDASH Term: lex_term] :DashDash
+ [Expr: lex_expr LEX_BAR Term: lex_term] :Bar
+| [Expr: lex_expr LEX_AMP Term: lex_term] :Amp
+| [Expr: lex_expr LEX_DASH Term: lex_term] :Dash
+| [Expr: lex_expr LEX_DASHDASH Term: lex_term] :DashDash
| [Term: lex_term] :Base
def opt_lex_dot
@@ -663,26 +663,26 @@ def opt_lex_dot
| []
def lex_term
- [Term: lex_term OptDot: opt_lex_dot FactorRep: lex_factor_rep] :Dot
-| [Term: lex_term ColonGt: LEX_COLON_GT FactorRep: lex_factor_rep] :ColonGt
-| [Term: lex_term ColonGtGt: LEX_COLON_GTGT FactorRep: lex_factor_rep] :ColonGtGt
-| [Term: lex_term LtColon: LEX_LT_COLON FactorRep: lex_factor_rep] :LtColon
+ [Term: lex_term opt_lex_dot FactorRep: lex_factor_rep] :Dot
+| [Term: lex_term LEX_COLON_GT FactorRep: lex_factor_rep] :ColonGt
+| [Term: lex_term LEX_COLON_GTGT FactorRep: lex_factor_rep] :ColonGtGt
+| [Term: lex_term LEX_LT_COLON FactorRep: lex_factor_rep] :LtColon
| [FactorRep: lex_factor_rep] :Base
def lex_factor_rep
- [FactorRep: lex_factor_rep Star: LEX_STAR]
-| [FactorRep: lex_factor_rep StarStar: LEX_STARSTAR]
-| [FactorRep: lex_factor_rep Plus: LEX_PLUS]
-| [FactorRep: lex_factor_rep Question: LEX_QUESTION]
-| [FactorRep: lex_factor_rep COPEN Exact: lex_uint CCLOSE ]
-| [FactorRep: lex_factor_rep COPEN COMMA Max: lex_uint CCLOSE ]
-| [FactorRep: lex_factor_rep COPEN Min: lex_uint COMMA CCLOSE ]
-| [FactorRep: lex_factor_rep COPEN Low: lex_uint COMMA High: lex_uint CCLOSE ]
-| [FactorNeg: lex_factor_neg]
+ [FactorRep: lex_factor_rep Star: LEX_STAR] :Star
+| [FactorRep: lex_factor_rep StarStar: LEX_STARSTAR] :StarStar
+| [FactorRep: lex_factor_rep Plus: LEX_PLUS] :Plus
+| [FactorRep: lex_factor_rep Question: LEX_QUESTION] :Question
+| [FactorRep: lex_factor_rep COPEN Exact: lex_uint CCLOSE ] :Exact
+| [FactorRep: lex_factor_rep COPEN COMMA Max: lex_uint CCLOSE ] :Max
+| [FactorRep: lex_factor_rep COPEN Min: lex_uint COMMA CCLOSE ] :Min
+| [FactorRep: lex_factor_rep COPEN Low: lex_uint COMMA High: lex_uint CCLOSE ] :Range
+| [FactorNeg: lex_factor_neg] :Base
def lex_factor_neg
- [Caret: LEX_CARET FactorNeg: lex_factor_neg]
-| [Factor: lex_factor]
+ [LEX_CARET FactorNeg: lex_factor_neg] :Caret
+| [Factor: lex_factor] :Base
def lex_range_lit
[Lit: lex_lit]
diff --git a/colm/loadcolm.cc b/colm/loadcolm.cc
index 58fe2b3b..68727e25 100644
--- a/colm/loadcolm.cc
+++ b/colm/loadcolm.cc
@@ -816,80 +816,81 @@ struct LoadColm
}
- LexFactorNeg *walkLexFactorNeg( lex_factor_neg &LexFactorNegTree )
+ LexFactorNeg *walkLexFactorNeg( lex_factor_neg lexFactorNeg )
{
- if ( LexFactorNegTree.Caret() != 0 ) {
- lex_factor_neg Rec = LexFactorNegTree.FactorNeg();
- LexFactorNeg *recNeg = walkLexFactorNeg( Rec );
+ switch ( lexFactorNeg.prodName() ) {
+ case lex_factor_neg::_Caret: {
+ LexFactorNeg *recNeg = walkLexFactorNeg( lexFactorNeg.FactorNeg() );
LexFactorNeg *factorNeg = LexFactorNeg::cons( recNeg,
LexFactorNeg::CharNegateType );
return factorNeg;
}
- else {
- lex_factor LexFactorTree = LexFactorNegTree.Factor();
- LexFactor *factor = walkLexFactor( LexFactorTree );
+ case lex_factor_neg::_Base: {
+ LexFactor *factor = walkLexFactor( lexFactorNeg.Factor() );
LexFactorNeg *factorNeg = LexFactorNeg::cons( factor );
return factorNeg;
- }
+ }}
}
- LexFactorRep *walkLexFactorRep( lex_factor_rep LexFactorRepTree )
+ LexFactorRep *walkLexFactorRep( lex_factor_rep lexFactorRep )
{
LexFactorRep *factorRep = 0;
- if ( LexFactorRepTree.Star() != 0 ) {
- lex_factor_rep Rec = LexFactorRepTree.FactorRep();
- LexFactorRep *recRep = walkLexFactorRep( Rec );
- factorRep = LexFactorRep::cons( LexFactorRepTree.Star().loc(),
+ LexFactorRep *recRep = 0;
+ lex_factor_rep::prod_name pn = lexFactorRep.prodName();
+
+ if ( pn != lex_factor_rep::_Base )
+ recRep = walkLexFactorRep( lexFactorRep.FactorRep() );
+
+ switch ( pn ) {
+ case lex_factor_rep::_Star: {
+ factorRep = LexFactorRep::cons( lexFactorRep.Star().loc(),
recRep, 0, 0, LexFactorRep::StarType );
+ break;
}
- else if ( LexFactorRepTree.StarStar() != 0 ) {
- lex_factor_rep Rec = LexFactorRepTree.FactorRep();
- LexFactorRep *recRep = walkLexFactorRep( Rec );
- factorRep = LexFactorRep::cons( LexFactorRepTree.StarStar().loc(),
+ case lex_factor_rep::_StarStar: {
+ factorRep = LexFactorRep::cons( lexFactorRep.StarStar().loc(),
recRep, 0, 0, LexFactorRep::StarStarType );
+ break;
}
- else if ( LexFactorRepTree.Plus() != 0 ) {
- lex_factor_rep Rec = LexFactorRepTree.FactorRep();
- LexFactorRep *recRep = walkLexFactorRep( Rec );
- factorRep = LexFactorRep::cons( LexFactorRepTree.Plus().loc(),
+ case lex_factor_rep::_Plus: {
+ factorRep = LexFactorRep::cons( lexFactorRep.Plus().loc(),
recRep, 0, 0, LexFactorRep::PlusType );
+ break;
}
- else if ( LexFactorRepTree.Question() != 0 ) {
- lex_factor_rep Rec = LexFactorRepTree.FactorRep();
- LexFactorRep *recRep = walkLexFactorRep( Rec );
- factorRep = LexFactorRep::cons( LexFactorRepTree.Question().loc(),
+ case lex_factor_rep::_Question: {
+ factorRep = LexFactorRep::cons( lexFactorRep.Question().loc(),
recRep, 0, 0, LexFactorRep::OptionalType );
+ break;
}
- else if ( LexFactorRepTree.Exact() != 0 ) {
- LexFactorRep *recRep = walkLexFactorRep( LexFactorRepTree.FactorRep() );
- int low = atoi( LexFactorRepTree.Exact().text().c_str() );
- factorRep = LexFactorRep::cons( LexFactorRepTree.Exact().loc(),
+ case lex_factor_rep::_Exact: {
+ int low = atoi( lexFactorRep.Exact().text().c_str() );
+ factorRep = LexFactorRep::cons( lexFactorRep.Exact().loc(),
recRep, low, 0, LexFactorRep::ExactType );
+ break;
}
- else if ( LexFactorRepTree.Max() != 0 ) {
- LexFactorRep *recRep = walkLexFactorRep( LexFactorRepTree.FactorRep() );
- int high = atoi( LexFactorRepTree.Max().text().c_str() );
- factorRep = LexFactorRep::cons( LexFactorRepTree.Max().loc(),
+ case lex_factor_rep::_Max: {
+ int high = atoi( lexFactorRep.Max().text().c_str() );
+ factorRep = LexFactorRep::cons( lexFactorRep.Max().loc(),
recRep, 0, high, LexFactorRep::MaxType );
+ break;
}
- else if ( LexFactorRepTree.Min() != 0 ) {
- LexFactorRep *recRep = walkLexFactorRep( LexFactorRepTree.FactorRep() );
- int low = atoi( LexFactorRepTree.Min().text().c_str() );
- factorRep = LexFactorRep::cons( LexFactorRepTree.Min().loc(),
+ case lex_factor_rep::_Min: {
+ int low = atoi( lexFactorRep.Min().text().c_str() );
+ factorRep = LexFactorRep::cons( lexFactorRep.Min().loc(),
recRep, low, 0, LexFactorRep::MinType );
+ break;
}
- else if ( LexFactorRepTree.Low() != 0 ) {
- LexFactorRep *recRep = walkLexFactorRep( LexFactorRepTree.FactorRep() );
- int low = atoi( LexFactorRepTree.Low().text().c_str() );
- int high = atoi( LexFactorRepTree.High().text().c_str() );
- factorRep = LexFactorRep::cons( LexFactorRepTree.Low().loc(),
+ case lex_factor_rep::_Range: {
+ int low = atoi( lexFactorRep.Low().text().c_str() );
+ int high = atoi( lexFactorRep.High().text().c_str() );
+ factorRep = LexFactorRep::cons( lexFactorRep.Low().loc(),
recRep, low, high, LexFactorRep::RangeType );
+ break;
}
- else {
- lex_factor_neg LexFactorNegTree = LexFactorRepTree.FactorNeg();
- LexFactorNeg *factorNeg = walkLexFactorNeg( LexFactorNegTree );
+ case lex_factor_rep::_Base: {
+ LexFactorNeg *factorNeg = walkLexFactorNeg( lexFactorRep.FactorNeg() );
factorRep = LexFactorRep::cons( factorNeg );
- }
+ }}
return factorRep;
}