Sample grammars in FParsec going beyond the samples?
Asked Answered
I

2

12

I am looking for some sample grammars written in FParsec that would go beyond the samples in the project repository.

I have found this very nice grammar of GLSL, but this is the only sample I found. What I need is a grammar for a language similar to C or JavaScript.

Italy answered 30/1, 2012 at 9:39 Comment(0)
A
15

Luca Bolognese has written a great series of Write Yourself a Scheme in 48 Hours in F# where he used FParsec for parsing. The full source code with detailed test cases are online here.

The most relevant post is 6th one where he talked about parsing a simple Lisp-like language. This language is closer to JavaScript than to C just so you know.

Current series on his blog is parsing lambda expressions in F# (using FParsec) which could be helpful for you too.

Acrophobia answered 30/1, 2012 at 11:52 Comment(0)
I
2

Here is an implementation of a parser for the Portable Game Notation (PGN, a file format for chess games) in F# using FParsec, called pgn.net

The PGN format is easy to understand, so the use cases are quite clear. There are many variations of the format (e.g. what a move is) so there many small examples.

Inartificial answered 17/5, 2013 at 17:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.