Input to port (between -- lines): -- a = 1 b = a + 1 a = 2 c = b + 1 -- Output from port (between -- lines): -- a = 1 b = 2 a = 2 c = 3 --
int main() { string line strvec bloc int block_changed = 0 while true bloc.clear() while true getline(cin, line) if !cin.good() return 0 if line.length() > 0 bloc.push_back(line) else break if block.size() > 0 do cons_fold(bloc) eval_bloc(bloc, block_changed) while block_changed == 1 print(bloc)
Input to port (between -- lines): -- a = 1 b = a + 1 a = 2 c = b + 1 -- Output from port (between -- lines): -- --
assert
macro is useful for this.
while true getline(cin, line) if !cin.good() assert(bloc.empty()); return 0 if line.length() > 0 bloc.push_back(line) else break
int main() { string line strvec bloc while true bloc.clear() while true getline(cin, line) if cin.good() and line.length() > 0 bloc.push_back(line) else break if block.size() == 0 break do cons_fold(bloc) while eval_bloc(bloc) print(bloc)
int main() vector<A> av string line while(true) getline(cin, line) if cin.eof() break if line != "" A ab ab.expression = line ab.get_elements() if !ab.isvalid() cerr << "Input errors\n" exit(1) av.push_back(ab) else E_Optimization(av) av.clear()
Input to port (between -- lines): -- x = y + 1 y = z + 1 z = x + 1 -- Output from port (between -- lines): -- --
while(true) getline(cin, line) if cin.eof() break
int main() vector<A> av string line while true vector<string> input while getline(cin, line) and (line != "") input.push_back(line) if input.empty() break if check(input, av) E_Optimization(av) bool check(input, av) av.clear() for each l line in input A ab ab.expression = l ab.get_elements() if !ab.isvalid() return false av.push_back(ab) return true
int main() vector<string> outputVect vector <Code_line> cVect bool errorFlag = false while getline(cin, str) if s.empty() if !cVect.empty() if !errorFlag process_block(cVect, outputVect) if errorFlag outputVect.push_back(error) errorFlag = false else if !errorFlag Code_line cln if process_line (s, cln) cVect.push_back(cln) else errorFlag = true if cin.eof() if !cVect.empty() if !errorFlag process_block(cVect, outputVect) else outputVect.push_back(emsg) for (i = 0; i < outputVect.size(); i++) cout << outputVect[i]
Input to port (between -- lines): -- x = y + 1 y = z + 1 z = x + 1 -- Output from port (between -- lines): -- x = y + 1 y = z + 1 z = x + 1 -- Input to port (between -- lines): -- x = y @[ z -- Output from port (between -- lines): -- --
process_block()
.
int main() vector<string> outputVect do vector <Code_line> cVect while getline(cin, s) and !s.empty() Code_line cln if process_line (s, cln) cVect.push_back(cln) else cVect.push_back(error_message) if !cVect.empty() process_block(cVect, outputVect) while !cin.eof() for (i = 0; i < outputVect.size(); i++) cout << outputVect[i]
assert
macro.
This page last modified on 25 April 2002.