Use more space in _debug

This commit is contained in:
augustin64 2024-01-10 11:50:13 +01:00
parent 6e1e6e2838
commit df22a7f065
3 changed files with 11 additions and 10 deletions

View File

@ -9,14 +9,15 @@ EvalResult execute(vector<string> input, Memory& memory, int initial_line, ExecA
vector<Token> tokens = tokenize(input, initial_line); vector<Token> tokens = tokenize(input, initial_line);
if (args.print_tokens) { if (args.print_tokens) {
cout << BOLD YELLOW " === TOKENS ===" RESET << endl; cout << BOLD YELLOW " ======= TOKENS =======" RESET << endl;
_debug_print_tokens(tokens); _debug_print_tokens(tokens);
} }
Node ast = parse(tokens); Node ast = parse(tokens);
if (args.print_ast) { if (args.print_ast) {
cout << BOLD YELLOW " === AST ===" RESET << endl; cout << BOLD YELLOW " ======= AST =======" RESET << endl;
_debug_print_tree(ast, 0, ""); _debug_print_tree(ast, 0, "");
} }
@ -24,14 +25,14 @@ EvalResult execute(vector<string> input, Memory& memory, int initial_line, ExecA
analyze(ast, type_mem); analyze(ast, type_mem);
if (args.dump_type_mem) { if (args.dump_type_mem) {
cout << BOLD YELLOW " === TYPE MEMORY ===" RESET << endl; cout << BOLD YELLOW " ======= TYPE MEMORY =======" RESET << endl;
type_mem._debug_print(); type_mem._debug_print();
} }
EvalResult res = eval(ast, memory, input); EvalResult res = eval(ast, memory, input);
if (args.dump_mem) { if (args.dump_mem) {
cout << BOLD YELLOW " === MEMORY ===" RESET << endl; cout << BOLD YELLOW " ======= MEMORY =======" RESET << endl;
memory._debug_print(); memory._debug_print();
} }

View File

@ -96,7 +96,7 @@ int main(int argc, char* argv[]) {
if ((print_tokens || print_ast || dump_type_mem || dump_mem) && if ((print_tokens || print_ast || dump_type_mem || dump_mem) &&
(holds_alternative<int>(res) || holds_alternative<double>(res))) { (holds_alternative<int>(res) || holds_alternative<double>(res))) {
cout << BOLD BLUE " === RESULT ===" RESET << endl; cout << BOLD BLUE " ======= RESULT =======" RESET << endl;
} }
if (holds_alternative<int>(res)) { if (holds_alternative<int>(res)) {

View File

@ -181,13 +181,13 @@ void _debug_print_memory_var(MemoryVar var) {
void _debug_print_scope(Scope scope) { void _debug_print_scope(Scope scope) {
for (auto it : scope.vars) { for (auto it : scope.vars) {
if (it.first.length() > 6) { if (it.first.length() > 14) {
cout << it.first.substr(0, 6) << ".."; cout << it.first.substr(0, 14) << "..";
} else { } else {
cout << setw (6) << it.first << " "; cout << setw (14) << it.first << " ";
} }
cout << "|"; cout << "|";
cout << setw (7) << _debug_get_type_type_name(it.second.type.type) << " |"; cout << setw (9) << _debug_get_type_type_name(it.second.type.type) << " |";
_debug_print_memory_var(it.second); _debug_print_memory_var(it.second);
cout << endl; cout << endl;
@ -195,7 +195,7 @@ void _debug_print_scope(Scope scope) {
} }
void Memory::_debug_print(void) { void Memory::_debug_print(void) {
cout << BOLD " Name | Type | Value" RESET << endl; cout << BOLD " Name | Type | Value" RESET << endl;
for (auto rit = scopes.rbegin(); rit != scopes.rend(); ++rit) { for (auto rit = scopes.rbegin(); rit != scopes.rend(); ++rit) {
Scope& scope = *rit; Scope& scope = *rit;
if (rit != scopes.rbegin()) { if (rit != scopes.rbegin()) {