6
http://www.cs.chalmers.se/Cs/Research/Language-technology/BNFC/如何使用BNFC定義INI文件語法?
我該怎麼寫我的標記BNF來讓BNFC爲我生成一個INI解析器?
我只得到了這麼多o__O!
entrypoints File ;
comment "#" ;
token ID (letter | digit | ["-_'"])+ ;
Ini. File ::= [Section] ;
Sect. Section ::= "[" ID "]" [Statement] ;
Bind. Statement ::= ID "=" ID ;
separator Statement "\n" ;
terminator Section "" ;
[name]
#x = 10
y = 20
Parse Successful!
[Abstract Syntax]
Ini [Sect (ID "name") [Bind (ID "y") (ID "20")]]
[Linearized tree]
[name]y = 20
[name]
x = 10
#y = 20
Parse Successful!
[Abstract Syntax]
Ini [Sect (ID "name") [Bind (ID "x") (ID "10")]]
[Linearized tree]
[name]x = 10
O__O我卡住了...
你下一步想做什麼呢?看起來像這樣幾乎可以滿足解析ini文件 – 2009-06-25 06:47:04