配置文件格式

之前我尝试使用yaml用到c中,結果发现,对于c是不合适的,它适合于ruby,py,要入乡随俗

 

几乎完整的程序或者软件, 都有配置信息, 一般保存在文件中. C/C++ 语言的项目一般使用 .ini 文件作为配置文件. ini 文件和成熟的库供使用, 但缺点很明显, 很难表达父子关系, 因为配置信息应该是一根树 - 配置树.

著名的Web Server Lighttpd 使用 LEMON 来解析配置文件. 有些软件还使用 Lua/Python 等脚本语言来做配置管理. 但很多时候没有这个必要.

http://www.ideawu.net/person/config/

The LEMON Parser Generator

The Lemon program is an LALR(1) parser generator. It takes a context free grammar and converts it into a subroutine that will parse a file using that grammar.

Lemon is similar to the much more famous programs "YACC" and "BISON". But lemon is not compatible with either yacc or bison. There are several important differences:

  • Lemon using a different grammar syntax which is less prone to programming errors.

     

  • The parser generated by Lemon is both re-entrant and thread-safe.

     

  • Lemon includes the concept of a non-terminal destructor, which makes it much easier to write a parser that does not leak memory.

     

The complete source code to the lemon parser generator is contained in two files. The file lemon.c is the parser generator program itself. A separate file lempar.c is the template for the parser subroutine that lemon generates. Documentation on lemon is also available.

 

Both the source code to lemon itself and the code that lemon generates are in the public domain.

To see an example of how to use lemon, see the source code to the SQLite database engine. Lemon is maintained as part of the SQLite project.

posted on 2011-11-11 19:39  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2011/11/11/2246041.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值