Managed meets functional

Blog about programming and having fun with .Net

About me

 Venice, 2009

profile for Alexander Galkin on Stack Exchange, a network of free, community-driven Q&A sites

Project Euler

Greetings here in my blog!
My name is Alexander Galkin. I was born 1979 in Kazan, Russia, where I graduated in child medicine.
Since 2001 I live in Hamburg, Germany and work as a freelancer software and database architect and trainer for Microsoft technologies.

 Microsoft Certified Trainer
Microsoft Certified Professional Developer
MCTS Logo
MCITP Logo

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Updated version of GLSL parser by Laurent Le Brun to compile with FParsec 0.9.1

GLSL parser by Laurent Le Brun is a gold nugget for those who would like to use FParsec to parse C-like languages. As I have plans to use this script as a starting point for my TouchDevelop parser, this script was the first I looked at after I fixed F# support in my Visual Studio 2010. 

It turned out, however, that the script is somewhat outdated: written in 2010 (according to the date of the blog entry) it requires an earlier version of FParsec library. Trying to compile it against the latest stable version of FParsec (0.9.1) fails due to some deprecated names (mostly abbreviations that were previously used in FParsec, like "Assoc", are now written in full). Besides, the syntax for SyntaxParser generic constructor has been changed to include the UserState type. 

I adapted the code by Laurent Le Brun, the working versions of the script with minimal changes (see below) can be downloaded from this blog entry.

Changes compared to the original version of the script:

  1. Assoc -> Associativity
  2. µOp -> µOperator where µ in {Infix, Prefix, Postfix, Ternary}
  3. Parse -> GlslParser
  4. Ast -> GlslAst
I also put together a small VS2010 project containing the latest version of FParsec along with a sample GLSL script that is automatically parsed if run in debug mode.
Files:

glsl_parser.fs (8 Kb) 

VisualStudio 2010 solution with FParsec 0.9.1 and sample script (1.36 Mb)


Categories: .net | F# | parser
Permalink | Comments (0) | Post RSSRSS comment feed