xtext

It's been a while

Yeah. I know. So, in no particular order, here’s what’s been happening I’ve suspended working on my unrealscript plugin for eclipse and open-sourced it. The basic grammar rules for parsing and lexing are in place, but it looks like the unrealscript classes that come with the UDK have more exceptions than rules in them, and I’m tired of working on it. The original plan was to finish it and sell it to indie devs, with a free-for-non-commercial-use license, but I already have a day-job where I do boring stuff every day to pay the bills, don’t really see the point in doing the same thing in my free time I started porting (read:trying really hard to port) the newly-open-sourced Doom 3 engine to NaCl.

Still alive and kicking

The project is still alive and kicking, I’ve just been busy with preparations for applying for an M.S. Made some progress today and managed to get array elements to cross-reference correctly anywhere in the class definition, but now I have a new problem: keywords self and super. They’re just keywords, but they’re supposed to behave like cross-references.self is the current class, and super is the parent class. Now, I’ve specified a rule for cross-references, which goes something like

Just built a scope-chain for parent class, implemented interface and "within" class

And I’m rather proud of myself for being able to do this. Simply put, if you have a class class A; var int A1; and an interface interface I; var int I1; and one more class class W; var int W1; and yet another class class Dick extends A implements I within(W); then for a variable Dick d of type Dick, all of the following will be resolved correctly: d.A1 d.

Fixed the issue with scope resolution inside DefaultProperties

Won’t go into the solution as it’s pretty similar to the approach I outlined in a previous post, but I did learn something interesting along the way. When you declare a custom scope resolution function, if you return IScope.NULLSCOPE, Xtext treats it as no variables being present inside that scope. On the other hand, if you return null, Xtext will treat it as your function not handling variables for that scope, and will use its own scope resolution instead.

Minor update

Plugging away at the code, fixing errors one-by-one. One interesting problem I’ve yet to solve is for scope resolution inside the DefaultProperties block. Normally, struct variables are resolved by [parent variable].[child variable]. However, inside the DefaultProperties block, struct variables can be assigned values as follows: For a variable “Outputs” declared as struct ExpressionOutput { var string OutputName; var int Mask, MaskR, MaskG, MaskB, MaskA; }; var array<ExpressionOutput> Outputs; the default values of the struct’s child variables can be initialized as:

Counting nested braces inside comments in xtext

So, I finished one playthrough of Dark Souls, and since I’ve exceeded the monthly download limit imposed on my net connection, the speed is down to 1/4th i.e. 256 Kbps, which translates to 20-30 KBps browsing speed, which is apparently insufficient for the multiplayer component of Dark Souls. Having experienced the multiplayer, it’s hard to play through the game a second time offline, so I’m back to my eclipse plugin development for now.

A brief hiatus from plugin development

I’ll be taking a break from developing this plugin, either till October 12th (Battlefield 3 beta) or October 31st (Ludum Dare October 2011 Challenge). I’ve been wanting to pick up Unity for a while now, and this challenge seems like a good opportunity to do so. I have one idea for a game I might be able to finish within a month, but the idea’s still pretty vague in my head, so I’m still not decided on whether I’ll participate or not.

Scoping nested variable declarations

(Pardon the title, I’m basically making post titles based on what feature I added/fixed, so there might be duplicates since I’m not actually bothering to go back and check whether there’s another post with a similar title. Only getting on an average of 10 hits a day or so, figure nobody will notice. Also, the code in the samples doesn’t really have terrible indentation, I just have to chop up the long grammar rules to make them somewhat fit in the page-width.

Resolving scope for variables inside a function's body

Unrealscript is pretty similar in design to OO languages like C++ and Java, in that you declare classes, and each class has several member variables, function declarations, structs, enums etc. Inside a function, only the following variables need to be accessible: Arguments passed to the function Variables declared inside the function Members of the class the function resides in Members of each super class of the current class Now, I don’t know how exactly (magic?

Quick update regarding next post

Fought my way through Xtext’s obscure (for me) feature of global and local scope resolution to figure out how to properly cross-reference members for implementing data structures like structs. But it’s quite late now, so I’ll make a post on that tomorrow.

Multiline nested comments in Xtext

When you declare your grammar in xtext, you can specify a few terminals that can appear anywhere in your model file (as opposed to normal rules, which can appear only at places assigned by the grammar). You do this by specifying those terminals as being “hidden”. For example, grammar com.wirywolf.Unrealscript hidden(WS, ML_COMMENT, SL_COMMENT) will allow terminal rules named WS, ML_COMMENT and SL_COMMENT appear anywhere in your model. The objective behind this is to specify blocks of text that the parser doesn’t have to worry about while parsing your DSL model.

An Eclipse plugin for Unrealscript programming using Xtext

Well, for the past month or so I’ve been working on a plugin for Eclipsethat can be used for writing code for Epic’s Unreal Development Kit (UDK). I’m using the Xtext framework for this. The motivation behind this is: The only other IDE with a plugin for Unrealscript (UDK’s scripting language) is Visual Studio with Pixel Mine’s nFringe, and it kinda sucks I like Eclipse This is actually something that I attempted to do a year or so back, but gave up due to the lack of documentation for beginners and my own lack of programming experience.