int main() {
statement_block sblock;
std::string sep;
while (sblock.input(std::cin)) {
sblock.optimize();
std::cout << sep;
sblock.output(std::cout);
sep = "\n";
}
}
equation equn;
int main() {
while (read_equ_blocks(std::cin)) { }
equn = equation_compiler.run_compiler(equn);
equn.output();
return 0;
}
main() tells us a lot.
class statement_block {
public:
bool input(istream & ins) {
string s;
if (read_nonblank_line(ins, s)) return false;
do sblock.push_back(s);
while (read_nonblank_line(ins, s));
return true;
}
void output(ostream & outs) {
for (unsigned i = 0; i < sblock; i++)
outs << sblock[i] << "\n";
}
void optimize(void) { }
private:
vector sblock;
};
x = y + z
x = y + z x = y + z
main() influenced statement blocks.
class statement_block {
public:
bool input(istream & ins) {
string s;
if (read_nonblank_line(ins, s)) return false;
do sblock.push_back(statement(s));
while (read_nonblank_line(ins, s));
return true;
}
void output(ostream & outs) {
for (unsigned i = 0; i < sblock; i++) {
sblock[i].output(outs)
outs << "\n";
}
}
void optimize(void) {
for (unsigned i = 0; i < sblock; i++) {
sblock[i].optimize()
}
private:
vector<statement> sblock;
};
class statement {
public:
statement(const string & s) : stmt(s) { }
void optimize(void) { }
void output(ostream & outs) const {
outs << stmt;
}
private:
string stmt;
};
"x = y + 1" vs. "x", "=", "y", "+",
"1".
= expression
| 000 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 1300 | 1500 | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | ||||||||
| 10 | 2 | 2 | ||||||||
| 20 | 1 | |||||||||
| 30 | 1 | |||||||||
| 40 | 1 | 1 | 1 | 1 | 1 | |||||
| 50 | 1 | |||||||||
| 60 | 1 | 1 | 1 | 1 | ||||||
| 70 | 1 | |||||||||
| 80 | 1 | 1 | ||||||||
| 90 | 1 | 1 | ||||||||
| Totals | 1 | 3 | 1 | 1 | 2 | 6 | 4 | 3 | 1 | 1 |
| 000 | 100 | 200 | 300 | 400 | 500 | |
|---|---|---|---|---|---|---|
| 0 | 2 | |||||
| 10 | ||||||
| 20 | 1 | 1 | ||||
| 30 | 1 | 1 | 2 | 1 | ||
| 40 | 3 | |||||
| 50 | ||||||
| 60 | 2 | 1 | ||||
| 70 | 2 | 1 | ||||
| 80 | 1 | 1 | ||||
| 90 | 1 | 1 | 1 | |||
| Totals | 3 | 3 | 10 | 5 | 1 | 1 |
| File Counts | Count | Average Lines/File | Avg Semicolons per File |
|---|---|---|---|
| 1 | 11 | 476 | 188 |
| 2 | 1 | 224 | 115 |
| 3 | 1 | 287 | 128 |
| 4 | 2 | 169 | 80 |
| 5 | 5 | 169 | 65 |
| 6 | 2 | 125 | 45 |
| 7 | 0 | ||
| 8 | 0 | ||
| 9 | 0 | ||
| 10 | 0 | ||
| 11 | 1 | 124 | 38 |
| total | pages per procedure | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| procs | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 3 | 3 | |||||||||
| 4 | 3 | 1 | ||||||||
| 4 | 3 | 1 | ||||||||
| 6 | 4 | 1 | 1 | |||||||
| 7 | 1 | 1 | 3 | 2 | ||||||
| 7 | 4 | 2 | 1 | |||||||
| 10 | 5 | 2 | 1 | 1 | 1 | |||||
| 11 | 5 | 4 | 1 | 1 | ||||||
| 13 | 11 | 1 | 1 | |||||||
| 14 | 7 | 4 | 1 | 1 | 1 | |||||
| 14 | 9 | 5 | ||||||||
| 20 | 15 | 2 | 3 | |||||||
| 20 | 17 | 3 | ||||||||
| 22 | 13 | 6 | 3 | |||||||
| 22 | 18 | 3 | 1 | |||||||
| 22 | 19 | 1 | 1 | 1 | ||||||
| 22 | 20 | 2 | ||||||||
| 24 | 20 | 3 | 1 | |||||||
| 28 | 25 | 3 | ||||||||
| 31 | 24 | 4 | 3 | |||||||
| 33 | 31 | 2 | ||||||||
| 59 | 50 | 7 | 1 | 1 | ||||||
| 70 | 66 | 3 | 1 | |||||||
lltostr().
char * lltostr(long long, char *).
char * argument points to the buffer end, not the
beginning.
char * intstr = new char[10]; intstr[0] = '\0'; intstr = lltostr(z, intstr);
char * intstr = new char[100]; // . . . expstr[m] = lltostr(Lkup[j].value, intstr);
intstr.
long long's 64 bits.
int ans = check(s.substr(i,j-i));
if (ans == 1) { /* whatever */ }
else if (ans == 2) { /* whatever */ }
else if (ans == 3) { /* whatever */ }
else if (ans == 4) { /* whatever */ }
else if (ans == 5) { /* whatever */ }
else if (ans == 6) { /* whatever */ }
else if (ans == 0) return false;
#define INVALID 0
#define NUMBER 1
#define VARIABLE 2
#define OPERATOR 3
#define LB 4
#define RB 5
#define EQUAL 6
if (StBlk[row][0].Type() != VARIABLE) /* . . . */
if (StBlk[row][col].Type() == INVALID) /* . . . */
if ((StBlk[row][col].Type() == NUMBER ||
StBlk[row][col].Type() == VARIABLE) &&
(StBlk[row][col+1].Type() == LB)) /* . . . */
if (StBlk[row][col].Type() == EQUAL) /* . . . */
if (StBlk[row][1] .Type() != EQUAL) /* . . . */
int ans = check(s.substr(i,j-i));
if (ans ==1) {
string str = s.substr(i,j-i);
dq.push_back("n");
smallv.push_back(str);
i = j;
}
else if (ans == 2) {
string str = s.substr(i,j-i);
dq.push_back("s");
smallv.push_back(str);
i = j;
}
else if (ans == 3) {
string str = s.substr(i,j-i);
dq.push_back("o");
smallv.push_back(str);
i = j;
}
else if (ans == 4) {
string str = s.substr(i,j-i);
dq.push_back("e");
smallv.push_back(str);
i = j;
}
else if (ans == 5) {
string str = s.substr(i,j-i);
dq.push_back("pl");
smallv.push_back(str);
i = j;
}
else if (ans == 6) {
string str = s.substr(i,j-i);
dq.push_back("pr");
smallv.push_back(str);
i = j;
}
else if (ans == 0)
return false;
|
int ans = check(s.substr(i,j-i));
if (ans == 0)
return false;
string str = s.substr(i,j-i);
if (ans == 1)
dq.push_back("n");
else if (ans == 2)
dq.push_back("s");
else if (ans == 3)
dq.push_back("o");
else if (ans == 4)
dq.push_back("e");
else if (ans == 5)
dq.push_back("pl");
else if (ans == 6)
dq.push_back("pr");
smallv.push_back(str);
i = j;
|
a = 1 b = a + 1 a = c + 1 c = a + 1
a the second time.
This page last modified on 26 February 2002.