我想用flex和bison编写解析器,但是我对它的工作原理感到困惑。我试图采取下列方式格式化的文本文件:在野牛上处理群体
Version Header Version 1.00 <--- File always starts with a header
Key : Value <--- Each section includes these but these after the version header are in the "Root" section
==Section Name <--- A section
$Key : Value <--- These are properties
Key : Value <--- Same thing as in the "Root" section
样本格式:
NasuTek Licensing Version 1.00
Vendor : NASUTEKENTERPRISES
Notice : NasuTek Enterprises
License Group : NasuTek Asheila
License Name : NasuTek Asheila
Vendor Notice : NasuTek Asheila Internal Build License
Serial : ASHEL-87267-4987-3737-37821:32742
Start Date : Wed July 04 00:00:00 2012
End Date : Sat July 20 00:00:00 2013
Trial : Yes
Count : 0
Components : EXPORT
Host : Any
==Software Configuration
$Signed Section : Yes
Export Configuration : {
Supports Export to XML : Yes
Supports Export to Text : Yes
}
==Signature
vpUsQJ+Qo4OS+RQg0vuLW0mXjAj/o6v[trunicated]
我怎样才能做到这一点是我在分组困惑。我可以得到它看到密钥对,因为这很简单,但我不知道如何处理分裂使用==和{}对?
你在解析? – iammilind 2012-07-15 04:49:29
你真的需要使用完整的解析器吗?它看起来像你的输入格式非常简单,你可以逐行阅读并根据需要生成输出。 – 2012-07-15 04:51:45
它是我正在编写的应用程序的一种配置文件。 “==”是部分拆分,任何不在部分中的版本头部将进入根部分。 – DrHouse 2012-07-15 04:52:35