more informative dump function
This commit is contained in:
parent
188c0dca03
commit
733898e013
|
@ -218,13 +218,16 @@ struct IndentStack
|
||||||
/**
|
/**
|
||||||
* Dumps the current state of the indentation stack to `stderr`. Used for debugging.
|
* Dumps the current state of the indentation stack to `stderr`. Used for debugging.
|
||||||
*/
|
*/
|
||||||
void dump(string file = __FILE__, uint line = __LINE__)
|
void dump(size_t pos = size_t.max, string file = __FILE__, uint line = __LINE__)
|
||||||
{
|
{
|
||||||
import dparse.lexer : str;
|
import dparse.lexer : str;
|
||||||
import std.algorithm.iteration : map;
|
import std.algorithm.iteration : map;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
|
|
||||||
|
if (pos == size_t.max)
|
||||||
stderr.writefln("\033[31m%s:%d %(%s %)\033[0m", file, line, arr[0 .. index].map!(a => str(a)));
|
stderr.writefln("\033[31m%s:%d %(%s %)\033[0m", file, line, arr[0 .. index].map!(a => str(a)));
|
||||||
|
else
|
||||||
|
stderr.writefln("\033[31m%s:%d at %d %(%s %)\033[0m", file, line, pos, arr[0 .. index].map!(a => str(a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue