@@ -7,10 +7,10 @@ namespace logger {
7
7
static constexpr const char * DASHES = " ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" ;
8
8
9
9
static constexpr const bool LOG_ENABLED = false ;
10
- static constexpr const int LOG_EVENT_LEN = 30 ;
11
- static constexpr const int LOG_BUFFER_LEN = 20 ;
12
- static constexpr const int LOG_DETAIL_LEN = 50 ;
13
- static constexpr const int LOG_INDEX_LEN = 10 ;
10
+ static constexpr const int LOG_EVENT_LEN = 20 ;
11
+ static constexpr const int LOG_BUFFER_LEN = 10 ;
12
+ static constexpr const int LOG_SMALL_BUFFER_LEN = 10 ;
13
+ static constexpr const int LOG_INDEX_LEN = 5 ;
14
14
15
15
static int log_depth; // Not threadsafe. Log only.
16
16
@@ -28,8 +28,8 @@ namespace logger {
28
28
if (LOG_ENABLED) {
29
29
log_depth = 0 ;
30
30
printf (" \n " );
31
- printf (" | %-*s | %-*s | %*s | %*s | %*s | % -*s | %-*s | %-*s |\n " , LOG_EVENT_LEN, " Event" , LOG_BUFFER_LEN, " Buffer" , 4 , " Curr " , 4 , " Next" , 5 , " Next#" , 5 , " Tape#" , LOG_DETAIL_LEN, " Detail " , LOG_INDEX_LEN, " index " );
32
- printf (" |%.*s|%.*s|%.*s|%.*s|%.*s|%.*s|%.*s|%.*s| \n " , LOG_EVENT_LEN+2 , DASHES, LOG_BUFFER_LEN+2 , DASHES, 4 +2 , DASHES, 4 + 2 , DASHES, 5 +2 , DASHES, 5 + 2 , DASHES, LOG_DETAIL_LEN+ 2 , DASHES, LOG_INDEX_LEN +2 , DASHES);
31
+ printf (" | %-*s | %-*s | %- *s | %-*s | %-*s | Detail |\n " , LOG_EVENT_LEN, " Event" , LOG_BUFFER_LEN, " Buffer" , LOG_SMALL_BUFFER_LEN , " Next" , 5 , " Next#" , 5 , " Tape#" );
32
+ printf (" |%.*s|%.*s|%.*s|%.*s|%.*s|--------| \n " , LOG_EVENT_LEN+2 , DASHES, LOG_BUFFER_LEN+2 , DASHES, LOG_SMALL_BUFFER_LEN +2 , DASHES, 5 +2 , DASHES, 5 +2 , DASHES);
33
33
}
34
34
}
35
35
@@ -44,22 +44,35 @@ namespace logger {
44
44
static really_inline void log_line (S &structurals, const char *title_prefix, const char *title, const char *detail) {
45
45
if (LOG_ENABLED) {
46
46
printf (" | %*s%s%-*s " , log_depth*2 , " " , title_prefix, LOG_EVENT_LEN - log_depth*2 - int (strlen (title_prefix)), title);
47
+ auto current_index = structurals.at_beginning () ? nullptr : structurals.next_structural -1 ;
48
+ auto next_index = structurals.next_structural ;
49
+ auto current = current_index ? &structurals.buf [*current_index] : (const uint8_t *)" " ;
50
+ auto next = &structurals.buf [*next_index];
47
51
{
48
52
// Print the next N characters in the buffer.
49
53
printf (" | " );
50
54
// Otherwise, print the characters starting from the buffer position.
51
55
// Print spaces for unprintable or newline characters.
52
56
for (int i=0 ;i<LOG_BUFFER_LEN;i++) {
53
- printf (" %c" , printable_char (structurals. current () [i]));
57
+ printf (" %c" , printable_char (current[i]));
54
58
}
55
59
printf (" " );
60
+ // Print the next N characters in the buffer.
61
+ printf (" | " );
62
+ // Otherwise, print the characters starting from the buffer position.
63
+ // Print spaces for unprintable or newline characters.
64
+ for (int i=0 ;i<LOG_SMALL_BUFFER_LEN;i++) {
65
+ printf (" %c" , printable_char (next[i]));
66
+ }
67
+ printf (" " );
68
+ }
69
+ if (current_index) {
70
+ printf (" | %*u " , LOG_INDEX_LEN, *current_index);
71
+ } else {
72
+ printf (" | %-*s " , LOG_INDEX_LEN, " " );
56
73
}
57
- printf (" | %c " , printable_char (structurals.current_char ()));
58
- printf (" | %c " , printable_char (structurals.peek_next_char ()));
59
- printf (" | %5u " , structurals.parser .structural_indexes [*(structurals.current_structural +1 )]);
60
- printf (" | %5u " , structurals.next_tape_index ());
61
- printf (" | %-*s " , LOG_DETAIL_LEN, detail);
62
- printf (" | %*u " , LOG_INDEX_LEN, *structurals.current_structural );
74
+ printf (" | %*u " , LOG_INDEX_LEN, structurals.next_tape_index ());
75
+ printf (" | %-s " , detail);
63
76
printf (" |\n " );
64
77
}
65
78
}
0 commit comments