Page 1 of 1

comment is interpreted by compiler ucc

Posted: Tue Jun 09, 2020 8:47 pm
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.

Re: comment is interpreted by compiler ucc

Posted: Wed Jun 10, 2020 1:50 pm
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 );
			}

Re: comment is interpreted by compiler ucc

Posted: Wed Jun 10, 2020 7:37 pm
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.