Create a pretty printer in param_storage.h .
bryan-lunt opened this issue · 8 comments
Create a pretty-printer utility function.
It could be a static function or a member function, either way. I suppose I prefer a static function for some reason.
Do not alter the existing operator<<
I am new to this , so can you help a little and tell me what this function should do ? Thx
Oh, wow! A contributor!
Well, a pretty-printer for some hierarchical datastructure / markup languages is a print function that sets up nice indentation and spacing so that the markup will be easy to read.
For example:
{"first":[1,2,{"other":[7,8,0],"ahah":56.6}],"second":{"secondsfirst":4.5}}
is valid SNOT (and therefore valid JSON).
But:
{
"first":[
1, 2, {
"other":[ 7, 8, 0],
"ahah":56.6
}
],
"second":{
"secondsfirst":4.5
}
}
is significantly easier to read.
Basically the function needs either a stack or recursion and descends into the datastructure, keeping track of how many levels in it is, and applies some rules about indentation and formatting.
In what language should I implement this function ?
It should go in param_storage.h
(in lexyacc/src
) , be written in standard C++98 , and complement/ work well with the existing code. It should either be a member method or static method of gsparams::DictList
.
Thanks!
Except for potentially including a new standard header (which I hope can be avoided), the new function should be totally self-contained. I mean that you should not need to alter any other part of the code, just add the function to the DictList class.
Is there a document explaining the parts of code already written? I have a problem understanding thr DictList class functionality.
There isn't any proper doxygen API or anything, but there are examples at https://github.com/bryan-lunt/SNOT_lang/tree/master/lexyacc/examples