three18ti has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
We have a system that dumps out, for lack of a better term, config files. They don't adhere to any external standard, but are standardized within themselves.
Essentially, I have a colon delimited list of key value pairs:
foo: bar baz: 1234+54q - bar bar who: bob where: October Some other parameter: 42 What are we doing today Brain: Same thing we do every day Pinky
Each "config" file produces the same "keys", while the values change.
I suppose it would be easy enough to use some kind of regex trickery, but I'm really trying to avoid that as it's likely the config file format will change and I want someone who isn't me (or a Perl person for that matter) to be able to update the tool to parse the new format. This is where the idea of a "parsing template" came up. I'd like to be able to do something like:
foo: <string> baz: <number><string><number> who: <name> where: <month> Some other parameter: <int> What are we doing today Brain: <varchar>
I had looked at Marpa::R2 previously for parsing the sudoers file, it was a bit cumbersome and I never could quite get it to work properly (someday... but I have more pressing projects at the moment), and I don't know that a full parser is really necessary, but it does sort of fit the "parse from template" bill...
Does anyone have any better ideas? I'm certainly not married to the idea of using some kind of (EE)BNF for parsing, but it seems like it would be the most direct route to write a tool that can consume arbitrary "parsing templates".
Thanks for the advice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing an Arbitrary "config" file (based on a "template"?)
by roboticus (Chancellor) on Dec 31, 2014 at 22:22 UTC | |
by roboticus (Chancellor) on Dec 31, 2014 at 23:33 UTC | |
by three18ti (Monk) on Jan 02, 2015 at 16:45 UTC |