Newbee: Lispy alternatives for configuration information file

From: Rodney (Rodney.malone_at_rodneyware.com)
Date: 08/05/04

  • Next message: Carl Shapiro: "Re: Data structure for raw byte manipulation"
    Date: Thu, 05 Aug 2004 05:58:54 GMT
    
    

    I currently have a program that stores configuration information
    in a modified window's INI file format. The information is
    read at runtime and loads internal values and arrays. I would
    like to replace this file with a Lisp friendly format to allow me
    to utilize the lisp reader facilities, but not make the data appear
    to criptic for a non-lisp maintainer to be able to make minor
    manual edits to the file, or at minimum, view it and understand
    the data in it. I feel XML is too verbose and seems to require
    a fairly large, not-very-easy-to-use library, at least for this
    particular purpose.

    The current (non-lisp) file format looks something like this:

    [File]
        Version=1.5
        Name=my_data

    [Section 1]
        Name="Section name 1"

        [Feature 1]
            Id=123
            Value="hi there 1 - 1"

        [Feature 2]
            Id=456
            Value="so long"

    [Section 2]
        Name="Section name 2"

        [Feature 1]
            Id=123
            Value="hi there 2 - 1"

    In this example, there are multiple sections with both key value
    pairs and other sections under them. The current program reads
    and parses out the sections (stuff with [brackets]) and the
    key value pairs, and puts them in internal arrays and variables that
    allow the user to find out how many Features are under Section 1,
    and then cycle through the array to pull out the key value pairs
    that fall under each [Section].

    For example the following call would set x to "hi there 2 - 1".
    x = GetValue("[Section 2].[Feature 1]:Value")

    The notation is arbitrary and doesn't really matter, but there
    has to be a way to specify where in the data tree you want to
    look, and how many of the entries you want to get, if there
    is more than one.

    But to do that parsing and processing is ugly and hard to maintain,
    as it is in a scripting language that does not have much in the way
    of data storage and searching facilities. I have created a Common
    Lisp plug-in that I can now use to give me a more robust data handling
    capablility. However, being new to Lisp, I haven't been able to come
    up with a sensible Lispy method or data format that allows
    that would allow easy fetching of both individual values and
    groups of values, for example, all of the "Id" values under [Section 1].

    Any suggestions would be welcome.

    Rodney


  • Next message: Carl Shapiro: "Re: Data structure for raw byte manipulation"

    Relevant Pages

    • Re: [PATCH] cpumask 5/10 rewrite cpumask.h - single bitmap based implementation
      ... >> likewise for whatever else is copying unsigned long arrays to userspace. ... The kernel bitmaps/cpumasks are arrays ... > I presume that it is too late to change the low level format of masks ... since it seems the perfctr stuff Mikael Pettersson ...
      (Linux-Kernel)
    • Re: Challenge: reading ascii data
      ... can process the U,V records below -> internal arrays and then output UV ... matches the UV output format shown. ... character:: dat ... output time frames time,u,v,uv from arrays ...
      (comp.lang.fortran)
    • Re: Challenge: reading ascii data
      ... can process the U,V records below -> internal arrays and then output UV product records in format requested by ... I will post my Fortran code once someone posts a non-Fortran solution that matches the UV output format shown. ... character:: dat ... output time frames time,u,v,uv from arrays ...
      (comp.lang.fortran)
    • Re: Rewrap "> " lines from file ?
      ... Common Lisp, as that is much easier to use for stand-alone processing. ... Anyway, once you have paragraphs, you can use a fancy Common Lisp format ... A fancier form of this function would allow you to specify the prefix ... language, then what you should do is write a rule-based reformatter, and ...
      (comp.lang.lisp)
    • Re: Challenge: reading ascii data
      ... can process the U,V records below -> internal arrays and then output UV ... matches the UV output format shown. ... character:: dat ... output time frames time,u,v,uv from arrays ...
      (comp.lang.fortran)

    Loading