Game Development Community

Does VS regenerate the TS compiler?

by Daniel Buckmaster · in Torque 3D Professional · 09/27/2012 (4:09 pm) · 7 replies

I've been making some little changes to TS. Here are a series of commits where I added keywords for client and server commands, to make declaring those a bit nicer on the eyes. However, two of the three commits are large chunks of nonsense that is auto-generated by flex/bison.

When we compile the engine in VS, does the TS compiler get automatically generated? If so, it would save having to commit those nasty auto-generated compiler files. If not, it might be worth looking into whether that's possible!

EDIT: from preliminary research, it seems like this doesn't happen.

Oh, and in case you don't want to read through the flex/bison code: my changes basically add new keywords for defining serverCmd and clientCmd functions.
// Old code
function serverCmdDoMyThing(%client)
{
   ...

// New code
servercmd doMyThing(%client)
{
   ...
Internally, this keyword just creates a regular function, but prefixes the name with serverCmd, so the changes were minimal.

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
09/27/2012 (4:51 pm)
That's because Visual C++ has no way to determine if the flex and bison scripts were modified in any way to call the batch file to invoke flex and bison to regenerate the compiler's sources. I suppose you could write a custom bat file to do that for you, but have fun with that.

Also, you do know that by creating new compiler keywords you've broken/confused Torsion and any other TorqueScript IDE, right?
#2
09/28/2012 (1:49 am)
The batch file seems to run very quickly for me, so it shouldn't be too intolerable to run it on each compile, though wasteful. I just have no idea how to set that up.

I hadn't considered that, mostly because I don't use an IDE for TS. Good point, though. Probably means I won't be pull-requesting this change, but I think it's worthwhile. It's similar to the 'datablock' keyword, basically an alias for 'new' which makes code easier to read.
#3
09/28/2012 (2:32 am)
You need to run the generateCompiler.bat file to regenerate the compiler each time you modify it. Unless you are making substantial changes every 5 minutes to the compiler syntax, there isn't really much need to regenerate it.

It's a pity TorqueScript isn't generic enough to allow metaprogramming without modifying the compiler.
#4
09/28/2012 (9:53 am)
I like that idea, it's like logical and stuff :D

Nothing wrong with breaking/confusing Torsion!
#5
09/28/2012 (10:26 am)
Hm, if people are gunna go all overhauling TS like this, maybe I should wrap up the in-engine script editor tool I've had in a 70%(ish) functional state for the past month and get that posted.
Super flexible, has the coloration of the text, and lets you define the words it uses for markers for the coloration, etc, etc.
Just needed bugfixes and the intellisense functionality and it'd be fairly solid(you know your tool is flexible when you can edit the editor WITH the editor, save, and it applies the changes :)
My ideal goal is a replacement for torsion.
#6
09/28/2012 (3:36 pm)
James: I figured that out (after having a go with your getWords sugar resource ages ago!), I was just wondering if I could get VS to do it for me so that I don't have to commit changes to auto-generated files.

That sounds great, Jeff! I've actually just started working on a script update dialog due to questions raised about the auto-script updater here, but it sounds like having a script editor integrated in T3D would make that redundant.

I've had some other TorqueScript tweaks in mind for a while as well, mostly after doing tons of JavaScript programming and having a blast. A weird, weird blast, but eye-opening.
#7
09/28/2012 (10:37 pm)
Have you had your V8 today?...

JQuery is fun!!!