I would like to edit MacRuby code in a Cocoa text window, press a button to "compile" it and display error information in a status line. I would also like to highlight the position of the error in my text window. How do I programmatically grab the error location from an evaluation or compilation error? Thanks, Joel --- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
I would catch the SyntaxError exception and poke at its content. If you want to catch syntax errors ahead of execution, you can use the ripper extension, which is bundled in MacRuby. It's basically an interface to the Ruby parser and allows you to retrieve the AST. Laurent On Jan 6, 2011, at 12:13 PM, Joel Reymont wrote:
I would like to edit MacRuby code in a Cocoa text window, press a button to "compile" it and display error information in a status line.
I would also like to highlight the position of the error in my text window.
How do I programmatically grab the error location from an evaluation or compilation error?
Thanks, Joel
--- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
The IRB::Source class uses Ripper and might be of help as well. On 6 jan 2011, at 23:50, Laurent Sansonetti wrote:
I would catch the SyntaxError exception and poke at its content.
If you want to catch syntax errors ahead of execution, you can use the ripper extension, which is bundled in MacRuby. It's basically an interface to the Ruby parser and allows you to retrieve the AST.
Laurent
On Jan 6, 2011, at 12:13 PM, Joel Reymont wrote:
I would like to edit MacRuby code in a Cocoa text window, press a button to "compile" it and display error information in a status line.
I would also like to highlight the position of the error in my text window.
How do I programmatically grab the error location from an evaluation or compilation error?
Thanks, Joel
--- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On Jan 7, 2011, at 12:20 AM, Eloy Duran wrote:
The IRB::Source class uses Ripper and might be of help as well.
Why would it be beneficial to catch syntax errors before execution by getting hold of the AST using Ripper? --- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
In the case of IRB, it's mostly because of collecting data about the code, e.g. at what indentation level is the current code. Besides that I prefer not to use exceptions for control flow :) PS: In case you are writing some kind of REPL as part of a bigger app, contact me off list, because we might be overlapping work on that part. On Fri, Jan 7, 2011 at 1:22 AM, Joel Reymont <joelr1@gmail.com> wrote:
On Jan 7, 2011, at 12:20 AM, Eloy Duran wrote:
The IRB::Source class uses Ripper and might be of help as well.
Why would it be beneficial to catch syntax errors before execution by getting hold of the AST using Ripper?
--- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Eloy Duran
-
Joel Reymont
-
Laurent Sansonetti