Newsgroup: comp.os.linux.development.system


Date: Thu, 27 Apr 2006 09:56:09 +0300
From: Diomidis Spinellis <dds@aueb.gr>
Organization: Athens University of Economics and Business
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060404 SeaMonkey/1.0.1
MIME-Version: 1.0
Newsgroups: comp.os.linux.development.system
Subject: Re: Lexical correctness of a configuration file
References: <1146120071.667215.118940@u72g2000cwu.googlegroups.com>
In-Reply-To: <1146120071.667215.118940@u72g2000cwu.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
v4vijayakumar wrote:
> How can we find a configuration file is lexically correct and parse its
> arguments?

It depends on the syntax used.  If the syntax is trivial, for example 
lines containing "variable = value" pairs, you can hand-craft lexical 
analysis and "parsing" in a simple loop using functions like fgets and 
strchr.  For more complex custom configuration languages you would have 
to implement your own lexical analyzer and parser. Here lex and yacc are 
your friends.  Another possibility is to adopt a scripting language like 
Perl as your configuration library, and embed Perl's interpreter in your 
application.


-- 
Diomidis Spinellis
Code Quality: The Open Source Perspective (Addison-Wesley 2006)
http://www.spinellis.gr/codequality?colds



Newsgroup comp.os.linux.development.system contents
Newsgroup list
Diomidis Spinellis home page

Creative Commons License Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.