C # to BNF or EBNF Parser generator for F #

I am looking for a BNF grammar for C # v4 that I can pass to fsyacc, or if I cannot find an EBNF-based parser generator that F # can output.

EDIT: I don't want to write a parser for C #, but an experimental parser for a very similar grammar, and since there is a huge literal match between the two grammars, it's easier for me to start with a C # grammar and just change the rejected bits. However, the only grammar for C # v4 I found is EBNF

an alternative answer would be a converter from EBNF to BNF

+4
source share
3 answers

Extending my previous comment - I don't think there is solid grammar for C # that can be used directly. There are a few examples, but they probably won’t cover all the new features (like LINQ) or they will not be very well tested.

The best option I can come up with is to use the parser from the C # compiler in Mono. It is written in C #, open source, includes all the latest features (and also pretty solidly). For more information see the Mono C # Compiler . You must compile it and use it from F # (or modify it to be more F # friendly).

+1
source

According to Wikipedia , Coco / R is an EBNF-based parser generator. And according to their homepage , there is a port F # Coco / R (last update 2007-07-23, though, so I expect some breaking changes). If you eventually verify this, I will be interested in your experience.

I found BNF grammars for C # v2: http://www.devincook.com/GOLDParser/grammars/index.htm

+1
source

I found several grammars here ; they seem to include up to C # 4.0.

+1
source

All Articles