-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-tools.cpp
More file actions
37 lines (31 loc) · 1.08 KB
/
Copy pathdev-tools.cpp
File metadata and controls
37 lines (31 loc) · 1.08 KB
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
37
/**
@brief Developer tools
Utility functions to facilitate development. (E.g. to visualize some internal layout)
*/
#include <cstring>
#include <iostream>
#include "src/Instruction.h"
using namespace MiniPython;
int main(int argc, char** argv) {
if (argc == 1) {
std::cout << "At least one parameter required.\n"
<< "Possible values:\n"
<< " token - supply a line from command-line and visualize how it is parsed into tokens\n"
<< " instr - supply a line from command-line and visualize how it is parsed into instructions\n";
exit(1);
}
if (!strcmp(argv[1], "token")) {
std::string line;
while (std::getline(std::cin, line)) {
for (auto& token: tokenizeLine(line)) {
std::cout << token.debug_string() << "\n";
}
}
}
if (!strcmp(argv[1], "instr")) {
std::string line;
while (std::getline(std::cin, line)) {
std::cout << Instruction::fromTokenList(tokenizeLine(line)).debug_string() << "\n";
}
}
}