Game Development Community

TS parser bug

by Tom Spilman · in Torque Game Engine · 07/18/2006 (11:17 pm) · 6 replies

It took me 30 minutes to spot this one. This compiles and executes...

%newvec = VectorScale( %myvec, * 5000 );

This should not compile and execute.

I guess i'll try to fix it and add this feature while i'm at it.

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.


#1
07/19/2006 (1:10 am)
File, line and SDK version? I searched the whole SDK and I could not find it... BTW, if you had used Torsion you would have spotted it immediately, as it pre-compiles everything before launching the exe.
#2
07/19/2006 (1:20 am)
@Alberto:

Oh shit man, that's funny! :D I'm sure Tom Spilman, the creator of Torsion, knows if he could had spotted it in his own IDE. Anyway. The reason you can't find it is because it's a syntax, a consoleMethod. That particular line is not nessecarily used anywhere.

Probably an issue somewhere in BASscan or CMDscan.

@Tom:

I noticed this bug too when I made an error once. I can't access that link though, so I guess it's a TGB specific feature?
#3
07/19/2006 (1:57 am)
Ops! :-D I just wanted to talk about my favorite tool and I did not look at whom I was talking to.
Quote:The reason you can't find it is because it's a syntax, a consoleMethod. That particular line is not nessecarily used anywhere.
These sentences make no sense to me, could you elaborate, please? What does "a syntax, a consoleMethod" mean? Even if the line is not used anywhere, if it's in a cs file then Torsion should pre-compile it anyway and give an error. Right? Anyway, I am very confused about where the line effectively is (a cs file? a C++ file? TGB? probably not in TGE, as I could not find it) so I believe there's definitely something big that I am missing...
#4
07/19/2006 (2:43 am)
Hey Tom2,

If you have a look at CMDgram.y, when it's defining expr, it explicitly makes that syntax valid here:

| '*' expr %prec UNARY
      { $$ = TTagDerefNode::alloc(); }

(expr starts about line 339, that specifically is line 362) ...

The same applies for - (which of course is unary negation and thus totally valid). It looks like it's used to derefence some tag thing (maybe tagged strings? not sure, I didnt dig any deeper then this).

I agree it's confusing and probably not used very often (if at all), but it definately looks like it's intentional and not actually a bug/syntax error.

T.

Edit: The heat must be getting to me because i have no idea what this does ;-) I think it might either be a throwback to ancient code or be part of the /* */ comment stuff, but then again it could be something else ;) Messing about in the console with various things doesnt really yield anything except for "", and the definition of TTagDerefNode looks strangely "empty".
#5
07/19/2006 (2:52 am)
@Alberto:

You can't search for:

Quote:
%newvec = VectorScale( %myvec, * 5000 );

and expect to find it because it has not been used in the SDK script, to my knowledge. Tom is just showing an example to illustrate the problem. It's a syntax, not a line somewhere. It could be something from Tom's codebase. Anyway we're offtopic.
#6
07/19/2006 (9:23 am)
@Alberto - It's a line of TorqueScript from one of my projects. The TorqueScript compiles and executes when it really shouldn't.

@Tom1 - Very interesting... looking further this is what TTagDerefNode does...

U32 TTagDerefNode::precompile(TypeReq)
{
   return 0;
}

U32 TTagDerefNode::compile(U32*, U32 ip, TypeReq)
{
   return ip;
}

TypeReq TTagDerefNode::getPreferredType()
{
   return TypeReqNone;
}

... nothing... it seems like a feature that was either removed or never implemented, but the syntax was left as valid. In a bit i'll test removing the syntax and compiling all the scripts i can find to see if it effects more than just a dead feature.