summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-07-16 16:17:10 -0400
committerAdrian Thurston <thurston@complang.org>2012-07-16 16:17:10 -0400
commit6d0a84f5ff7c3b298424a771c36792a9de2154fc (patch)
tree048d56f661959f02b5b6bcab2308328ff28c05cf
parent0cfd35f7dc13f3aef71ab7f05fb4da8330118939 (diff)
downloadcolm-6d0a84f5ff7c3b298424a771c36792a9de2154fc.tar.gz
minor cleanup around parsing
-rw-r--r--src/lmparse.kl27
-rw-r--r--src/lmscan.rl6
-rw-r--r--src/parsetree.h2
-rw-r--r--src/resolve.cc2
-rw-r--r--src/synthesis.cc2
5 files changed, 19 insertions, 20 deletions
diff --git a/src/lmparse.kl b/src/lmparse.kl
index 98ccac8d..640c1e57 100644
--- a/src/lmparse.kl
+++ b/src/lmparse.kl
@@ -724,7 +724,6 @@ repl_el: region_qual TK_Literal
ReplItem *replItem = ReplItem::cons( $2->loc, ReplItem::FactorType, factor );
replItemList->append( replItem );
};
-repl_el: '"' lit_repl_el_list '"';
repl_el: code_expr
final {
@@ -732,6 +731,8 @@ repl_el: code_expr
replItemList->append( replItem );
};
+repl_el: '"' lit_repl_el_list '"';
+
#
# Accumulate List
#
@@ -803,14 +804,6 @@ lit_string_el: '[' string_el_list ']';
string_el_list: string_el_list string_el;
string_el_list: ;
-#accum_el: region_qual TK_Literal
-# final {
-# PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 );
-# ProdEl *factor = new ProdEl( $2->loc, false, $1->nspaceQual,
-# literal, 0 );
-# ReplItem *replItem = new ReplItem( $2->loc, ReplItem::FactorType, factor );
-# replItemList->append( replItem );
-# };
string_el: code_expr
final {
ReplItem *replItem = ReplItem::cons( $1->expr->loc, ReplItem::ExprType, $1->expr );
@@ -819,6 +812,10 @@ string_el: code_expr
string_el: '"' lit_string_el_list '"';
+#
+# Production Lists.
+#
+
prod_el_list:
prod_el_list prod_el
final {
@@ -1832,7 +1829,7 @@ code_factor:
}
};
code_factor:
- KW_Parse opt_capture type_ref opt_field_init accumulate
+ KW_Parse opt_capture type_ref accumulate
final {
Namespace *nspace = namespaceStack.top();
TokenRegion *region = regionStack.top();
@@ -1855,8 +1852,8 @@ code_factor:
ParserText *parserText = ParserText::cons( $2->loc, nspace, region, replItemList );
pd->parserTextList.append( parserText );
- $$->expr = LangExpr::cons( LangTerm::cons( $1->loc, LangTerm::Parse2Type,
- varRef, $2->objField, parserTypeRef, $4->fieldInitVect, replacement, parserText ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc, LangTerm::ParseType,
+ varRef, $2->objField, parserTypeRef, 0, replacement, parserText ) );
/* Check for redeclaration. */
if ( $2->objField != 0 ) {
@@ -1870,7 +1867,8 @@ code_factor:
pd->curLocalFrame->insertField( $2->objField->name, $2->objField );
}
};
-code_factor: KW_Parse opt_capture type_ref '(' opt_code_expr_list ')'
+code_factor:
+ KW_Parse opt_capture type_ref '(' opt_code_expr_list ')'
final {
String parserName = $3->typeRef->typeName + "_parser";
@@ -1908,7 +1906,8 @@ code_factor: KW_Parse opt_capture type_ref '(' opt_code_expr_list ')'
pd->curLocalFrame->insertField( $2->objField->name, $2->objField );
}
};
-code_factor: KW_ParseStop opt_capture type_ref '(' opt_code_expr_list ')'
+code_factor:
+ KW_ParseStop opt_capture type_ref '(' opt_code_expr_list ')'
final {
/* This is a silly clone. To be fixed later. */
String parserName = $3->typeRef->typeName + "_parser";
diff --git a/src/lmscan.rl b/src/lmscan.rl
index 070a1e66..583c62e6 100644
--- a/src/lmscan.rl
+++ b/src/lmscan.rl
@@ -285,7 +285,7 @@ void ColmScanner::endSection( )
}
%%{
- machine rlscan;
+ machine lmscan;
# This is sent by the driver code.
EOF = 0;
@@ -532,7 +532,7 @@ void ColmScanner::endSection( )
'||' => { token( TK_BarBar ); };
'<<' => { token( TK_LtLt ); };
- ('+' | '-' | '*' | '/' | '(' | ')' | '@' | '$' | '^' ) => { token( *ts ); };
+ ( '+' | '-' | '*' | '/' | '(' | ')' | '@' | '$' | '^' ) => { token( *ts ); };
# Whitespace other than newline.
@@ -598,7 +598,7 @@ void ColmScanner::scan()
%% write exec;
/* Check if we failed. */
- if ( cs == rlscan_error ) {
+ if ( cs == lmscan_error ) {
/* Machine failed before finding a token. I'm not yet sure if this
* is reachable. */
scan_error() << "colm scanner error (metalanguage)" << endl;
diff --git a/src/parsetree.h b/src/parsetree.h
index 0701cf1d..37ab2def 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -2341,7 +2341,7 @@ struct LangTerm
* parse error if present. */
OrigParseType,
OrigParseStopType,
- Parse2Type,
+ ParseType,
SendType,
MakeTreeType,
MakeTokenType,
diff --git a/src/resolve.cc b/src/resolve.cc
index 7ca06203..6df73cba 100644
--- a/src/resolve.cc
+++ b/src/resolve.cc
@@ -370,7 +370,7 @@ void LangTerm::resolve( Compiler *pd )
generic = parserTypeRef->generic;
break;
- case Parse2Type:
+ case ParseType:
typeRef->lookupType( pd );
/* Evaluate the initialization expressions. */
if ( fieldInitArgs != 0 ) {
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 88bdf00c..09ce2389 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -1731,7 +1731,7 @@ UniqueType *LangTerm::evaluate( Compiler *pd, CodeVect &code ) const
return evaluateParse( pd, code, true );
case ConstructType:
return evaluateConstruct( pd, code );
- case Parse2Type:
+ case ParseType:
return evaluateParse2( pd, code );
case SendType:
return evaluateSend( pd, code );