git.iko.soy/typeable/cabal2nix
on master help sign in
src/Nix.cf: a full-blown happy parser for Cabal derivations, generated by bnfc
68c82efPeter Simons
src/Nix.cfnew file+41
@@ -0,0 +1,41 @@
1+-- Run "bnfc -p Hackage4Nix -d Nix.cf" to re-generate the parsers from
2+-- this file.
3+--
4+-- The grammar works fine for 99% of all expressions. The remaining
5+-- percent doesn't parse because of 'let' or 'with' statements, which
6+-- don't support (and probably don't want to, because we can't resolve
7+-- them).
8+
9+Expr . Expr ::= "{" [Argument] "}" ":" "cabal.mkDerivation" "(" Argument ":" Dictionary ")";
10+
11+Argument . Argument ::= Ident ;
12+separator Argument "," ;
13+
14+Dictionary . Dictionary ::= "{" [Attribute] "}" ;
15+
16+Attribute . Attribute ::= Reference "=" Value ;
17+terminator Attribute ";" ;
18+
19+Reference . Reference ::= [Ident] ;
20+separator nonempty Ident "." ;
21+
22+StringV . Value ::= String ;
23+QStringV . Value ::= QString ;
24+URLV . Value ::= URL ;
25+PathV . Value ::= Path ;
26+BoolV . Value ::= Boolean ;
27+AttributeV . Value ::= Reference ;
28+ListV . Value ::= "[" [Value] "]" ;
29+DictionaryV . Value ::= Dictionary ;
30+FunctionV . Value ::= Reference Dictionary ;
31+separator Value "" ;
32+
33+Yes . Boolean ::= "true" ;
34+No . Boolean ::= "false" ;
35+
36+comment "#" ;
37+comment "/*" "*/" ;
38+
39+token QString {"''"} char* {"''"} ;
40+token URL letter+ {"://"} (char - [" \n\t;[]{}"])+ ;
41+token Path {"./"} (char - [" \n\t;[]{}"])+ ;