配置文件格式

之前我尝试使用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.

原文链接: https://www.cnblogs.com/lexus/archive/2011/11/11/2246041.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    配置文件格式

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/36234

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月8日 下午1:00
下一篇 2023年2月8日 下午1:00

相关推荐