having following hierarchical text data input (junos-like, in fact) need parse suitable data structure perform queries obtain user-specified branch of tree, linearize (?) sort of mapping use let user change/insert/delete etc. , write output file tree again (storing original data in "version" file allow later "history" or "rollback" operations - full set of operations described words ago).
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 , baz"; } } questions:
1) data structure suites input best? c structure suggest used?
2) not want use yacc/lex parse (unnecessary steps , complicated collaborative work whilst not - me - likes/knows use tools) - parsing method easiest implement such sort of parsing problem?
3) method suggest maintain "types" of nodes in source code? seems quite tricky me @ moment (in fact have no idea how yet). instance there node of type "version" takes "word" it's argument. known node "version" exists part of root branch of hierarchy. example may there several "description" nodes taking "word" or "string arguments. "description" nodes belongs every node of hierarchy. etc. how cope sort of problem?
note explain purpose: resulting utility "version" data stored in text data files quite similar example provided above , user query/change/insert/delete data maintain sort of specific information (say, todo list or whatever, example). consider sort of simple database rather configuration file or alike (sorry english). idea provide a) cli, b) command-line tool, c) allow users edit data in editor, if not want use a) or b)...
at least "general" suggestions highly appreciated.
i use recursive descent parser combined sort of hashtable or map data storage. looks of it, closely resembles json, not exactly. strings, numbers, lists, , dictionaries seem supported though. simple "object" type class trick storing (similar javascript).
for managing history of data structure, implement similar ometa worlds (see: http://www.vpri.org/pdf/rn2008001_worlds.pdf). leverages prototypical object model managing scope , history.
Comments
Post a Comment