Re: Parse library
From: Daniel O'Connell [C# MVP] (onyxkirx_at_--NOSPAM--comcast.net)
Date: 05/15/04
- Next message: Jay B. Harlow [MVP - Outlook]: "Re: Where to start the try block and what's the overhead???"
- Previous message: DalePres: "Re: Microsoft Message Queue"
- In reply to: William Stacey [MVP]: "Re: Parse library"
- Next in thread: William Stacey [MVP]: "Re: Parse library"
- Reply: William Stacey [MVP]: "Re: Parse library"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 15 May 2004 10:50:45 -0500
"William Stacey [MVP]" <staceywREMOVE@mvps.org> wrote in message
news:%239Q0CCpOEHA.3896@TK2MSFTNGP12.phx.gbl...
> Probably 50 or so key words with values like bool, string[], int, string.
Hrmm, it wouldn't be terribly hard to write. It'd take acouple days, for
sure, but if you aren't trying to compile to MSIL or anything, it'd be
doable without much of a headache(its codegen that makes you wanna tear your
hair out).
The simplist way would be a very simple parser that just returns a
dictionary with name,value pairs. If one was really nuts you could go the
xsd.exe way and generate a config class that loads and writes out the config
file, ;).
Actually, that would be an interesting project, a library of config parsers
and config object generators, or more interestingly a parser generator based
on some kind of grammer...something to think about at the least, something
like this must exist for .NET somewhere....but I'm going off tangent here.
Anyway, it'd be easier than adapting libConfuse, I think, but probably still
more work than you are looking for.
> What is "jay"?
>
Its the parser generator that mono uses. I've been using it to write the
parser of a compiler these last couple of days. There are a few other
generators out there, jay is just the one I happen to have used. I'm pretty
sure it would apply to this circumstance, but it requires learning a bit of
new syntax and writing your own tokenizer. To avoid that a direct C# parser
could probably be written, just not as efficent, I would think.
> --
> William Stacey, MVP
>
> "Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
> message news:e$0JMfjOEHA.2480@tk2msftngp13.phx.gbl...
>>
>> "William Stacey [MVP]" <staceywREMOVE@mvps.org> wrote in message
>> news:OenhwaiOEHA.3312@tk2msftngp13.phx.gbl...
>> > Thanks Erik. After looking at the lib, looks like more work then what
>> > I
>> > want to get into. Maybe I will just use xml serializer instead. I
> guess
>> > most folks may like xml config files these days. Cheers!
>> >
>>
>> Personally, I'm tryign to find a way to get away from them, ;). After a
> year
>> or so of too much xml, I'm starting to see why people fuss when someone
> uses
>> xml as a human readable\writeable language.
>>
>> While I don't know a library that will parse it, writing a parser
> shouldn't
>> be terribly difficult, maybe a days work using jay, depending on the
>> flexibility.
>>
>> Are you interested in a limited set of keywords or an open ended parser?
>> > --
>> > William Stacey, MVP
>> >
>> > "Erik Frey" <eriksjunk@hotmail.com> wrote in message
>> > news:uClZZ5gOEHA.2876@TK2MSFTNGP09.phx.gbl...
>> >> "William Stacey [MVP]" <staceywREMOVE@mvps.org> wrote in message
>> >> news:%23fRNhigOEHA.4044@TK2MSFTNGP10.phx.gbl...
>> >> > Anyone know of some library that will parse files like following:
>> >> >
>> >> > options {
>> >> > directory "/etc";
>> >> > allow-query { any; }; // This is the default
>> >> > recursion no;
>> >> > listen-on { 192.168.0.225; };
>> >> > forwarders { 4.2.2.2; };
>> >> > };
>> >> >
>> >> > --
>> >> > William Stacey, MVP
>> >>
>> >> libConfuse pretty much does what you want:
>> >>
>> >> http://www.nongnu.org/confuse/
>> >>
>> >> It's pure C, but it comes prebaked with a VS.NET project so it
>> >> wouldn't
>> >> be
>> >> too hard to convert/wrap.
>> >>
>> >> It might take you less time to write something yourself with Regex.
>> >>
>> >> Erik
>> >>
>> >>
>> >
>>
>>
>
- Next message: Jay B. Harlow [MVP - Outlook]: "Re: Where to start the try block and what's the overhead???"
- Previous message: DalePres: "Re: Microsoft Message Queue"
- In reply to: William Stacey [MVP]: "Re: Parse library"
- Next in thread: William Stacey [MVP]: "Re: Parse library"
- Reply: William Stacey [MVP]: "Re: Parse library"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|