GarageGames Blog #1 wrote:
Anyone who's developed for Torque on OS X knows how limited our options have been as far as a good programmer's text-editor for composing Torque Script files. Komodo Edit is a fantastic (and free, though it's IDE cousin is not) editor based on Scintilla, Python, and Mozilla. It supports both extensible syntax highlighting, extensible linting (syntax checking) and extensible code-sense (autocomplete). After struggling to understand the User-Defined Language architecture - it's limited to Cascading Style Sheet, Client-Side Languages, Server-Side Languages, and Markup type languages, and the state machine for the lexer evidently begins in Markup mode, and to get the SDK working on both Lion (PPC only binaries) and Vista (VirtualStore is the worst thing I've ever encountered in what's supposed to be a useable operating system), I have produced a working plugin. At the moment it only supports the UDL/syntax-highlighting portion of the features mentioned above, but I plan to keep hacking away at it. Also, for whatever reason SSLs have one additional color available as compared to CSL.

If you just want to download it, click here and then drag-and-drop the downloaded file into the main editing window of Komodo Edit (or IDE), approve the installation, and restart. Then change the file associations and coloring to fit your needs and have fun.


Here we have examples of two different color schemes:





A couple things to note:

  • Komodo Edit supports C# development, so you'll have to change the file-extension/language association for *.cs in the preferences. You can use this as an opportunity to add associations for *.gui and *.mis as well
  • The default color-scheme doesn't do anything special for variables or named identifiers, but you can change this to suit your fancy
  • I developed this under Komodo 6.1, but version 7 was released in the last couple days, so I'll be upgrading to that and testing it out there as soon as possible
  • For whatever reason, variable names with only a single character aren't lexed as variable tokens. Also, the array[index] syntax can confuse the syntax highlighting in certain scenarios. If you want to take a look at, ponder, and comment on the regex/state-machine code which is used for the lexing, I've embedded it below. It's derived from the example code the Komodo developers provide for JS and PHP lexers, and incorporates TorqueScript specific features which I've extracted
  • Tagged (single quoted) strings right now are color coded as regex tokens, since TS doesn't support regex syntax, by default. If you've added that somehow to your installation, let me know and it might motivate me to color it using the markup-tag colors instead.
  • I've also added rudimentary auto-indent/dedent code.



[edit]

The forum software breaks code with backslashes. Click here if you want to take a look at the lexer code.



GarageGames Blog #2 wrote:

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:


  • 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 download it, because it's ~7MB and 45000x9000 pixels, which makes the Google Drive 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


Code:
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("}");
}
Good Lord that's a large image! I can't open it with anything without destroying my computer. You were not kidding. Is there any way you could condense it? like, remove every odd-numbered pixel or something?

Also, isn't there a risk someone will upload this somewhere where they can direct link it, and then embed it in a forum topic to crash every browser that tries to load the topic?
DShiznit wrote:
Good Lord that's a large image! I can't open it with anything without destroying my computer. You were not kidding. Is there any way you could condense it? like, remove every odd-numbered pixel or something?

Get this: http://graphviz.org/Download_windows.php and look at the .dot file version, which is essentially just a very detailed vector graphic.

That actually IS a condensed version, in that I used optipng to convert it from 32bpp image to an 8bpp image, cutting it down from around 25MB. If I make it smaller, the text will become unreadable.

If you really want to do the rasterized version, you might try just using the OS's previewing capabilities?

DShiznit wrote:
Also, isn't there a risk someone will upload this somewhere where they can direct link it, and then embed it in a forum topic to crash every browser that tries to load the topic?


probably, but they could have done that anyway with paint or the gimp, or pretty much anything else, and there are technical hurdles to overcome - finding somewhere with unlimited bandwidth to host it that forcibly resize the image, and attacking someone whose computer is low on RAM but whose internet connection is fast enough to deliver the image before they can kill it. I suspect browsers probably even have safeguards against such things.


[edit]


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.





Grammars.zip has been updated to account to some of the fixes I made this evening.
Is there a way to zoom out in the Graphviz editor? It's hard to see the relationships on a macro level this way.
DShiznit wrote:
Is there a way to zoom out in the Graphviz editor? It's hard to see the relationships on a macro level this way.


Yeah, there should be a zoom out and a zoom in button in the toolbar (or under the view menu). I can't say exactly where it is, since I'm looking at the Mac UI, but I'm assuming the two have feature parity.
There are no zoom buttons, in fact, there aren't many buttons to speak of. Just a layout button and a settings button. Settings opens a dialog box for exporting(as a png by default) and the layout button causes a crash. There's another program in my Graphviz start menu folder, but it crashes on load. I can't shake the feeling this is primarily a Unix program of which I'm running a token version with no features or support.
DShiznit wrote:
There are no zoom buttons, in fact, there aren't many buttons to speak of. Just a layout button and a settings button. Settings opens a dialog box for exporting(as a png by default) and the layout button causes a crash. There's another program in my Graphviz start menu folder, but it crashes on load. I can't shake the feeling this is primarily a Unix program of which I'm running a token version with no features or support.


Let me fire up my VM and see what I can figure out. I'll report back in a few minutes.
Thanks. It might just be something stupid like a runtime I was supposed to install but didn't.
DShiznit wrote:
Thanks. It might just be something stupid like a runtime I was supposed to install but didn't.


Oh dear, I don't think I've ever seen such ridiculous feature disparity between different versions of the same software package on different platforms. I'm actually not sure what to do about that.
elfprince13 wrote:
DShiznit wrote:
Thanks. It might just be something stupid like a runtime I was supposed to install but didn't.


Oh dear, I don't think I've ever seen such ridiculous feature disparity between different versions of the same software package on different platforms. I'm actually not sure what to do about that.


Well at least it's not just me. I have to go to bed now as it's 4:30 in the morning. Tomorrow(later today) is gonna suck...
DShiznit wrote:
Well at least it's not just me. I have to go to bed now as it's 4:30 in the morning. Tomorrow(later today) is gonna suck...


I'll try and take a video showing it off tomorrow or something.

[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.


[edit 2]
DShiznit, this is for you
clool
Komodo Edit 8 has been released. I'll be uploading a new version of the plugin soon. In the meantime, I've posted it to GitHub as well for anyone who wants to build their own. https://github.com/elfprince13/KomodoTS
*bump*

This has been added to the community package manager for Komodo, in case anyone is still paying attention.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement