Use Irony on Mono to create PHP parser?

Jul 26, 2009 at 9:08 AM

Hello!

I'm interrested to know if Irony can be used (on Mono) to create a parser for a non .NET language like PHP. What I want is to get code helping me to create features like code completion for PHP in MonoDevelop.

I'm new to lexers/parsers.

-Martin

Coordinator
Jul 26, 2009 at 5:18 PM

Well, you asked two questions - Irony on Mono, and is it possible to encode a grammar for language like PHP. As for the latter, the answer is definitely yes, I don't see why you can't implement PHP grammar in Irony; you can try it even without Mono

As for Mono, I would like to know it myself. Definitely it is possible to port Irony to Mono, the question is just how many changes will be needed. I suspect that Runtime classes cannot be ported yet, they use lambda expressions which come in .NET 3.5, and Mono is not there yet, as far as I know. As for the rest, it should be portable without big problems. Try it and let everybody know the results, maybe share some code. On my side, I'll try to provide all help I can

Roman

Jul 27, 2009 at 12:00 PM

They claim: "Develop in C# 3.0 (including LINQ)," and afaik that requires lambda expressions(?)

 

Jul 27, 2009 at 3:19 PM

Mono has supported lambda expressions for quite some time now.

Jul 30, 2009 at 9:58 PM

I can run the grammar explorer on mono but when I choose a grammar in the dropdown combobox I get an exception:

System.NullReferenceException: Object reference not set to an instance of an object
  at Irony.GrammarExplorer.fmGrammarExplorer.CreateGrammar () [0x00011] in /home/marlun/tmp/irony-28496/Irony.GrammarExplorer/fmGrammarExplorer.cs:251
  at Irony.GrammarExplorer.fmGrammarExplorer.cboGrammars_SelectedIndexChanged (System.Object sender, System.EventArgs e) [0x00013] in /home/marlun/tmp/irony-28496/Irony.GrammarExplorer/fmGrammarExplorer.cs:451
  at System.Windows.Forms.ComboBox.OnSelectedIndexChanged (System.EventArgs e) [0x00023] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs:1207
  at System.Windows.Forms.ComboBox.SetSelectedIndex (Int32 value, Boolean supressAutoScroll) [0x000ab] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs:1765
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.ComboBox:SetSelectedIndex (int,bool)
  at System.Windows.Forms.ComboBox+ComboListBox.OnMouseUp (System.Windows.Forms.MouseEventArgs e) [0x00060] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs:2740
  at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message& m) [0x00081] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5595
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x0017c] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5332
  at System.Windows.Forms.ComboBox+ComboListBox.WndProc (System.Windows.Forms.Message& m) [0x0001a] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs:2817
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:234
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:215
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00085] in /home/marlun/src/mono/mono-2.4.2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:242

Couldn't debug because monodevelop froze when I tried to debug it but I'm showing this so you know :)

Coordinator
Jul 31, 2009 at 12:05 AM

Hi!

Nice to hear that at least grammar explorer opens! Can you investigate it and provides some more info, maybe using some debug.Write if debugger doesn't work?

thanks

Roman

 

Aug 2, 2009 at 3:56 PM

I had the 'Object Reference not set to an instance of the object' error as well...it had to do with the combobox used to choose a grammar. 

 - In Grammar Explorer, click the 'dotdotdot' button beside the grammar choosing combobox, choose 'Remove All', then click again, choose 'Add Grammar' and point it at Irony.Samples.dll

 - Maybe try deleting your copy and checking out a fresh copy from subversion.

Aug 10, 2009 at 10:28 AM

If I removed all and added them again like budmandave said I could choose a grammer in the combobox however when I go to Test and start writing something the app closes without any error message.

Coordinator
Aug 11, 2009 at 9:45 PM

Sorry, I don't have Mono installation, can't help you with anything... try to debug around, see what's going on and why it crashes. Basically it shouldn't, the form/app have global exception handler, see why it fails...

Jul 8, 2010 at 9:05 PM
budmandave wrote:

I had the 'Object Reference not set to an instance of the object' error as well...it had to do with the combobox used to choose a grammar. 

 - In Grammar Explorer, click the 'dotdotdot' button beside the grammar choosing combobox, choose 'Remove All', then click again, choose 'Add Grammar' and point it at Irony.Samples.dll

 - Maybe try deleting your copy and checking out a fresh copy from subversion.

@Budmandave @marlun It has been a while since either of you posted on this thread wondering how far you got with mono and php. I have been asked to consider implementing something similar. @rivantsov I have been using the irony parser as an assembly in SQL server and the extended search capability is great. -Michael White
Jul 8, 2010 at 9:42 PM
Hello mnwcsult, My foray into parsing with Irony is pretty much dead in the water...I was actually trying to make a visual studio language package for Digital Mars D Language. I started with this article at CodeProject if that helps: http://www.codeproject.com/KB/recipes/VSLanguageService.aspx Dave
Jul 9, 2010 at 2:00 AM

I had looked at using Irony with Mono a while ago.  Irony works fine on Mono; unfortunately the Grammar Explorer does not because it has some MS Windows specific code for things like text color and cursor position.  I'll have to find the specific place in code and maybe we can find a work around and have Roman add in a #MONO.

Jul 9, 2010 at 4:22 AM

Ok, some of the MS Windows specific code is located in RichTextBoxHighlighter.cs under the regions WinAPI and Colorizing Tokens.

I can confirm that the Grammar Explorer runs with some minor glitches on a Mac OSX running Mono 2.6.4 if you do as mentioned earlier, 1) clear the Grammar list first before selecting your grammar and 2) disable syntax highlighting.

 

 

 

Jul 18, 2010 at 1:03 AM
mindcore wrote:

I had looked at using Irony with Mono a while ago.  Irony works fine on Mono; unfortunately the Grammar Explorer does not because it has some MS Windows specific code for things like text color and cursor position.  I'll have to find the specific place in code and maybe we can find a work around and have Roman add in a #MONO.

Hi Mindcore

I had done a  Visual Studio / Mono conversion on something else a couple of years ago, the hang up would be in the Visual components. Otherwise Irony would work. So saying that in my production version which does not display anything it just parses text and returns the grammar does work under mono.

 

My real issue is ... adapting irony for "FULL TEXT SEARCH" with MYSQL.

 

Anyone with hints?

Aug 7, 2010 at 5:19 PM
Edited Aug 7, 2010 at 8:44 PM

Hello Marlun...have you gone ahead with PHP grammar for Irony?...I'm looking at doing one now :)