I too have been playing around with fslex and fsyacc and the latest version of the powerpack broken my project. I managed to fix it but as you said since there is no documentation it is hard to know exactally what happened so you will have to take all that I am telling you is my guesses so take it with a pinch of salt!

To start of with I am using VS2008 but the same problems apply. The first problem I found is that the FsYacc and FsLex MSBuild tasks stopped working. If you are not using them then read [link:blogs.msdn.com] as they will make you life much better! The reason for that is the install seems a bit broken and doesn't install FSharp.PowerPack.Build.Tasks.dll to C:\Program Files\MSBuild\FSharp\1.0. You can find it in C:\Program Files\FSharp-1.9.6.16\bin\gac. Just copy it accross and it should all start working.

The next problem is that the Lexer API has fundimentally changed as you have noticed. What I think has happened is that FsLex only accepted ASCII chars which is not great so they have converted it to accept UNICODE. To do this the LexBuffer is now generic so it can either be LexBuffer<byte> which is the default and can be use for single byte encoding or LexBuffer<char> which is for UNICODE strings which is what you want I suspect. This has to be turned on in the lexer so you need to pass the -unicode option to fslex. Now if you are using the MSBuild tasks and you should be you can turn on the setting in your project file. Look at C:\Program Files\MSBuild\FSharp\1.0\FSharp.PowerPack.Targets and you can see the options you can put in your project file. Basically add <FsLexUnicode>True</FsLexUnicode> in your element and all will be good. This should give you LexBuffer<char> everywhere and life should again make sense. You need your lexme function as well. Also I use LexBuffer<char>.FromChars(text.ToCharArray()) to create the buffers :).

Get a copy of [link:www.red-gate.com] (Disclaimer I am a redgate employee) and open the powerpack dll and you should see all the new inteface and looking through the F# compiler source is also an excellent way of working out how to use the new Lexer.

Hope that helps

Lionel

By on 6/9/2009 1:59 PM ()

Many, many thanks, Lionel.

Your explanations were superbly clear and worked perfectly! I learnt a great deal as a result, for which I am very grateful.

(Now if I a can only work out how to access the durn thing from c# projects I'll be a happy little coder :)

By on 6/12/2009 10:49 PM ()

Reflector is a great tool, but, the F# installation comes with the source code for the power pack including FSLex and FSYacc. I happen to be using VS 2k8 so I have F# installed as a plugin and my source is located under this path:

C:\Program Files\FSharp-1.9.6.16\source\fsppack

It might be a little easier to look through that than disassembling code with reflector.

By on 6/9/2009 2:50 PM ()

These days I even use reflector on my own code as I find it easier to navigate the class hieararcy than in Visual Studio :). I guess that means I have truly drunk the cool aid.

Lionel

By on 6/10/2009 12:17 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper