-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathParser.cpp
More file actions
36 lines (30 loc) · 800 Bytes
/
Parser.cpp
File metadata and controls
36 lines (30 loc) · 800 Bytes
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
35
36
#include "Parser.h"
Parser::Parser(){
command=new wordList;
}
wordList* Parser::getcommand(){
return command;
}
Command* Parser::createCommand(){
std::string instruction, firstWord, secondWord;
std::cout << ">>>>";
std::getline(std::cin, instruction);
std::stringstream sstr(instruction);
sstr >> firstWord;
sstr >> secondWord;
sstr.ignore();
// Excepción si el Command es erroneo
try {
Command* commandWord=command->getCommand(firstWord);
if(commandWord){
commandWord->setprompt(secondWord);
return commandWord;
} else {
throw commandWord;
}
}
catch (Command* error) {
std::cout << "You wrote a wrong value\n";
std::cout << "Write a valid Command to use\n";
}
}