comment is interpreted by compiler ucc

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

comment is interpreted by compiler ucc

Post by Barbie »

This example shows that a comment is not fully ignored by the compiler:

Code: Select all

/* class Prototype */
class Test extends Actor;
ucc.exe wrote:Error, Class must be named Prototype, not Test
Failed due to errors.
  • Single line comment "//" works.
  • Expanding the comment with other characters or white space leads to the same result.
  • Defining the class before the comment works.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Chris
Experienced
Posts: 134
Joined: Mon Nov 24, 2014 9:27 am

Re: comment is interpreted by compiler ucc

Post by Chris »

This is because UClassFactoryUC is parsing the class name and default properties ahead of time.
As you can see in the code below, there is nothing that handles multiline comments.
It looks like multiline comments was added later on and they simply forgot, or were too lazy to add the code in the factory.

Code: Select all

			// Get script text.
			ScriptText.Logf( TEXT("%s\r\n"), *StrLine );

			// Stub out the comments.
			INT Pos = StrLine.InStr(TEXT("//"));
			if( Pos>=0 )
				StrLine = StrLine.Left( Pos );
			Str=*StrLine;

			// Get class name.
			if( ClassName==TEXT("") && (Temp=appStrfind(Str, TEXT("class")))!=0 )
			{
				Temp+=6;
				ParseToken( Temp, ClassName, 0 );
			}
			if
			(	BaseClassName==TEXT("")
			&&	((Temp=appStrfind(Str, TEXT("expands")))!=0 || (Temp=appStrfind(Str, TEXT("extends")))!=0) )
			{
				Temp+=7;
				ParseToken( Temp, BaseClassName, 0 );
				while( BaseClassName.Right(1)==TEXT(";") )
					BaseClassName = BaseClassName.LeftChop( 1 );
			}
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: comment is interpreted by compiler ucc

Post by sektor2111 »

:lol2:
Is this even a problem ? I think after compiling package normally I can load this package in Editor -> EditScript -> Writing two page of comments in top of script -> Save package with new script (without recompiling changes) - it's like stripping out code without to recompile anything. You can even replace entire code with some lousy things which nobody will compile later as long as the "TEXT" can be "encrypted" on purpose a bit later... I recommend opening some web page in whatever language "encrypted" by default and copy some news (or fake news) from there inside class... some "coders" will be surprised to see some "birdisch" programming language supported in UT :mrgreen: .

Note: These habits won't help UT development in any way.
Post Reply