Re: Parse library

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Daniel O'Connell [C# MVP] (onyxkirx_at_--NOSPAM--comcast.net)
Date: 05/15/04


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
>> >>
>> >>
>> >
>>
>>
>



Relevant Pages

  • Re: Parse library
    ... this syntax is the config syntax used for Bind's config file ... > to comment the parser a bit better and throw it up as an article. ... > As you'll find out a compiler can go from one format to any other format, ... >> these tokens based on context. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Parse library
    ... Guess for now, will just leave as XML to get things working, then think ... > xsd.exe way and generate a config class that loads and writes out the ... or more interestingly a parser generator ... > generators out there, jay is just the one I happen to have used. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Parse library
    ... Then the parser assigns meaning to ... you would march the string and build a context ... If one was really nuts you could go the>> xsd.exe way and generate a config class that loads and writes out the> config ... There are a few other>> generators out there, jay is just the one I happen to have used. ...
    (microsoft.public.dotnet.languages.csharp)
  • .ini file parser (ConfigParser)
    ... I've written a simple parser for .ini files; ... but you could build such a module ontop of it fairly ... though generally the parser should be a non-public implementation ... a good piece for building different config parsers. ...
    (comp.lang.python)
  • Re: SQL autocomplete project
    ... so 1st determine if the grammar is LL or LR. ... grammar used into the notation of you favorite LL parser generator. ... Finding the parent rule is the only tricky part. ...
    (comp.compilers)