This project has moved and is read-only. For the latest updates, please go here.

Grammar explorer

Oct 4, 2009 at 9:35 AM

hi there,

Thanks Roman for a really cool project.

I've been playing around, creating a frankenstein grammar from the samples and little console input test apps.

Unfortunately I've not been able to get the 'Grammar Explorer' to work.

I followed the instructions in the ReadMe.txt but after selecting Irony.Samples.dll an error dialog pops up with:

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Irony.GrammarExplorer.GrammarItem'.
   at Irony.GrammarExplorer.fmGrammarExplorer.miAdd_Click(Object sender, EventArgs e) in E:\Code\Irony\trunk\Irony.GrammarExplorer\fmGrammarExplorer.cs:line 251
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Closing the dialog and trying to select one of the items available in the Grammar drop-down I get:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Irony.GrammarExplorer.fmGrammarExplorer.CreateGrammar() in E:\Code\Irony\trunk\Irony.GrammarExplorer\fmGrammarExplorer.cs:line 280
   at Irony.GrammarExplorer.fmGrammarExplorer.cboGrammars_SelectedIndexChanged(Object sender, EventArgs e) in E:\Code\Irony\trunk\Irony.GrammarExplorer\fmGrammarExplorer.cs:line 490
   at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

No further info is displayed in any of the tabs.

I'm on svn revision 33075 but have also tried revision 31155 with the same results.

I've not found other threads on the forum or issues being tracked regarding this but if anyone's run into this please give me a heads up.



Oct 4, 2009 at 11:27 AM


Just in case this happens to anyone else:

Right-click on the Grammar drop-down and select "Remove all" prior to following the instructions in ReadMe.txt and adding the grammars from Irony.Samples.dll works fine.

Since the Grammar Explorer caches the values of that drop-down its possible that I checked out a dirty cache from svn which the explorer tried to access on first launch.


Oct 4, 2009 at 1:57 PM

Don't know how I missed it but this was already dealt with here

Oct 4, 2009 at 5:51 PM

thanks for pointing this out, I will add a note to startup instructions.


Oct 7, 2009 at 5:15 PM

Hi Roman,

I ran into the same issue, however - I was not able to add the newly created irony sample assembly to  the grammar explorer ('...not derived from irony grammar').

The asm.GetTypes call returned grammars with a base type of 'irony.compiler.grammar', which of cause does not match the expected 'irony.parser.grammar'.  I checked the types in  the example grammars - OK.

I am using the latest change set  (33075) without any changes.

Any idea ?



Oct 7, 2009 at 5:43 PM
Edited Oct 7, 2009 at 5:44 PM

Just rebuild the irony.Samples assembly - looks like you're trying to load from an old version, built with prev version of Irony 

and of course don't forget to "Remove All" right after you start Grammar Explorer for the first time

Oct 7, 2009 at 7:42 PM


I did rebuild the  project - but I did not realize that Irony explorer kept a file path from from a previous evaluation.

Anyway, this is a great project!