diff --git a/src/cmd_do.cpp b/src/cmd_do.cpp index 48c0877..cf99c59 100644 --- a/src/cmd_do.cpp +++ b/src/cmd_do.cpp @@ -9,6 +9,7 @@ using namespace std; cmdEngine *CMDENGINE; int Cmd_do::check_cmd(const string& _CMD) { + cout << "inside cmd_do check \n"; stack Stack; istringstream sin(_CMD); string word; @@ -42,7 +43,9 @@ int Cmd_do::check_cmd(const string& _CMD) } else //stack is filled, we need to accept this "[" as SUBCMD { + cout << "word [ :"; SUBCMD += word + " "; + cout << SUBCMD << ":\n"; } Stack.push(word); } @@ -61,7 +64,9 @@ int Cmd_do::check_cmd(const string& _CMD) } else//stack not empty so we need to accept "]" into SUBCMD { + cout << "word ] :"; SUBCMD += word + " "; + cout << SUBCMD << "\n"; } } else// wrong positions @@ -72,12 +77,21 @@ int Cmd_do::check_cmd(const string& _CMD) } else if (word == "<") { - readUI = 1; + // readUI = 1; + if (!Stack.isEmpty())//if stack is not empty, we need to read it + { + readSUBCMD = 1; + SUBCMD += word+" "; + } + else//stack is empty, root command + { + readUI = 1; + } Stack.push(word); } else if (word == ">") { - if (!Stack.isEmpty()) + if (!Stack.isEmpty())//if stack is not empty { Stack.pop(); if (Stack.isEmpty()) @@ -89,6 +103,12 @@ int Cmd_do::check_cmd(const string& _CMD) readUI = false; } } + else//stack is not empty, so it mean we are still reading + { + cout << "word > :"; + SUBCMD += word + " "; + cout << SUBCMD << ":\n"; + } } else { @@ -99,6 +119,7 @@ int Cmd_do::check_cmd(const string& _CMD) else if (readSUBCMD == 1 && readUI == 0) { SUBCMD += word + " "; + cout << "SUBCMD :" << SUBCMD << ": (stack empty : "<> major_command;//read first major command , note that submajor can also be read + cout << "Major is : " << major_command << "\n"; if (major_command == "read" || major_command == "write"||major_command=="-q") { //cout << "detected major_command\n"; @@ -76,7 +77,7 @@ int cmdEngine::check(const string& _CMD,int toExecute)//toExecute set true by de if (cmd_io != NULL) delete cmd_io; isCorrect = 0; - cout << "\n ERROR : error in command \n "; + cout << "\n ERROR : error in command ("<check_cmd(_CMD)) { if(toExecute) @@ -105,8 +108,9 @@ int cmdEngine::check(const string& _CMD,int toExecute)//toExecute set true by de isCorrect=1; } else - { isCorrect=0; - cout<<"\n ERROR : error in command \n"; + { + isCorrect=0; + cout<<"\n ERROR : error in command do\n"; } if(cmd_do!=NULL) delete cmd_do;