aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/CodeGen.cc27
-rw-r--r--lib/Parser/Parser.cc12
2 files changed, 24 insertions, 15 deletions
diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc
index d5942e9..c0da7ee 100644
--- a/lib/CodeGen/CodeGen.cc
+++ b/lib/CodeGen/CodeGen.cc
@@ -1138,20 +1138,23 @@ void CodeGen::emitStmt(StmtAST *Stmt) {
}
if (auto *Out = dynamic_cast<OutputStmtAST*>(Stmt)) {
- bool Handled = Arrays->tryEmitArrayOutput(Out->getExpr(), *this);
- if (Handled) return;
+ const auto &Exprs = Out->getExprs();
+ for (size_t I = 0; I < Exprs.size(); ++I) {
+ ExprAST *Expr = Exprs[I].get();
+ if (Arrays->tryEmitArrayOutput(Expr, *this)) continue;
- Value *Val = emitExpr(Out->getExpr());
- const TypeInfo *TypeInfo = getExprTypeInfo(Out->getExpr());
- if (!TypeInfo) {
- reportError("Cannot infer the type of the OUTPUT expression");
- return;
- }
- if (TypeInfo->isVoid()) {
- reportError("Cannot OUTPUT the result of a PROCEDURE call");
- return;
+ Value *Val = emitExpr(Expr);
+ const TypeInfo *TypeInfo = getExprTypeInfo(Expr);
+ if (!TypeInfo) {
+ reportError("Cannot infer the type of the OUTPUT expression");
+ continue;
+ }
+ if (TypeInfo->isVoid()) {
+ reportError("Cannot OUTPUT the result of a PROCEDURE call");
+ continue;
+ }
+ emitOutputValue(Val, TypeInfo, I + 1 == Exprs.size());
}
- emitOutputValue(Val, TypeInfo, true);
return;
}
diff --git a/lib/Parser/Parser.cc b/lib/Parser/Parser.cc
index 260472c..25fc342 100644
--- a/lib/Parser/Parser.cc
+++ b/lib/Parser/Parser.cc
@@ -555,9 +555,15 @@ std::unique_ptr<StmtAST> Parser::ParseStatementImpl() {
}
else if (CurTok == tok_output) {
getNextToken();
- auto Expr = ParseExpression();
- if (!Expr) return nullptr;
- return std::make_unique<OutputStmtAST>(std::move(Expr));
+ std::vector<std::unique_ptr<ExprAST>> Exprs;
+ while (true) {
+ auto Expr = ParseExpression();
+ if (!Expr) return nullptr;
+ Exprs.push_back(std::move(Expr));
+ if (CurTok != ',') break;
+ getNextToken();
+ }
+ return std::make_unique<OutputStmtAST>(std::move(Exprs));
}
else if (CurTok == tok_if) {
return ParseIfStmt();