forked from VisceralLogic/basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print.cpp
34 lines (29 loc) · 780 Bytes
/
print.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include "print.h"
#include "basic.h"
using std::endl;
using std::cout;
// constructor for Print class
Print::Print(const std::vector<Expression*> *exprList){
this->exprList = exprList;
}
// prints out each expression to std::cout
bool Print::execute(bool next) const{
for( int i = 0; i < exprList->size()-1; i++ ){
cout << exprList->at(i)->print() << ' ';
}
cout << exprList->at(exprList->size()-1)->print() << endl;
if (next)
{
Basic::instance()->nextLine();
}
return true;
}
// lists the expressions, as they were originally given
void Print::list(ostream& os) const{
os << "PRINT ";
for( int i = 0; i < exprList->size()-1; i++ ){
os << exprList->at(i)->list() << ", ";
}
os << exprList->at(exprList->size()-1)->list();
}