/************************************************************************************************/
/*			        LEDA Lab: 2nd Lab Assignment					*/
/*			      Arithmetic Expression Calculator					*/
/************************************************************************************************/

#define WhoAmI "<Give your name(s)>"		// for identification purposes		

#include <LEDA/core/stack.h>				// for using the stack data type of LEDA
#include <LEDA/core/string.h>			// for using the string data type of LEDA
#include <iostream>

using namespace leda;

#if defined(LEDA_STD_IO_HEADERS)
using std::cout;
using std::cin;
using std::endl;
#endif

//some useful macros...
#define is_space(c)     ( c == ' ' || c == '\t' || c == '\n' )
#define is_operator(c)  ( c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')' )
#define is_digit(c)     ( c >= '0' && c <= '9' )
#define atoi(c)		( c - '0' )

int main() 
{
	const char delim ='.';

	string s, errmsg;
	char c;

	stack<int> S;
	stack<char> Op;

	int left_parentheses_counter = 0;


cout << " ///////////////////////////////////////////////////////////////////////////////////////////////////// " << endl;
cout << " LEDA LAB 2012: Lab2 \t " << WhoAmI << endl;
cout << " ///////////////////////////////////////////////////////////////////////////////////////////////////// " << endl;
cout << " PRECONDITIONS " << endl;
cout << " This programme calculates arithmetic expressions that are constructed recursively as follows:" << endl;
cout << " -- We consider as legal operators only the BINARY OPERATORS of addition ('+'), subtraction ('-') " << endl;
cout << "     multiplication ('*') and division ('/')" << endl;
cout << " -- Any integer is considered to be a legal expression" << endl;
cout << " -- Any expression E= ( E1 op E2)  that is the result of combining two legal expressions E1 and E2 " << endl;
cout << "    with a legal operator OP is also a legal expression" << endl;
cout << " We determine the end of a legal expression with the '.' delimiter" << endl;
cout << " POSTCONDITIONS: " << endl;
cout << " The result of the expression that is given as input, provided that it is a legal expression " << endl;
cout << " which is terminated with the delimiter '.'" << endl;
cout << " ///////////////////////////////////////////////////////////////////////////////////////////////////// " << endl;


cout.flush();

cout << " Give a legal expression to compute: " << endl;

	s.read(delim); 					// read the expression that the reader provides...
	cout << "****" << s << "****" << endl; 		// print the expression that was just given...
	cout.flush();

	int count = 0, numdigits = 0;

	while ( count < s.length() ) 
	{
		c = s[count++];
		cout << "I just read the character **" << c << "**" << endl;

		// ********************************** 
		// ********************************** 
		//...provide your code here...
		// errmsg = " Error: <<reason>> "
		// ********************************** 
		// ********************************** 

	}


	//...provide your code here...
	// for output LEGAL or ILLEGAL EXPRESSION
	// If LEGAL print VALUE
	// If ILLEGAL print errmsg 

}
