I’ve blogged before about the excellent Coco/R parser generator. I’m using it a lot in my masters project and I’m happy with it but there were a few things I wished worked differently. The main thing was that I wanted better Visual Studio integration. I had set up a pre-build event that generated the parser and scanner before every build. However there is obviously no need to re-generate the files unless the grammar file has changed. Generating on every build also had the effect that Visual Studio kept prompting me about reloading changed files and I had to build to see if there were any errors in my grammar. So, I decided to create a Visual Studio plugin for Coco/R myself.
Coco/R is open source and written in C# (at least one version of it) so it was easy to get the source. I then looked at a couple of tutorials on Visual Studio plugins and managed to hack together an plugin that works well enough for my needs. I also made a small change to the way Coco/R generates its parsers and scanners from frame files. Here are the features that are unique to the plugin:
So, that’s it. You can download an MSI installer for it and you can also view or checkout the source at http://einaregilsson.googlecode.com/svn/dotnet/CocoPlugin/. Enjoy.
Hi,
thanks a lot. Great tool.
Just a question: I am about to use coco/r with Silverlight which doesn’t support Hashtable. I found that I should use System.Collections.Generic.Dictionary. I changed the definition of start in scanner.cs to static readonly Dictionary start. But when scanner.generated.cs is regenerated, there is still Hashtable there.
Is there any flexible way of setting the underlying frame file and specifically this datatype?
Thanks a lot.
Pavel K.
Hi
Glad you could use the tool. Unfortunately you can’t really change the frame file without re-compiling the plugin since the frame files are embedded in the CocoPlugin.dll file. Maybe not the best decision I made there…
But you can if you want check out the source from Subversion at http://einaregilsson.googlecode.com/svn/dotnet/CocoPlugin/
Then change the Scanner.frame file in the Frames folder and rebuild the .dll. You don’t need to rebuild the installer or anything, just build the dll and dump it in\Visual Studio 200X\AddIns or something like that, where the old CocoPlugin.dll is.
If that doesn’t work for you for some reason then just let me know exactly how you want the line to read (” = new Dictionary“) and I’ll do a custom build for you.
Hi,
thanks. I changed it, recompiled it and have been using it for a few day.
Great tool!! What a relief. All’s changed just with hitting the save button.
Thanks again.
Pavel K.