-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathprint.cpp
More file actions
31 lines (27 loc) · 732 Bytes
/
print.cpp
File metadata and controls
31 lines (27 loc) · 732 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
#include "smiley.h"
#include "test.h"
using namespace Smiley;
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <smiles string>" << std::endl;
return 1;
}
PrintCallback callback;
Parser<PrintCallback> parser(callback);
try {
parser.parse(argv[1]);
} catch (Exception &e) {
if (e.type() == Exception::SyntaxError)
std::cerr << "Syntax";
else
std::cerr << "Semantics";
std::cout << "Error: " << e.what() << "." << std::endl;
std::cout << argv[1] << std::endl;
for (std::size_t i = 0; i < e.pos(); ++i)
std::cout << " ";
for (std::size_t i = 0; i < e.length(); ++i)
std::cout << "^";
std::cout << std::endl;
}
}