Note that there are some explanatory texts on larger screens.

plurals
  1. POHierarchical text data structure parser suggestions needed
    primarykey
    data
    text
    <p>Having the following hierarchical text data input (JunOS-like, in fact) I need to parse it into some suitable data structure I could perform queries to obtain some user-specified branch of the tree, then linearize it (?) to some sort of mapping I could use to let user change/insert/delete etc. it and then write it back to an output file as a tree again (storing the original data in a "version" file to allow later "history" or "rollback" operations - the full set of operations as described some words ago).</p> <pre><code>version 1.0; description "Example data"; weights { weight low { value 1; description Forgetable; } weight medium { value 2; description Important; } weight high { value 3; description Critical; } } tags { tag foo { description "Some foo"; } tag bar { description "Some bar"; } tag baz { description "Some baz"; } } tag-sets { tag-set foo\ bar { tag [ foo bar ]; description Foo\ and\ bar; } tag-set "foo bar baz" { tag-set "foo bar"; tag baz; description "Foo, bar and baz"; } } </code></pre> <p>Questions:</p> <p>1) What data structure suites the input the best? What C structure do you suggest to be used?</p> <p>2) I do not want to use yacc/lex to parse it (unnecessary extra steps and complicated collaborative work whilst not everybody - even me - likes/knows to use the tools) - what parsing method is the easiest to implement for such sort of parsing problem?</p> <p>3) What method do you suggest to maintain the "types" of nodes in source code? It seems quite tricky to me at the moment (in fact I have no idea how to do it yet). For instance there is some node of type "version" that takes some "word" as it's argument. It is also known that the node "version" exists only as part of the root branch of the hierarchy. Another example may be that there are several "description" nodes taking a "word" or a "string as their arguments. The "description" nodes belongs to every node of the hierarchy. Etc. How to cope with this sort of problem?</p> <p>Note to explain the purpose: The resulting utility will "version" some data stored in text data files quite similar to the example I provided above and user will query/change/insert/delete the data to maintain some sort of specific information (say, todo list or whatever, as an example). Consider it to be sort of simple database rather than configuration file or something alike (sorry my english). The idea is to provide a) CLI, b) command-line tool, c) allow users to edit data in their editor, if the do not want to use a) or b)...</p> <p>At least some "general" suggestions are to be highly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload