parsing - How can I define an INI file grammar using the BNFC? -
How to write BNF with my label to make INFi Parser for me?
I have yet received the o__O!
entry point file; Comment "#" ; Token id (letter | numbers | ["-_ '"]] +; Th File :: = [section]; Sect Section: = "[" id "]" [statement]; Bind Statement: = id = "id"; Separator Details "\ n"; Terminator section "";
[name] #x = 10 y = 20
Pars succeeded! [Surname] [name (name "name") [bind (id "y") (id "20")] [linerized tree] [name] y = 20
< Pre>
[name] x = 10 #y = 20
Pars succeeded! [Abstract syntax] Ine [sect (id "name") [bind (id "x") (id "10")] [alkaline tree] [name] x = 10
ODO I am stuck ...
I asked a BNFC devs and quoted it here:
Space characters such as Newlines are not well supported in tokens because the hard-wired laser type "Space" in BNFC. The idea is that the spaces can not make sense in "well-behaved" languages, one of the restrictions that has made the BNFC so easy ... but you should solve it using a preprocessor, eg. Pars the input line by line.
For example:
entry point file; Comment "#" ; Token id (letter | numbers | ["-_ '"]] +; Th File :: = [section]; Sect Section: = "[" id "]" [statement]; Bind Statement: = id = "id"; Separator Details "//"; Terminator stream "//";
Read:
[name] x = 10 y = 20
preprocess :
[name] // x = 10 // y = 20 //
Pars:
< Code (id "name") [bind (id "x") (id "10"), bind (id "Y") (id "20")]] < "Name") [bind (id "x") (id "0"), bind (id "y"): (id "0")]]
Type:
[name] // x = 0 // y = 0 //
post process: < / P>
[name] x = 0 y = 0
(not checked, don does not know that it works, Irf give you an idea!)
Comments
Post a Comment