Komodo Plugin Update
by Thomas -elfprince13- Dickerson · 02/06/2012 (6:15 pm) · 21 comments
I've been hard at work on my Python based TorqueScript parser, which will soon be plugged into the code-intelligence portion of my plugin for Komodo Edit.
I made several changes to the Python code generation for the byacc variant I was using, and contacted (read: "stalked on Facebook") the maintainer of the Sourceforge project, which has been inactive for close to a decade, in the hopes of contributing my changes back into the wild. I also rewrote the Torquescript lexer using the Plex library.
Updates from the last blog post:
Finally, for fun, I rendered the AST generated by my parser.
If you have GraphViz, you can check out the .dot file
Otherwise, I've rendered a PNG of it, and uploaded it here
You'll have to downlaod it, because it's ~7MB and 45000x9000 pixels, which makes the mediafire image preview sad. It may also make your computer sad if you don't have enough RAM to open a picture that large.
And I'll include this snippet that I previously posted as a comment on my last blog, in case anyone is interested and missed it the first time around:
I made several changes to the Python code generation for the byacc variant I was using, and contacted (read: "stalked on Facebook") the maintainer of the Sourceforge project, which has been inactive for close to a decade, in the hopes of contributing my changes back into the wild. I also rewrote the Torquescript lexer using the Plex library.
Updates from the last blog post:
- I've uploaded a new version of the plugin which should be compatible with all Komodo versions between 4 and 7.
- The link to the Python code for the parser/code-intelligence portion of the project is still here.
- The UDL file for the Scintilla lexer used by Komodo for syntax highlighting is still here (and still has some weirdness).
Finally, for fun, I rendered the AST generated by my parser.
If you have GraphViz, you can check out the .dot file
Otherwise, I've rendered a PNG of it, and uploaded it here
You'll have to downlaod it, because it's ~7MB and 45000x9000 pixels, which makes the mediafire image preview sad. It may also make your computer sad if you don't have enough RAM to open a picture that large.
And I'll include this snippet that I previously posted as a comment on my last blog, in case anyone is interested and missed it the first time around:
Quote:
I never knew this, but with TorqueScript you can put a type specifier before the field declarations within an object, or datablock declaration. Weird, huh? Anyway, the parser needs to know what types are available to the console, in order to distinguish between them and a normal identifier, so here's some code to dump a python dictionary matching type names to their numeric IDs to the console. I put mine in console/dynamicTypes.cpp
ConsoleFunction(dumpConsoleTypes, void, 1, 1, "dumpConsoleTypes")
{
Con::printf("gConsoleTypeTable = {");
ConsoleBaseType *walk = ConsoleBaseType::getListHead();
while( walk != NULL )
{
Con::printf(" '%s' : %d,", walk->getTypeName(), walk->getTypeID());
walk = walk->getListNext();
}
Con::printf("}");
}About the author
C.S. PhD student at Brown University. Project lead for FreeBuild. Administrator, Cemetech tech community. Webmaster for the Village2Village Projects and the Vermont Sustainable Heating Initiative.
#2
02/06/2012 (7:08 pm)
Komodo is definitely the best editing environment I've used for Python or for web languages like PHP, (x)html, CSS, and Javascript. I understand it's quite good at Perl as well, but you catch me writing any of that.
#3
02/06/2012 (10:22 pm)
Well I am writing a lot of PHP, HTML, CSS, JS, and I hate Perl too! Sounds like a good fit!
#4
And as might be expected, GUI code (the last example) has a very blocky hierarchical structure.
Grammars.zip has been updated to account to some of the fixes I made this evening.
[edit]
Hah, just uploaded a new version of the plugin that fixes the problems I was having with single-letter variable names and variable names inside of array indexes. It also turns on soft-character support, so that if you open a string or a bracketed region, or a pair of parentheses, the editor will automatically generate a "soft" version of the closing character, that you can either re-type or array-key over to harden it.
02/06/2012 (11:21 pm)
Just for fun, here are three more AST's (.dot only) that I used to debug the parser against various example scripts in my codebase. It's fun to notice that control structures lead to deep trees (such the example above), and declarative statements lead to wide trees (the second example below). Code which is a mix of both ends up having some really fat portions and some really deep portions (the first example below).And as might be expected, GUI code (the last example) has a very blocky hierarchical structure.
- sfgp.cemetech.net/komodo-plugins/dots/ast_test_accessory.dot (this one has a couple stray nodes because GraphViz is having trouble with the escape sequences in a couple of the node names)
- sfgp.cemetech.net/komodo-plugins/dots/ast_test_player.dot
- sfgp.cemetech.net/komodo-plugins/dots/ast_test_mainmenu.dot
Grammars.zip has been updated to account to some of the fixes I made this evening.
[edit]
Hah, just uploaded a new version of the plugin that fixes the problems I was having with single-letter variable names and variable names inside of array indexes. It also turns on soft-character support, so that if you open a string or a bracketed region, or a pair of parentheses, the editor will automatically generate a "soft" version of the closing character, that you can either re-type or array-key over to harden it.
#5
It was brought to my attention that the GUI interface for GraphViz on Windows is pretty abominable, so I recorded a video with my observations for anyone who was interested.
02/07/2012 (4:41 pm)
It was brought to my attention that the GUI interface for GraphViz on Windows is pretty abominable, so I recorded a video with my observations for anyone who was interested.
#6
02/08/2012 (7:00 am)
Quote:and contacted (read: "stalked on Facebook") the maintainer of the Sourceforge projectHaha, nice. I feel identified :)
#7
02/08/2012 (11:37 am)
Hrmm... ok I am using Komodo 6.1.3 up at work on thier mac minis because there is a bug where komodo 7 does not work correctly with MacOS as in none of the file dialogs appear not even the new project dialogs work. Now. your original plugin worked with 6.1 but the new one say it works but when I goto add the the file extentions torquescript no longer appears in the list and whats worse is I can not find your original plugin to add it back to my komodo 6.1 copy at work.
#8
Here is the error in the log
02/16/2012 (9:15 am)
ok .... I am having issues with the new plugin. It adds to komoedit just fine. but .. When I go to add a file assosiation for *.gui Torquescript is no where in the list even though its shows the torqueScript extantion enabled in the add-ons section of komodoedit.Here is the error in the log
File "/Users/repairshop/Library/Application Support/KomodoEdit/6.1/XRE/extensions/torquescript@cemetech.net/components/koTorqueScript_UDL_Language.py", line 30, in <module>
class KoTorqueScriptLanguage(KoUDLLanguage, KoLanguageBaseDedentMixin):
NameError: name 'KoLanguageBaseDedentMixin' is not defined
No handlers could be found for logger "koLanguage"
[2012-02-16 11:00:33,058] [WARNING] keybindings: [Meta+=] was used for 'cmd_fontZoomIn', overriding to use 'cmd_replace'
[2012-02-16 11:10:15,347] [ERROR] root:
-- EXCEPTION START --
+ 0 (string) Can't set project tree view sort direction: TypeError: ko.places.projects.projectsTreeView is undefined
#9
02/16/2012 (10:20 am)
Huh, looks like I uploaded a buggy version. I'll upload a new one later today/tonight that should be a bit more stable.
#10
02/16/2012 (3:06 pm)
That will be great. thanks a bunch.. I despise working on macs with a passion... but I am forced to at work cause they think they are the greatest thing since the transistor. But if I am going to be forced to use them I would rather use KomodoEdit to do my scripts as I hate Jedits interface and bugginess.
#11
Anyway, the new version of the plugin has been uploaded (at the same URL), so let me know how it works for you. Most of the changes are behind the scenes, since I haven't hooked the code-intelligence up to the autocomplete yet (i.e., I can generate a lot of API information, the editor just doesn't know when to show it to you yet).
02/16/2012 (9:09 pm)
Sorry to hear it Michael - I'm a passionate Mac user, so if there's anything bugging you that you think might be "fixable behavior" feel free to ask me. For Linux users, I usually recommend installing iTerm to replace Terminal, replacing Apple's X11 with XQuartz, and getting cozy with Mac Ports. If you actually enjoy using a Windows environment, I'm not sure there's much I can do for you.Anyway, the new version of the plugin has been uploaded (at the same URL), so let me know how it works for you. Most of the changes are behind the scenes, since I haven't hooked the code-intelligence up to the autocomplete yet (i.e., I can generate a lot of API information, the editor just doesn't know when to show it to you yet).
#12
02/17/2012 (6:24 am)
Plugin works like a charm now. One question? Maybe I am missing it but where do I change the colors of the syntax highlighting in KomodoEdit?
#13
02/17/2012 (6:28 am)
Uggh. Spoke too soon.... It works great on a pc. But on a mac Mini with osx 10.5.9 I get the same errors./Applications/Komodo Edit.app/Contents/MacOS/python/komodo/Crypto/Util/randpool.py:40: RandomPool_DeprecationWarning: This application uses RandomPool, which is BROKEN in older releases. See http://www.pycrypto.org/randpool-broken
RandomPool_DeprecationWarning)
ERROR:xpcom:Unhandled exception calling 'int8 loadModule(in nsISomething, out retval nsISomething);'
Traceback (most recent call last):
File "/Applications/Komodo Edit.app/Contents/MacOS/python/xpcom/server/policy.py", line 277, in _CallMethod_
return 0, func(*params)
File "/Applications/Komodo Edit.app/Contents/MacOS/python/xpcom/server/loader.py", line 92, in loadModule
return self._getCOMModuleForLocation(aFile)
File "/Applications/Komodo Edit.app/Contents/MacOS/python/xpcom/server/loader.py", line 111, in _getCOMModuleForLocation
py_mod = loader.load_module( module_name_in_sys, stuff )
File "/Applications/Komodo Edit.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ihooks.py", line 272, in load_module
m = self.hooks.load_source(name, filename, file)
File "/Applications/Komodo Edit.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ihooks.py", line 170, in load_source
return imp.load_source(name, filename, file)
File "/Users/repairshop/Library/Application Support/KomodoEdit/6.1/XRE/extensions/torquescript@cemetech.net/components/koTorqueScript_UDL_Language.py", line 30, in <module>
class KoTorqueScriptLanguage(KoUDLLanguage, KoLanguageBaseDedentMixin):
NameError: name 'KoLanguageBaseDedentMixin' is not defined
No handlers could be found for logger "koLanguage"
[2012-02-17 08:33:29,355] [WARNING] keybindings: [Meta+=] was used for 'cmd_fontZoomIn', overriding to use 'cmd_replace'
#14
To change your syntax highlighting preferences, go to the Fonts & Colors section of the Komodo Edit preferences, and select the TorqueScript language under the "Language Specific" tab.
02/17/2012 (11:41 am)
Huh, I'm running 10.7, and not seeing those problems. What version of Komodo are you running?To change your syntax highlighting preferences, go to the Fonts & Colors section of the Komodo Edit preferences, and select the TorqueScript language under the "Language Specific" tab.
#15
02/17/2012 (6:40 pm)
I am running Komodo 6.1.3 At work cause oddly enough they have not figured out why Komodo 7 will not work on macs with 10.5.8 or .9. And my work can not upgrade to anything higher because the Server is and older computer and will not upgrade to anything past there.
#16
02/17/2012 (10:23 pm)
Is it a PPC Mac, or just one of the first-gen Intels (Core Duo rather than Core 2 Duo)? I think Komodo 7 may very well be an Intel only application. In either case I can download an older build and give it a test run here.
#17
and Komodo 6 runs like a charm on it. But your plugin does not play well with Komodo 6.1.3. All the other plugins are running just fine. and ... your plugin works great on komodo 7. Have you tried your plugin on komodo 6 since you updated it?
02/18/2012 (5:52 am)
Its is a 1.83 Ghz Core 2 Duo Intel Mac Running Mac OSX 10.5.8and Komodo 6 runs like a charm on it. But your plugin does not play well with Komodo 6.1.3. All the other plugins are running just fine. and ... your plugin works great on komodo 7. Have you tried your plugin on komodo 6 since you updated it?
#18
02/18/2012 (2:09 pm)
If that's the case, I'm not sure why your machine wouldn't be able to run Snow Leopard or Lion, or, for that matter, why Komodo 7 wouldn't run just fine with your existing Leopard installation. That said, I'd like to be able to support Komodo 6 as well as 7, so I'll try and reinstall it on this machine and see how it works.
#19
So we are stuck using 10.5.8 until they upgrade the server which will allow all of us to upgrade. Now all that being said ... KomodoEdit 7 does not support 10.5.8 yet and they do not seem to be sure why
More info Here
So we are stuck only being able to use Komodo Edit 6.1.3 which in turn does not like your plugin. what a viscous little upgrade cycle we are stuck in.
02/18/2012 (2:49 pm)
Our point of sale system at work runs off filemaker and our current version of filemaker only works with 10.5.8 Whats worse is we could upgrade to the newest version of filemaker but its requires the newest mac OSX and the main server computer is so old that the highest OSX it can take is 10.5.8 So we are stuck using 10.5.8 until they upgrade the server which will allow all of us to upgrade. Now all that being said ... KomodoEdit 7 does not support 10.5.8 yet and they do not seem to be sure why
More info Here
So we are stuck only being able to use Komodo Edit 6.1.3 which in turn does not like your plugin. what a viscous little upgrade cycle we are stuck in.
#20
In the mean time, I'll try and figured out what's up with the plugin on version 6.
02/18/2012 (3:07 pm)
Ouch, got it. On the upside, looks like they have a lead on the problem on the bug reporting thread you linked to.In the mean time, I'll try and figured out what's up with the plugin on version 6.

Torque Owner Demolishun
DemolishunConsulting Rocks!
Good job on the parser!