Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a pretty printer in param_storage.h . #1

Open
bryan-lunt opened this issue Jun 7, 2018 · 8 comments
Open

Create a pretty printer in param_storage.h . #1

bryan-lunt opened this issue Jun 7, 2018 · 8 comments

Comments

@bryan-lunt
Copy link
Owner

bryan-lunt commented Jun 7, 2018

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<<

@Traveler98
Copy link

I am new to this , so can you help a little and tell me what this function should do ? Thx

@bryan-lunt
Copy link
Owner Author

bryan-lunt commented Jun 7, 2018

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.

@bryan-lunt
Copy link
Owner Author

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.

@Traveler98
Copy link

In what language should I implement this function ?

@bryan-lunt bryan-lunt changed the title Create a pretty printer. Create a pretty printer in parameter_storage.h . Jun 7, 2018
@bryan-lunt
Copy link
Owner Author

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!

@bryan-lunt bryan-lunt changed the title Create a pretty printer in parameter_storage.h . Create a pretty printer in param_storage.h . Jun 7, 2018
@bryan-lunt
Copy link
Owner Author

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.

@Traveler98
Copy link

Is there a document explaining the parts of code already written? I have a problem understanding thr DictList class functionality.

@bryan-lunt
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants