diff options
author | Adrian Thurston <thurston@colm.net> | 2018-05-07 11:54:29 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2018-05-07 11:54:29 -0400 |
commit | 7b441a6c7f2c9704b9d536a739f1b91893167df5 (patch) | |
tree | c3f76777deafd8b5dd010913202d19bc6afe2143 /src/loadcolm.cc | |
parent | ff797d903459b690c8c3035b601a3808afa4ccac (diff) | |
download | colm-7b441a6c7f2c9704b9d536a739f1b91893167df5.tar.gz |
removed XML and postfix print, implemented remaining print with send
Removed the XML and postfix print forms. The functionality is now achieved with
xml(), xmlac() and postfix() functions.
Now implementing the print and prints using the send expression. All printing
is now handled via the send instructions.
Diffstat (limited to 'src/loadcolm.cc')
-rw-r--r-- | src/loadcolm.cc | 98 |
1 files changed, 69 insertions, 29 deletions
diff --git a/src/loadcolm.cc b/src/loadcolm.cc index 9f47789f..c04d4c7b 100644 --- a/src/loadcolm.cc +++ b/src/loadcolm.cc @@ -291,9 +291,9 @@ struct LoadColm case statement::BareSend: { NamespaceQual *nspaceQual = NamespaceQual::cons( curNspace() ); QualItemVect *qualItemVect = new QualItemVect; - String id = "Output"; + LangVarRef *varRef = LangVarRef::cons( InputLoc(), - curNspace(), curStruct(), curScope(), nspaceQual, qualItemVect, id ); + curNspace(), curStruct(), curScope(), nspaceQual, qualItemVect, String("Output") ); ConsItemList *list = walkAccumulate( Statement.accumulate() ); bool eof = walkOptEos( Statement.opt_eos() ); @@ -1271,39 +1271,79 @@ struct LoadColm return callArgVect; } + ConsItemList *walkCallArgSeqAccum( call_arg_seq callArgSeq ) + { + ConsItemList *consItemList = new ConsItemList; + while ( callArgSeq != 0 ) { + code_expr codeExpr = callArgSeq.code_expr(); + +// LangExpr *expr = walkCodeExpr( codeExpr ); +// callArgVect->append( new CallArg(expr) ); + + bool trim = false; //walkTrim( consEl.opt_no_trim() ); + LangExpr *consExpr = walkCodeExpr( codeExpr ); + ConsItem *consItem = ConsItem::cons( consExpr->loc, + ConsItem::ExprType, consExpr, trim ); + consItemList->append( consItem ); + + callArgSeq = callArgSeq._call_arg_seq(); + } + return consItemList; + } + + ConsItemList *walkCallArgListAccum( call_arg_list callArgList ) + { + return walkCallArgSeqAccum( callArgList.call_arg_seq() ); + } + LangStmt *walkPrintStmt( print_stmt &printStmt ) { - if ( printStmt.prodName() == print_stmt::Accum ) { + LangStmt *stmt = 0; + switch ( printStmt.prodName() ) { + case print_stmt::Accum: { + InputLoc loc = printStmt.PRINT().loc(); + + NamespaceQual *nspaceQual = NamespaceQual::cons( curNspace() ); + QualItemVect *qualItemVect = new QualItemVect; + LangVarRef *varRef = LangVarRef::cons( loc, curNspace(), curStruct(), + curScope(), nspaceQual, qualItemVect, String("stdout") ); + ConsItemList *list = walkAccumulate( printStmt.accumulate() ); - return LangStmt::cons( printStmt.PRINT().loc(), LangStmt::PrintAccum, list ); + + bool eof = false; //walkOptEos( StmtOrFactor.opt_eos() ); + LangExpr *expr = send( loc, varRef, list, eof ); + stmt = LangStmt::cons( loc, LangStmt::ExprType, expr ); + break; } - else { - CallArgVect *exprVect = walkCallArgList( printStmt.call_arg_list() ); + case print_stmt::Tree: { + InputLoc loc = printStmt.PRINT().loc(); - LangStmt::Type type = LangStmt::PrintType; - switch ( printStmt.prodName() ) { - case print_stmt::Tree: - type = LangStmt::PrintType; - break; - case print_stmt::PrintStream: - type = LangStmt::PrintStreamType; - break; - case print_stmt::Xml: - type = LangStmt::PrintXMLType; - break; - case print_stmt::XmlAc: - type = LangStmt::PrintXMLACType; - break; - case print_stmt::Dump: - type = LangStmt::PrintDumpType; - break; - case print_stmt::Accum: - /* unreachable (see above) */ - break; - } - - return LangStmt::cons( printStmt.POPEN().loc(), type, exprVect ); + NamespaceQual *nspaceQual = NamespaceQual::cons( curNspace() ); + QualItemVect *qualItemVect = new QualItemVect; + LangVarRef *varRef = LangVarRef::cons( loc, curNspace(), curStruct(), + curScope(), nspaceQual, qualItemVect, String("stdout") ); + + ConsItemList *list = walkCallArgListAccum( printStmt.call_arg_list() ); + + + bool eof = false; //walkOptEos( StmtOrFactor.opt_eos() ); + LangExpr *expr = send( loc, varRef, list, eof ); + stmt = LangStmt::cons( loc, LangStmt::ExprType, expr ); + break; } + case print_stmt::PrintStream: { + LangVarRef *varRef = walkVarRef( printStmt.var_ref() ); + + ConsItemList *list = walkCallArgListAccum( printStmt.call_arg_list() ); + + InputLoc loc = printStmt.PRINTS().loc(); + + bool eof = false; //walkOptEos( StmtOrFactor.opt_eos() ); + LangExpr *expr = send( loc, varRef, list, eof ); + stmt = LangStmt::cons( loc, LangStmt::ExprType, expr ); + break; + }} + return stmt; } QualItemVect *walkQual( qual &Qual ) |